How can I specify or add a directory to the Python.h search path during module build / install using setup.py?

I run Linux and loaded the python module, which should install without access to anyone but to my / home / user directory (I don't have root privileges or the ability to chase them).

This, of course, requires a Python source. I downloaded and placed this in the specified user directory.

When contacting the administrator to copy the correct files to / usr / include / python 2.7, this is the easiest way to do this, I hope for a more general and portable solution to this problem.

Changing only the data in the module source (MANIFEST.in, README.txt, setup.py, etc.), how can I add an arbitrary directory to the search path for Python.h and friends?

(Without the solution, "python setup.py build" will continue to return with the error "Python.h: There is no such file or directory")

Many thanks.

+8
python build install setup.py include-path
source share
1 answer

To create compiled packages, you need to specify the setup.py configuration step to look elsewhere for the included files. I believe this can be done like this:

 python setup.py config --with-includepath=/path/to/your/install/of/python/includes/ 

You may also need to tell setup.py about the location of other files (such as libraries), in which case look:

 python setup.py config --help 

and check the --libraries and --library-dirs . To change the location where the resulting package is installed, use the prefix after assembly, for example:

 python setup.py install --prefix=/path/to/install/to/ 

Although the exact combination of required parameters may depend on the package you are installing. If you need to do this often, I think it can be done by specifying the setup.cfg configuration file, as discussed here .

+7
source share

All Articles