[Distutils] Distutils improvements regarding header installation and building C extension modules
Sylvain Corlay
sylvain.corlay at gmail.com
Wed May 25 12:01:51 EDT 2016
Hello everyone,
This is my first post here so, apologies if I am breaking any rules.
Lately, I have been filing a few bug reports and patches to distutils on
bugs.python.org that all concern the installation and build of C++
extensions.
*1) The distutils.ccompiler has_flag method.*
(http://bugs.python.org/issue26689)
When building C++ extension modules that require a certain compiler flag
(such as enabling C++11 features), you may want to check if the compiler
has such a flag available.
I proposed a patch adding a `has_flag` method to ccompiler. It is an
equivalent to cmake' s CHECK_CXX_COMPILER_FLAG.
The implementation is similar to the one of has_function which by the way
has a pending patch by minrk in issue (http://bugs.python.org/issue25544).
*2) On the need for something like pip.locations.distutils_scheme in
distutils*
(http://bugs.python.org/issue26955)
When installing a python package that has a directive for the install_headers
distutils command, these headers are usually installed under the main
python include directory, which can be retrieved with
sysconfig.get_path('include') or directly referred to as the 'include' string
when setting the include directories of an extension module.
However, on some systems like OS X, headers for extension modules are not
located in under the python include directory
/usr/local/Cellar/pythonX/X.Y.Z/Frameworks/Python.framework/Versions/X.Y/include/pythonX.Y
but in
/usr/local/include/pythonX.Y.
Is there a generic way to find the location where headers are installed in
a python install? pip.locations has a distutils_scheme function which seems
to be returning the right thing, but it seems to be a bit overkill to
require pip. On the other side, no path returned by sysconfig corresponds
to `/usr/local/include/pythonX.Y`.
*3) On allowing `install_headers` command to follow a specific directory
structure*
(http://bugs.python.org/issue27123)
(instead of making a flat copy of the specified list of headers)
Unlike wheel's data files, which can be specified as a list of tuples
including the target directories
[(target_directory, [list of files for target directory])]
the `headers` setup keyword argument only let's you specify a list of files
that will be copied over to a sub-directory of
sysconfig.get_path('include').
It would be useful to enable the same feature for headers as we have for
data files.
If this is a feature that you would also like to see, I can propose a patch
to the install_headers command.
Thanks,
Syllvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20160525/ee156242/attachment.html>
More information about the Distutils-SIG
mailing list