Skip to content

Commit d09f605

Browse files
authored
fix: install into free-threaded python3.14t/site-packages prefixes (#911)
* fix: support free-threaded python3.14t/site-packages prefixes * fix: append sys.abiflags to e.g. python3.14 in env.sh
1 parent b5056e2 commit d09f605

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cmake/podioBuild.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,27 @@ endif()
214214
# Setup the python install dir. See the discussion in
215215
# https://github.com/AIDASoft/podio/pull/599 for more details on why this is
216216
# done the way it is
217+
#
218+
# For Python 3.13+ with free-threading (PEP 703), the site-packages directory
219+
# includes a 't' suffix (e.g., python3.14t/site-packages). We use Python's
220+
# own SITEARCH to get the correct path including any ABI suffixes.
221+
#
217222
set(podio_python_lib_dir lib)
218223
if("${Python3_SITEARCH}" MATCHES "/lib64/")
219224
set(podio_python_lib_dir lib64)
220225
endif()
221226

227+
# Extract the python-specific part of the path (e.g., python3.14t/site-packages)
228+
# from Python3_SITEARCH
229+
string(REGEX MATCH "python[0-9]+\\.[0-9]+[a-z]*/site-packages" _python_site_subdir "${Python3_SITEARCH}")
230+
if(NOT _python_site_subdir)
231+
# Fallback to manual construction if regex fails
232+
set(_python_site_subdir "python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
233+
message(WARNING "Could not extract site-packages path from Python3_SITEARCH (${Python3_SITEARCH}), using fallback: ${_python_site_subdir}")
234+
endif()
235+
222236
set(podio_PYTHON_INSTALLDIR
223-
"${CMAKE_INSTALL_PREFIX}/${podio_python_lib_dir}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
237+
"${CMAKE_INSTALL_PREFIX}/${podio_python_lib_dir}/${_python_site_subdir}"
224238
CACHE STRING
225239
"The install prefix for the python bindings and the generator and templates"
226240
)

env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ elif [[ "$unamestr" = 'Darwin' ]]; then
2525
fi
2626
fi
2727

28-
python_stem=python3.$(python -c 'import sys; print(sys.version_info[1])')/site-packages
28+
python_stem=python3.$(python -c 'import sys; print(str(sys.version_info[1]) + sys.abiflags )')/site-packages
2929
if [ -d $PODIO/lib64/${python_stem} ]; then
3030
if ! echo $PYTHONPATH | grep -o $PODIO/lib64/${python_stem} > /dev/null 2>&1; then
3131
export PYTHONPATH=$PODIO/lib64/${python_stem}:$PYTHONPATH

0 commit comments

Comments
 (0)