boostorg / python

Boost.org python module
http://boostorg.github.io/python
Boost Software License 1.0
468 stars 201 forks source link

Boost.NumPy doesn't build when more than one Python version is configured in user-config #361

Closed pdimov closed 3 years ago

pdimov commented 3 years ago

When user-config.jam has more than one version of Python configured, e.g.

using python : 2.7 : C:/Python27 ;
using python : 3.9 : C:/Python39 ;

trying to build Python (with e.g. b2 --with-python python=2.7) fails, because Boost.NumPy is built against the (correct) 2.7 version of Python, but against the 3.9 headers of NumPy:

cl /Zm800 -nologo "libs\python\src\numpy\ufunc.cpp" -Fo"bin.v2\libs\python\build\msvc-14.2\debug\address-model-32\link-static\python-2.7\threading-multi\numpy\ufunc.obj"    -TP /wd4675 /EHs /GR /Zc:throwingNew /Z7 /Od /Ob0 /W3 /MDd /Zc:forScope /Zc:wchar_t /Zc:inline -c -DBOOST_ALL_NO_LIB=1 -DBOOST_NUMPY_SOURCE -DBOOST_NUMPY_STATIC_LIB -DBOOST_PYTHON_STATIC_LIB "-I." "-IC:\Python27\Include" "-IC:\Python39\lib\site-packages\numpy\core\include"

The reason for that is that the Python configuration in b2's python.jam stores the NumPy include path in a variable .numpy-include, which can only hold one value.

https://github.com/boostorg/build/blob/916afd3876bc0d5b706a63f9d09ba66ff69e7d66/src/tools/python.jam#L1087-L1090 https://github.com/boostorg/build/blob/916afd3876bc0d5b706a63f9d09ba66ff69e7d66/src/tools/python.jam#L858

This can in principle be fixed by declaring a target for NumPy's include path, instead of a variable, and then linking to it instead of using <include>$(numpy-include) in build/Jamfile.

https://github.com/boostorg/python/blob/2a82afdf6d30c28eb1775f3b8041d988f6f04598/build/Jamfile#L120

pdimov commented 3 years ago

Boost.Build issue: https://github.com/boostorg/build/issues/725

SoapGentoo commented 3 years ago

The original Gentoo issue with a comment where the bug occurs: https://bugs.gentoo.org/733830#c12