Repository navigation
compile with python 3.13t (nogil) #458
Copy link
Copy link
Open
Description
I have installed free-threading python 3.13 following https://py-free-threading.github.io/installing_cpython/ on ubuntu 22.04(with gcc 11.04.0), with command:
conda create -n nogil --override-channels -c conda-forge python-freethreading
But compile python 3.13t with boost-1.86.0 failed, below the steps:
1, configure boost successfully:
./bootstrap.sh --with-python=/home/mydesktop/anaconda3/envs/nogil
2, compile boost failed:
./b2 --toolset=gcc --with-python include="/home/mydesktop/anaconda3/envs/nogil/include/python3.13t/" --with-thread --with-date_time --with-chrono --with-system
3, error message:
`gcc.compile.c++ bin.v2/libs/python/build/gcc-11/release/x86_64/link-static/python-3.13/threading-multi/visibility-hidden/dict.o
In file included from ./boost/python/detail/prefix.hpp:13,
from ./boost/python/dict.hpp:8,
from libs/python/src/dict.cpp:4:
./boost/python/detail/wrap_python.hpp:57:11: fatal error: pyconfig.h: No such file or directory
57 | # include <pyconfig.h>
| ^~~~~~~~~~~~
compilation terminated.
"g++" -fvisibility-inlines-hidden -m64 -pthread -O3 -finline-functions -Wno-inline -Wall -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_COBALT_USE_STD_PMR=1 -DBOOST_PYTHON_SOURCE -DBOOST_PYTHON_STATIC_LIB -DNDEBUG -I"." -I"/home/subaochen/anaconda3/envs/nogil/include/python3.13" -I"/home/subaochen/anaconda3/envs/nogil/include/python3.1t" -c -o "bin.v2/libs/python/build/gcc-11/release/x86_64/link-static/python-3.13/threading-multi/visibility-hidden/dict.o" "libs/python/src/dict.cpp"
...failed gcc.compile.c++ bin.v2/libs/python/build/gcc-11/release/x86_64/link-static/python-3.13/threading-multi/visibility-hidden/dict.o...
gcc.compile.c++ bin.v2/libs/python/build/gcc-11/release/x86_64/link-static/python-3.13/threading-multi/visibility-hidden/str.o
In file included from ./boost/python/detail/prefix.hpp:13,
from ./boost/python/str.hpp:8,
from libs/python/src/str.cpp:4:
./boost/python/detail/wrap_python.hpp:57:11: fatal error: pyconfig.h: No such file or directory
57 | # include <pyconfig.h>
| ^~~~~~~~~~~~
compilation terminated.
Obviously I missed "pyconfig.h", but i successfully compiled boost 1.86 with python 3.11 with the same step. Any suggestions? Thanks in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
stefanseefeld commentedon Dec 2, 2024
@grafikrobot , do you know what's wrong here ? My b2 knowledge is next to non-existent.
grafikrobot commentedon Dec 7, 2024
@stefanseefeld hmm.. something strange is going on with the include paths for python:
It would help if we got the output of running the build with the
--debug-configurationoption.rgommers commentedon Apr 16, 2025
I can reproduce this build error if I leave out the
include="/path/to/include/python3.13t/"part, if I add it things do work. Full reproducer:Change the build command to add an explicit include path:
The generated
project-config.jamfile does set the path to the root dir for the Python executable, but no related include path:Details
Knowing where that include path is set would be helpful I guess (I'm not familiar with
b2either) - or is it expected that one has to manually add it if thepythonexecutable isn't the system one?Output up the the first build failure
I checked that my CMake is recent enough; it's at 3.31.6 while 3.30.0 is the minimum version needed for free-threaded CPython support (such versions are tracked here, I'll add Boost.Python to that table as well).
In the end this looks like all it needs is appending a single
tto the include path that the build system calculates based on the Python minor version.rgommers commentedon Apr 16, 2025
Okay, found it I think:
https://github.com/bfgroup/b2/blob/f518c83dbbcce621df81ab29e7b2a33498a35ca2/src/tools/python.jam#L563
versionis still3.13for a free-threaded interpreter, so what is needed is to detect that a free-threaded interpreter is being run and if so, appendt. The solution will be similar to mesonbuild/meson#13338 I think: run the interpreter, and check for thissysconfigvariable:rgommers commentedon Feb 9, 2026
This is all fixed after gh-504, the issue can be closed.
mbechard commentedon Feb 25, 2026
This doesn't seem quite fixed yet, at least on Windows. I can build boost while pointing it to python3.14t.exe without errors. However the boost_python314-vc143-mt-x64-1_90.dll is still linked against python314.dll, not python314t.dll. So the link arguments need to be updated to point to the correct .lib depending on what the python executable returns.