<div dir="ltr">Hello everyone,<div><br></div><div>This is my first post here so, apologies if I am breaking any rules.</div><div><br></div><div>Lately, I have been filing a few bug reports and patches to distutils on <a href="http://bugs.python.org">bugs.python.org</a> that all concern the installation and build of C++ extensions.</div><div><br></div><div><b>1) The distutils.ccompiler <font face="monospace, monospace">has_flag </font>method.</b></div><div>(<a href="http://bugs.python.org/issue26689">http://bugs.python.org/issue26689</a>)<br></div><div><br></div><div>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.</div><div><br></div><div>I proposed a patch adding a `has_flag` method to ccompiler. It is an equivalent to cmake' s <span style="color:rgb(0,0,0);font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap">CHECK_CXX_COMPILER_FLAG. </span></div><div><span style="color:rgb(0,0,0);font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><br></span></div><div><font color="#000000"><span style="font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap">The implementation is similar to the one of <font face="monospace, monospace">has_function</font><font face="arial, helvetica, sans-serif"> which by the way has a pending patch by minrk in issue (</font></span></font><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><a href="http://bugs.python.org/issue25544">http://bugs.python.org/issue25544</a>).</span></font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><b><font face="arial, helvetica, sans-serif">2) On the need for something like </font><font face="monospace, monospace">pip.locations.distutils_scheme</font><font face="arial, helvetica, sans-serif"> in  distutils</font></b></span></font></div>(<a href="http://bugs.python.org/issue26955">http://bugs.python.org/issue26955</a>)<div><br></div>When installing a python package that has a directive for the <font face="monospace, monospace">install_headers </font>distutils command, these headers are usually installed under the main python include directory, which can be retrieved with <font face="monospace, monospace">sysconfig.get_path('include')</font> or directly referred to as the <font face="monospace, monospace">'include'</font> string when setting the include directories of an extension module. <div><br></div><div>However, on some systems like OS X, headers for extension modules are not located in under the python include directory </div><div><br></div><div><font face="monospace, monospace">/usr/local/Cellar/pythonX/X.Y.Z/Frameworks/Python.framework/Versions/X.Y/include/pythonX.Y</font></div><div><br></div><div>but in </div><div><br></div><div><font face="monospace, monospace">/usr/local/include/pythonX.Y</font>.</div><div><br></div><div>Is there a generic way to find the location where headers are installed in a python install? <font face="monospace, monospace">pip.locations</font> has a <font face="monospace, monospace">distutils_scheme</font> 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`.</div><div><br></div><div><b>3) On allowing `install_headers` command to follow a specific directory structure</b></div><div><div><div><span style="color:rgb(0,0,0);font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap">(</span><font color="#000000"><span style="font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><a href="http://bugs.python.org/issue27123">http://bugs.python.org/issue27123</a></span></font><span style="color:rgb(0,0,0);font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap">)</span></div><div><span style="color:rgb(0,0,0);font-size:11.8953px;line-height:17.8231px;white-space:pre-wrap"><br></span></div>(instead of making a flat copy of the specified list of headers)<br><br>Unlike wheel's data files, which can be specified as a list of tuples including the target directories<br><br><font face="monospace, monospace">[(target_directory, [list of files for target directory])]</font><br><br>the `headers` setup keyword argument only let's you specify a list of files that will be copied over to a sub-directory of <font face="monospace, monospace">sysconfig.get_path('include').</font><br><br>It would be useful to enable the same feature for headers as we have for data files.</div><div><br></div><div>If this is a feature that you would also like to see, I can propose a patch to the install_headers command.<br><br>Thanks,</div></div><div><br></div><div>Syllvain</div></div>