
I am trying to distutilsify my Python packages, but I am stuck at an almost undocumented point: installation of header files. In fact, the Distutils manual only says that it can be done, but not how, and the only real-life example that does it seems to be NumPy. Here's my situation: I have a distribution called "ScientificPython" which contains a Python package "Scientific", which in turn contains an extension module for which some header files exist. These files are supposed to end up in $prefix/pythonx.y/Scientific, such that they can be included as "Scientific/xxx". However, if I do exactly what NumPy does, they end up in $prefix/pythonx.y/ScientificPython. The only way I found to change the header installation directory is by specifying an option during installation, but I want this defined in setup.py. Any suggestions? Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------

Konrad Hinsen wrote:
I am trying to distutilsify my Python packages, but I am stuck at an almost undocumented point: installation of header files. In fact, the Distutils manual only says that it can be done, but not how, and the only real-life example that does it seems to be NumPy.
Here's my situation: I have a distribution called "ScientificPython" which contains a Python package "Scientific", which in turn contains an extension module for which some header files exist. These files are supposed to end up in $prefix/pythonx.y/Scientific, such that they can be included as "Scientific/xxx". However, if I do exactly what NumPy does, they end up in $prefix/pythonx.y/ScientificPython. The only way I found to change the header installation directory is by specifying an option during installation, but I want this defined in setup.py. Any suggestions?
There is a command install_headers which could be what you are looking for. If that doesn't work, you could try to use the data_files directive for this (I had to subclass it though to do anything useful...). -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/

There is a command install_headers which could be what you are looking for. If that doesn't work, you could try to use
I think this is what I am already using by writing headers = [...] (please correct me if I am wrong). And it works fine, except that I don't know how to tell it *where* I want my header files installed. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------

Konrad Hinsen wrote:
There is a command install_headers which could be what you are looking for. If that doesn't work, you could try to use
I think this is what I am already using by writing headers = [...] (please correct me if I am wrong). And it works fine, except that I don't know how to tell it *where* I want my header files installed.

This again defaults to:
'unix_prefix': # without PYTHONHOME set 'headers': '$base/include/python$py_version_short/$dist_name',
'unix_home': # with PYTHONHOME set 'headers': '$base/include/python/$dist_name',
'nt': 'headers': '$base/Include/$dist_name',
'mac': 'headers': '$base/Include/$dist_name',
At least in theory, adding the install_header option to your setup.cfg file should do the trick.
If I know the precise path name, yes. But I don't. Perhaps I could set install_headers = "$base/include/python$py_version_short/xxx" in setup.cfg and have the variables expanded (I didn't check if this works), but I'd still have to assume a specific installation scheme. What I really want is replace $dist_name with the name of my package, for the rest I fully trust distutils. Anyway, for the moment I am giving up; I'll continue with my own home-grown installation scripts instead of switching to distutils. For my next project, I'd need a subdirectory within the main header file directory, and that seems completely beyond the capabilities of distutils in its current form. I suppose I could do it with extensions to distutils, but at the moment I simply don't have the time to figure this out without any documentation. And here's yet another challenge: I have a package that produces a new Python interpreter (including a module that has to be static), which should be installed to something like /usr/local/bin. Perhaps that could be done via the data file installation, but then again I don't have the time to figure it out at the moment. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------

What I really want is replace $dist_name with the name of my package, for the rest I fully trust distutils.
You just have to give up in order to realize that this can be done rather easily: from distutils.command.install_headers import install_headers class modified_install_headers(install_headers): def finalize_options(self): install_headers.finalize_options(self) self.install_dir = \ os.path.join(os.path.split(self.install_dir)[0], 'Scientific') setup( ... , cmdclass = {'install_headers': modified_install_headers}) Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais -------------------------------------------------------------------------------

On Wed, Mar 28, 2001 at 06:33:57PM +0200, Konrad Hinsen wrote:
NumPy does, they end up in $prefix/pythonx.y/ScientificPython. The only way I found to change the header installation directory is by specifying an option during installation, but I want this defined in setup.py. Any suggestions?
Putting this in a setup.cfg file should do it: [install_headers] install_dir=/wherever I don't think you can define anything in the setup() call to set the directory. --amk
participants (3)
-
Andrew Kuchling
-
Konrad Hinsen
-
M.-A. Lemburg