Re: [Distutils] Distutils improvements regarding header installation and building C extension modules

On Wed, May 25, 2016 at 1:24 PM Sylvain Corlay <sylvain.corlay@gmail.com> wrote:
*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`.
As a Homebrew maintainer this sounds like something that Homebrew could influence. Are there any packages in the wild that use this mechanism? It seems that headers are mostly installed beneath site-packages. I don't have strong feelings about whether Homebrew should have better support for install_headers or whether that would be straightforward to implement but IIRC we've had no prior reports of this causing trouble. Thanks, Tim

On Wed, May 25, 2016 at 8:35 PM, Tim Smith <tim@tim-smith.us> wrote:
As a Homebrew maintainer this sounds like something that Homebrew could influence. Are there any packages in the wild that use this mechanism? It seems that headers are mostly installed beneath site-packages. I don't have strong feelings about whether Homebrew should have better support for install_headers or whether that would be straightforward to implement but IIRC we've had no prior reports of this causing trouble.
Thanks, Tim
Thanks Tim, The OS X python install is the only one I know of where headers installed with the install_headers command are not placed in a subdirectory of `sys.config('include')`. Besides, `pip.locations.distutils_scheme` returns the right include directory even in the case of homebrew. My point here was that this pip.locations function should probably be a feature of distutils itself. Although I would probably not have discovered the need for it if homebrew was placing extra headers in the same place as everyone else ! I don't think that using the package_data to place headers under site-package is the right thing to do in general. Then you need to rely on some python function to return the include directory... Sylvain

Hi all, I am following up on this: - Is there any chance to get the has_flag and has_functions patches in? - Would there be any interest in a patch adding the *pip.locations.distutils_scheme *functionality to distutils? - Same question for the install_headers command item mentioned earlier. Thanks, Sylvain On Wed, May 25, 2016 at 3:07 PM, Sylvain Corlay <sylvain.corlay@gmail.com> wrote:
On Wed, May 25, 2016 at 8:35 PM, Tim Smith <tim@tim-smith.us> wrote:
As a Homebrew maintainer this sounds like something that Homebrew could influence. Are there any packages in the wild that use this mechanism? It seems that headers are mostly installed beneath site-packages. I don't have strong feelings about whether Homebrew should have better support for install_headers or whether that would be straightforward to implement but IIRC we've had no prior reports of this causing trouble.
Thanks, Tim
Thanks Tim,
The OS X python install is the only one I know of where headers installed with the install_headers command are not placed in a subdirectory of `sys.config('include')`. Besides, `pip.locations.distutils_scheme` returns the right include directory even in the case of homebrew.
My point here was that this pip.locations function should probably be a feature of distutils itself. Although I would probably not have discovered the need for it if homebrew was placing extra headers in the same place as everyone else !
I don't think that using the package_data to place headers under site-package is the right thing to do in general. Then you need to rely on some python function to return the include directory...
Sylvain
participants (2)
-
Sylvain Corlay
-
Tim Smith