Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anaconda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ upstream_sources:
from_pattern: ^v(\d+\.\d+\.\d+)$
to_pattern: \1
packages:
- python
- libpython
- libpython-static
- python
- python-freethreading
- python-gil
- python-jit
Expand Down
6 changes: 4 additions & 2 deletions recipe/build_base.bat
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if "%DEBUG_C%"=="yes" (
:: AP doesn't support PGO atm?
set PGO=

if "%PY_GIL_DISABLED%" == "yes" (
if "%PY_FREETHREADING%" == "yes" (
set "FREETHREADING=--disable-gil"
set "THREAD=t"
set "EXE_T=%VER%t"
Expand Down Expand Up @@ -84,7 +84,7 @@ if errorlevel 1 exit 1
cd ..

:: Populate the root package directory
for %%x in (python%VERNODOTS%%THREAD%%_D%.dll python3%THREAD%%_D%.dll python%EXE_T%%_D%.exe pythonw%EXE_T%%_D%.exe) do (
for %%x in (python%VERNODOTS%%THREAD%%_D%.dll python3%THREAD%%_D%.dll python3t%_D%.dll python%EXE_T%%_D%.exe pythonw%EXE_T%%_D%.exe) do (
if exist %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x (
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%
) else (
Expand Down Expand Up @@ -158,6 +158,8 @@ for %%x in (lib libs) do (
if errorlevel 1 exit 1
if exist %SRC_DIR%\PCbuild\%BUILD_PATH%\python3%THREAD%%_D%.lib copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\python3%THREAD%%_D%.lib %PREFIX%\%%x\
if errorlevel 1 exit 1
if exist %SRC_DIR%\PCbuild\%BUILD_PATH%\python3t%_D%.lib copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\python3t%_D%.lib %PREFIX%\%%x\
if errorlevel 1 exit 1
if exist %SRC_DIR%\PCbuild\%BUILD_PATH%\_tkinter%_D%.lib copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\_tkinter%_D%.lib %PREFIX%\%%x\
if errorlevel 1 exit 1
)
Expand Down
73 changes: 38 additions & 35 deletions recipe/build_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,33 @@ _buildd_shared=build-shared
_ENABLE_SHARED=--enable-shared
# We *still* build a shared lib here for non-static embedded use cases
_DISABLE_SHARED=--disable-shared
# Hack to allow easily comparing static vs shared interpreter performance
# .. hack because we just build it shared in both the build-static and
# build-shared directories.
# Yes this hack is a bit confusing, sorry about that.
if [[ ${PY_INTERP_LINKAGE_NATURE} == shared ]]; then
_DISABLE_SHARED=--enable-shared
_ENABLE_SHARED=--enable-shared
fi

# For debugging builds, set this to no to disable profile-guided optimization
if [[ ${DEBUG_C} == yes ]]; then
if [[ ${PY_INTERP_DEBUG} == yes || ${DEBUG_C} == yes ]]; then
_OPTIMIZED=no
else
_OPTIMIZED=yes
fi

declare -a _dbg_opts
if [[ ${DEBUG_PY} == yes ]]; then
if [[ ${PY_INTERP_DEBUG} == yes ]]; then
# This Python will not be usable with non-debug Python modules.
_dbg_opts+=(--with-pydebug)
DBG=d
else
DBG=
fi

if [[ ${PY_GIL_DISABLED} == yes ]]; then
if [[ ${PY_FREETHREADING} == yes ]]; then
# This Python will not be usable with non-free threading Python modules.
THREAD=t
else
THREAD=
fi

ABIFLAGS=${DBG}
ABIFLAGS=${DBG}${THREAD}
VERABI=${VER}${THREAD}${DBG}
VERABI_NO_DBG=${VER}${THREAD}

# Make sure the "python" value in conda_build_config.yaml is up to date.
test "${PY_VER}" = "${VER}"
Expand Down Expand Up @@ -107,6 +100,12 @@ if [[ ${_OPTIMIZED} = yes ]]; then
CXXFLAGS=$(echo "${CXXFLAGS}" | sed "s/-O2/-O3/g")
fi

if [[ ${PY_INTERP_DEBUG} == yes ]]; then
CPPFLAGS=$(echo "${CPPFLAGS}" | sed "s/-O2/-O0/g")
CFLAGS=$(echo "${CFLAGS}" | sed "s/-O2/-O0/g")
CXXFLAGS=$(echo "${CXXFLAGS}" | sed "s/-O2/-O0/g")
fi

if [[ "$target_platform" == linux-* ]]; then
cp ${PREFIX}/include/uuid/uuid.h ${PREFIX}/include/uuid.h
fi
Expand Down Expand Up @@ -253,14 +252,10 @@ _common_configure_args+=(--with-tzpath=${PREFIX}/share/zoneinfo)
_common_configure_args+=(--with-computed-gotos)
_common_configure_args+=(--with-system-expat)
_common_configure_args+=(--enable-loadable-sqlite-extensions)
# TODO: Remove this comment in PR#256
# Dropped dead tcltk configure flags — log-confirmed unused in 3.15.0rc2:
# configure: WARNING: unrecognized options: --with-tcltk-includes, --with-tcltk-libs
# _tkinter already comes from pkg-config.
_common_configure_args+=(--with-platlibdir=lib)
_common_configure_args+=(--with-system-libmpdec=yes)

if [[ "${DEBUG_PY}" == "yes" || "${target_platform}" != *"64" || ${PY_GIL_DISABLED} == yes ]]; then
if [[ "${PY_INTERP_DEBUG}" == "yes" || "${target_platform}" != *"64" || ${PY_FREETHREADING} == yes ]]; then
_common_configure_args+=(--enable-experimental-jit=no)
else
_common_configure_args+=(--enable-experimental-jit=yes-off)
Expand All @@ -271,7 +266,7 @@ if [[ "${target_platform}" == osx-* ]]; then
_common_configure_args+=(--with-tail-call-interp)
fi

if [[ ${PY_GIL_DISABLED} == yes ]]; then
if [[ ${PY_FREETHREADING} == yes ]]; then
_common_configure_args+=(--disable-gil)
fi

Expand Down Expand Up @@ -337,8 +332,8 @@ pushd ${_buildd_static}
popd

make -j${CPU_COUNT} -C ${_buildd_static} \
EXTRA_CFLAGS="${EXTRA_CFLAGS}" \
${_MAKE_TARGET} "${_PROFILE_TASK[@]}" 2>&1 | tee make-static.log
EXTRA_CFLAGS="${EXTRA_CFLAGS}" \
${_MAKE_TARGET} "${_PROFILE_TASK[@]}" 2>&1 | tee make-static.log
if rg "Failed to build these modules" make-static.log; then
echo "(static) :: Failed to build some modules, check the log"
exit 1
Expand Down Expand Up @@ -370,7 +365,7 @@ fi
# build a static library with PIC objects and without LTO/PGO
make -j${CPU_COUNT} -C ${_buildd_shared} \
EXTRA_CFLAGS="${EXTRA_CFLAGS}" \
LIBRARY=libpython${VERABI}-pic.a libpython${VERABI}-pic.a
LIBRARY=libpython${VERABI_NO_DBG}-pic.a libpython${VERABI_NO_DBG}-pic.a

make -C ${_buildd_static} install

Expand All @@ -389,13 +384,14 @@ if [[ ${_OPTIMIZED} == yes ]]; then
_FLAGS_REPLACE+=("")
done
fi
# Use sysconfigdata from the shared build, as we want packages to prefer
# linking against the shared library. Issue #565.
SYSCONFIG=$(find ${_buildd_shared}/$(cat ${_buildd_shared}/pybuilddir.txt) -name "_sysconfigdata*.py" -print0)
BUILD_DIR=$(< ${_buildd_shared}/pybuilddir.txt)
SYSCONFIG=$(find ${_buildd_shared}/${BUILD_DIR} -name "_sysconfigdata*.py" -print0)
cat ${SYSCONFIG} | ${SYS_PYTHON} "${RECIPE_DIR}"/replace-word-pairs.py \
"${_FLAGS_REPLACE[@]}" \
> ${PREFIX}/lib/python${VERABI}/$(basename ${SYSCONFIG})
MAKEFILE=$(find ${PREFIX}/lib/python${VERABI}/ -path "*config-*/Makefile" -print0)
> ${PREFIX}/lib/python${VERABI_NO_DBG}/$(basename ${SYSCONFIG})
BUILD_DETAILS=${_buildd_shared}/${BUILD_DIR}/build-details.json
cp ${BUILD_DETAILS} ${PREFIX}/lib/python${VERABI_NO_DBG}/
MAKEFILE=$(find ${PREFIX}/lib/python${VERABI_NO_DBG}/ -path "*config-*/Makefile" -print0)
cp ${MAKEFILE} /tmp/Makefile-$$
cat /tmp/Makefile-$$ | ${SYS_PYTHON} "${RECIPE_DIR}"/replace-word-pairs.py \
"${_FLAGS_REPLACE[@]}" \
Expand All @@ -417,7 +413,7 @@ ln -s ${PREFIX}/bin/pydoc${VER} ${PREFIX}/bin/pydoc
# Remove test data to save space
# Though keep `support` as some things use that.
# TODO :: Make a subpackage for this once we implement multi-level testing.
pushd ${PREFIX}/lib/python${VERABI}
pushd ${PREFIX}/lib/python${VERABI_NO_DBG}
mkdir test_keep
mv test/__init__.py test/support test/test_support* test/test_script_helper* test_keep/
rm -rf test */test
Expand All @@ -430,7 +426,7 @@ pushd ${PREFIX}
chmod +w lib/libpython${VERABI}.a
${STRIP} -S lib/libpython${VERABI}.a
fi
CONFIG_LIBPYTHON=$(find lib/python${VERABI}/config-${VERABI}* -name "libpython${VERABI}.a")
CONFIG_LIBPYTHON=$(find lib/python${VERABI_NO_DBG}/config-${VERABI}* -name "libpython${VERABI}.a")
if [[ -f lib/libpython${VERABI}.a ]] && [[ -f ${CONFIG_LIBPYTHON} ]]; then
chmod +w ${CONFIG_LIBPYTHON}
rm ${CONFIG_LIBPYTHON}
Expand All @@ -440,7 +436,7 @@ popd
# Copy sysconfig that gets recorded to a non-default name
# using the new compilers with python will require setting _PYTHON_SYSCONFIGDATA_NAME
# to the name of this file (minus the .py extension)
pushd "${PREFIX}"/lib/python${VERABI}
pushd "${PREFIX}"/lib/python${VERABI_NO_DBG}
# On Python 3.5 _sysconfigdata.py was getting copied in here and compiled for some reason.
# This breaks our attempt to find the right one as recorded_name.
find lib-dynload -name "_sysconfigdata*.py*" -exec rm {} \;
Expand Down Expand Up @@ -472,7 +468,7 @@ pushd "${PREFIX}"/lib/python${VERABI}
sed -i.bak "s@$HOST-@@g" sysconfigfile
if [[ "$target_platform" == linux* ]]; then
# For linux, make sure the system gcc uses our linker
sed -i.bak "s@-pthread@-pthread -B $PREFIX/compiler_compat@g" sysconfigfile
sed -i.bak "s@-pthread@-pthread -B $PREFIX/share/python_compiler_compat@g" sysconfigfile
fi
# Don't set -march and -mtune for system gcc
sed -i.bak "s@-march=[^( |\\\"|\\\')]*@@g" sysconfigfile
Expand All @@ -497,14 +493,21 @@ pushd "${PREFIX}"/lib/python${VERABI}
popd

if [[ ${HOST} =~ .*linux.* ]]; then
mkdir -p ${PREFIX}/compiler_compat
ln -s ${PREFIX}/bin/${HOST}-ld ${PREFIX}/compiler_compat/ld
echo "Files in this folder are to enhance backwards compatibility of anaconda software with older compilers." > ${PREFIX}/compiler_compat/README
echo "See: https://github.com/conda/conda/issues/6030 for more information." >> ${PREFIX}/compiler_compat/README
mkdir -p ${PREFIX}/share/python_compiler_compat
ln -s ${PREFIX}/bin/${HOST}-ld ${PREFIX}/share/python_compiler_compat/ld
echo "Files in this folder are to enhance backwards compatibility of anaconda software with older compilers." > ${PREFIX}/share/python_compiler_compat/README
echo "See: https://github.com/conda/conda/issues/6030 for more information." >> ${PREFIX}/share/python_compiler_compat/README
fi

python -c "import compileall,os;compileall.compile_dir(os.environ['PREFIX'])"
rm ${PREFIX}/lib/libpython${VERABI}.a

if [[ ${PY_INTERP_DEBUG} == yes ]]; then
rm ${PREFIX}/bin/python${VER}
ln -s ${PREFIX}/bin/python${VERABI} ${PREFIX}/bin/python${VER}
ln -s ${PREFIX}/include/python${VERABI} ${PREFIX}/include/python${VER}
fi

if [[ "$target_platform" == linux-* ]]; then
rm ${PREFIX}/include/uuid.h
fi
Expand All @@ -522,7 +525,7 @@ fi
# <prefix>/lib/python3.13t/site-packages.
# Note that these directories are not added to sys.path if they do not exist.
SP_DIR="${PREFIX}/lib/python${PY_VER}${THREAD}/site-packages"
if [[ ${PY_GIL_DISABLED} == yes ]]; then
if [[ ${PY_FREETHREADING} == yes ]]; then
echo "${PREFIX}/lib/python${PY_VER}/site-packages" >> $SP_DIR/conda-site.pth
fi
# Do not add ${PREFIX}/lib/python/site-packages (CF experimental ABI3/noarch
Expand Down
13 changes: 9 additions & 4 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ python_impl:
# Override aggregate global tk 8.6 — build/test against tk 9 from pkgs/main
tk:
- '9.0'
gil_type:
- normal
# Will be enabled as part of https://anaconda.atlassian.net/browse/PKG-5855
- disabled # [not (s390x or (osx and x86_64))]
# Whether to build free-threaded Python (3.13+)
freethreading:
- yes
- no

# Whether to build for release or with debug symbols
build_type:
- release
# - debug

# Override aggregate global clang 20 on osx. CPython 3.15 JIT requires LLVM 21
# (Tools/jit/_llvm.py); mixing compiler('c')=20 with clang-21/llvm-tools-21
Expand Down
12 changes: 11 additions & 1 deletion recipe/fix_staged_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def fix_staged_scripts(scripts_dir):
Fixes scripts which have been installed unix-style to have a .bat
helper
"""
target_arch = os.environ["target_platform"].split("-")[-1]
if not isdir(scripts_dir):
return
for fn in os.listdir(scripts_dir):
Expand All @@ -31,7 +32,16 @@ def fix_staged_scripts(scripts_dir):
# now create the .exe file
# This is hardcoded that conda and conda-build are in the same environment
base_env = dirname(dirname(os.environ['CONDA_EXE']))
exe = join(base_env, 'lib', 'site-packages', 'conda_build', 'cli-64.exe')
# conda-build >= 26.9 sources launchers from conda-launchers
candidates = [
join(base_env, 'share', 'conda-launchers', f'cli-{target_arch}.exe'),
join(base_env, 'lib', 'site-packages', 'conda_build', f'cli-{target_arch}.exe'),
]
exe = next((path for path in candidates if isfile(path)), None)
if exe is None:
raise FileNotFoundError(
'cli-64.exe launcher not found in any of: %s' % ', '.join(candidates)
)
shutil.copyfile(exe, join(scripts_dir, fn + '.exe'))

# remove the original script
Expand Down
6 changes: 3 additions & 3 deletions recipe/install_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ esac

cp -pf ${_buildd_static}/libpython${VERABI}.a ${PREFIX}/lib/libpython${VERABI}.a
if [[ ${HOST} =~ .*linux.* ]]; then
pushd ${PREFIX}/lib/python${VERABI}/config-${VERABI}-${OLD_HOST}
pushd ${PREFIX}/lib/python${VERABI_NO_DBG}/config-${VERABI}-${OLD_HOST}
elif [[ ${HOST} =~ .*darwin.* ]]; then
pushd ${PREFIX}/lib/python${VERABI}/config-${VERABI}-darwin
pushd ${PREFIX}/lib/python${VERABI_NO_DBG}/config-${VERABI}-darwin
fi
ln -s ../../libpython${VERABI}.a libpython${VERABI}.a
popd
# If the LTO info in the normal lib is problematic (using different compilers for example
# we also provide a 'nolto' version).
cp -pf ${_buildd_shared}/libpython${VERABI}-pic.a ${PREFIX}/lib/libpython${VERABI}.nolto.a
cp -pf ${_buildd_shared}/libpython${VERABI_NO_DBG}-pic.a ${PREFIX}/lib/libpython${VERABI_NO_DBG}.nolto.a
Loading