Skip to content
Open
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
19 changes: 19 additions & 0 deletions .scripts/run_osx_build.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions recipe/build_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,16 @@ if [[ ${_OPTIMIZED} == yes ]]; then
_FLAGS_REPLACE+=("")
done
fi
# Install the shared library (for people who embed Python only, e.g. GDB).
# Linking module extensions to this on Linux is redundant (but harmless).
# Linking module extensions to this on Darwin is harmful (multiply defined symbols).
shopt -s extglob
cp -pf ${_buildd_shared}/libpython*${SHLIB_EXT}!(.lto) ${PREFIX}/lib/
shopt -u extglob
if [[ ${target_platform} =~ .*linux.* ]]; then
ln -sf ${PREFIX}/lib/libpython${VERABI}${SHLIB_EXT}.1.0 ${PREFIX}/lib/libpython${VERABI}${SHLIB_EXT}
fi

SYSCONFIG=$(find ${_buildd_static}/$(cat ${_buildd_static}/pybuilddir.txt) -name "_sysconfigdata*.py" -print0)
# Use sysconfigdata and build-details.json from the shared build, as we want packages to prefer
# linking against the shared library. Issue #565.
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_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 \
Expand Down Expand Up @@ -515,7 +511,6 @@ 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}/lib/libpython${VERABI}${SHLIB_EXT} ${PREFIX}/lib/libpython${VERABI_NO_DBG}${SHLIB_EXT}
ln -s ${PREFIX}/include/python${VERABI} ${PREFIX}/include/python${VER}
fi

Expand Down
Empty file added recipe/build_shared.bat
Empty file.
33 changes: 33 additions & 0 deletions recipe/build_shared.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -ex

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

VER=${PKG_VERSION%.*}
ABIFLAGS=${DBG}${THREAD}
VERABI=${VER}${THREAD}${DBG}
VERABI_NO_DBG=${VER}${THREAD}

# Install the shared library (for people who embed Python only, e.g. GDB).
# Linking module extensions to this on Linux is redundant (but harmless).
# Linking module extensions to this on Darwin is harmful (multiply defined symbols).
shopt -s extglob
cp -pf ${_buildd_shared}/libpython*${SHLIB_EXT}!(.lto) ${PREFIX}/lib/
shopt -u extglob
if [[ ${target_platform} =~ .*linux.* ]]; then
ln -sf ${PREFIX}/lib/libpython${VERABI}${SHLIB_EXT}.1.0 ${PREFIX}/lib/libpython${VERABI}${SHLIB_EXT}
fi
if [[ ${PY_INTERP_DEBUG} == yes ]]; then
ln -s ${PREFIX}/lib/libpython${VERABI}${SHLIB_EXT} ${PREFIX}/lib/libpython${VERABI_NO_DBG}${SHLIB_EXT}
fi
90 changes: 76 additions & 14 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set ver2 = '.'.join(version.split('.')[0:2]) %}
{% set ver2nd = ''.join(version.split('.')[0:2]) %}
{% set ver3nd = ''.join(version.split('.')[0:3]) %}
{% set build_number = 0 %}
{% set build_number = 1 %}

# this makes the linter happy
{% set channel_targets = channel_targets or 'conda-forge main' %}
Expand Down Expand Up @@ -221,7 +221,6 @@ outputs:
files:
- tests/cmake/*
- tests/cython/*
- tests/prefix-replacement/*
- run_test.py
commands:
- echo on # [win]
Expand All @@ -247,8 +246,11 @@ outputs:
- _CONDA_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_linux_gnu python -c "import sysconfig; print(sysconfig.get_config_var('CC'))" # [linux64]
# check for unreplaced @ symbols in sysconfig files, excluding e.g. '"$@".lto'
- for f in ${CONDA_PREFIX}/lib/python*/_sysconfig*.py; do echo "Checking $f:"; if [[ `rg @[^@]*@ $f` ]]; then echo "FAILED ON $f"; cat $f; exit 1; fi; done # [linux64 or osx]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.a # [unix]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.nolto.a # [unix]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.so # [unix]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.a # [unix]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.so # [linux]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.dylib # [osx]
- test ! -f ${PREFIX}/lib/libpython${PKG_VERSION%.*}.nolto.a # [unix]
{% if freethreading == "yes" %}
- if not exist %PREFIX%\\libs\\python3t.lib exit 1 # [win]
- if not exist %PREFIX%\\libs\\python{{ ver2nd }}t.lib exit 1 # [win]
Expand All @@ -265,14 +267,8 @@ outputs:
- if not exist %PREFIX%\\Scripts\\pydoc.exe exit 1 # [win]
- if not exist %PREFIX%\\include\\pyconfig.h exit 1 # [win]
- pushd tests
- pushd prefix-replacement # [unix]
- bash build-and-test.sh # [unix]
- popd # [unix]
- pushd cmake
{% if freethreading == "no" %}
# TODO: use the new FindPython3 which supports freethreading
- cmake -GNinja -DPY_VER={{ version }} --debug-find --trace --debug-output --debug-trycompile .
{% endif %}
- cmake -GNinja -DPY_VER={{ version }} -DEXTRA_COMPONENTS="Development.Module" --debug-find --trace --debug-output --debug-trycompile .
- popd
- popd
- python run_test.py
Expand All @@ -283,6 +279,61 @@ outputs:
# Test for wide character supported via ncursesw
- TERM=xterm >/dev/null python -c "import curses; scr = curses.initscr(); curses.unget_wch('x'); assert 'x' == scr.get_wch()" # [unix]

- name: libpython
script: build_shared.sh # [unix]
script: build_shared.bat # [win]
build:
number: {{ build_number }}
activate_in_script: true
ignore_run_exports:
- python_abi
script_env:
- PY_INTERP_DEBUG={{ py_interp_debug }}
- PY_FREETHREADING={{ freethreading }}
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ debug }}_{{ abi_tag }}
requirements:
build:
- {{ compiler('c') }}
- {{ stdlib('c') }}
- {{ compiler('cxx') }}
host:
- {{ pin_subpackage('python', exact=True) }}
run:
- {{ pin_subpackage('python', exact=True) }}
test:
files:
- tests/cmake/*
- tests/prefix-replacement/*
requires:
- {{ stdlib('c') }}
- {{ compiler('c') }}
# cmake expects a C++ compiler for some reason
- {{ compiler('cxx') }}
- ripgrep
- cmake
- ninja
commands:
- VER=${PKG_VERSION%.*} # [not win]
- VERABI=${VER} # [not win]
{% if freethreading == "yes" %}
- VERABI=${VERABI}t # [not win]
{% endif %}
- VERABI_NO_DBG=${VERABI} # [not win]
{% if py_interp_debug == "yes" %}
- VERABI=${VERABI}d # [not win]
{% endif %}
- test -f ${PREFIX}/lib/libpython${VERABI}.so # [linux]
- test -f ${PREFIX}/lib/libpython3.so # [linux and build_type == "release"]
- test -f ${PREFIX}/lib/libpython${VERABI}.dylib # [osx]
- pushd tests
- pushd prefix-replacement # [unix]
- bash build-and-test.sh # [unix]
- popd # [unix]
- pushd cmake
- cmake -GNinja -DPY_VER={{ version }} -DEXTRA_COMPONENTS="Development.Embed" --debug-find --trace --debug-output --debug-trycompile .
- popd
- popd

- name: libpython-static
script: build_static.sh # [unix]
script: build_static.bat # [win]
Expand All @@ -306,10 +357,16 @@ outputs:
- {{ pin_subpackage('python', exact=True) }}
test:
files:
- tests/cmake/*
- tests/prefix-replacement/*
requires:
- {{ stdlib('c') }}
- {{ compiler('c') }}
# cmake expects a C++ compiler for some reason
- {{ compiler('cxx') }}
- ripgrep

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover from debugging?

Copy link
Author

@mgorny mgorny Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's actually used in tests. However, it was listed only for python output and was missing for libpython-static.

- cmake
- ninja
commands:
- VER=${PKG_VERSION%.*} # [not win]
- VERABI=${VER} # [not win]
Expand All @@ -323,9 +380,14 @@ outputs:
- test -f ${PREFIX}/lib/libpython${VERABI}.a # [unix]
- test -f ${PREFIX}/lib/libpython${VERABI_NO_DBG}.nolto.a # [unix]
- test -f ${PREFIX}/lib/python${VERABI_NO_DBG}/config-${VERABI}-darwin/libpython${VERABI}.a # [osx]
- pushd tests/prefix-replacement # [unix]
- bash build-and-test.sh # [unix]
- popd # [unix]
- pushd tests
- pushd prefix-replacement # [unix]
- bash build-and-test.sh # [unix]
- popd # [unix]
- pushd cmake
- cmake -GNinja -DPY_VER={{ version }} -DEXTRA_COMPONENTS="Development.Embed" --debug-find --trace --debug-output --debug-trycompile .
- popd
- popd

- name: cpython
build:
Expand Down
14 changes: 4 additions & 10 deletions recipe/tests/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# https://martinopilia.com/posts/2018/09/15/building-python-extension.html
# FindPythonInterp and FindPythonLibs are deprecated since cmake 3.12
# These can be replaced by find_package(Python ${PY_VER} REQUIRED)
# But these are still used by other packages, so we keep them.
# https://scikit-build-core.readthedocs.io/en/latest/guide/cmakelists.html#finding-python

cmake_minimum_required(VERSION 3.10)
enable_language(C)
project(mymath)

option(PY_VER, "Python version to use")
option(PY_VER "Python version to use")
option(EXTRA_COMPONENTS "Additional Python components to check for")

find_package(PythonInterp ${PY_VER} REQUIRED)
# PATHS $ENV{CONDA_PREFIX}

# This goes after, since it uses PythonInterp as hint
find_package(PythonLibs ${PY_VER} REQUIRED)
find_package(Python ${PY_VER} COMPONENTS Interpreter ${EXTRA_COMPONENTS} REQUIRED)
Loading