Skip to content

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

@pdimov

Description

@pdimov

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.

<include>$(numpy-include)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions