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.

16 changes: 8 additions & 8 deletions README.md

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

7 changes: 6 additions & 1 deletion recipe/build_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,15 @@ 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
3 changes: 2 additions & 1 deletion 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 @@ -307,6 +307,7 @@ outputs:
requires:
- {{ stdlib('c') }}
- {{ compiler('c') }}
- 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.

commands:
- VER=${PKG_VERSION%.*} # [not win]
- VERABI=${VER} # [not win]
Expand Down
47 changes: 21 additions & 26 deletions recipe/tests/prefix-replacement/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@

set -ex

if [[ "$PKG_NAME" == "libpython-static" ]]; then
# see bpo44182 for why -L${CONDA_PREFIX}/lib is added
${CC} a.c $(python3-config --cflags) $(python3-config --embed --ldflags) -L${CONDA_PREFIX}/lib -o ${CONDA_PREFIX}/bin/embedded-python-static
if [[ "$target_platform" == linux-* ]]; then
if ${READELF} -d ${CONDA_PREFIX}/bin/embedded-python-static | rg libpython; then
echo "ERROR :: Embedded python linked to shared python library. It is expected to link to the static library."
fi
elif [[ "$target_platform" == osx-* ]]; then
if ${OTOOL} -l ${CONDA_PREFIX}/bin/embedded-python-static | rg libpython; then
echo "ERROR :: Embedded python linked to shared python library. It is expected to link to the static library."
fi
fi
${CONDA_PREFIX}/bin/embedded-python-static

# I thought this would prefer the shared library for Python. I was wrong:
# EMBED_LDFLAGS=$(python3-config --ldflags)
# re='^(.*)(-lpython[^ ]*)(.*)$'
# if [[ ${EMBED_LDFLAGS} =~ $re ]]; then
# EMBED_LDFLAGS="${BASH_REMATCH[1]} ${BASH_REMATCH[3]} -Wl,-Bdynamic ${BASH_REMATCH[2]}"
# fi
# ${CC} a.c $(python3-config --cflags) ${EMBED_LDFLAGS} -o ${CONDA_PREFIX}/bin/embedded-python-shared

# Brute-force way of linking to the shared library, sorry!
rm -rf ${CONDA_PREFIX}/lib/libpython*.a
fi

# see bpo44182 for why -L${CONDA_PREFIX}/lib is added
${CC} a.c $(python3-config --cflags) \
$(python3-config --embed --ldflags) \
-L${CONDA_PREFIX}/lib -Wl,-rpath,${CONDA_PREFIX}/lib \
Expand All @@ -44,4 +19,24 @@ elif [[ "$target_platform" == osx-* ]]; then
fi
${CONDA_PREFIX}/bin/embedded-python-shared

if [[ "$PKG_NAME" == "libpython-static" ]]; then
# remove the shared library to force static linking
rm -f ${CONDA_PREFIX}/lib/libpython*.{so,dylib}

${CC} a.c $(python3-config --cflags) \
$(python3-config --embed --ldflags) \
-L${CONDA_PREFIX}/lib -Wl,-rpath,${CONDA_PREFIX}/lib \
-o ${CONDA_PREFIX}/bin/embedded-python-static
if [[ "$target_platform" == linux-* ]]; then
if ${READELF} -d ${CONDA_PREFIX}/bin/embedded-python-static | rg libpython; then
echo "ERROR :: Embedded python linked to shared python library. It is expected to link to the static library."
fi
elif [[ "$target_platform" == osx-* ]]; then
if ${OTOOL} -l ${CONDA_PREFIX}/bin/embedded-python-static | rg libpython; then
echo "ERROR :: Embedded python linked to shared python library. It is expected to link to the static library."
fi
fi
${CONDA_PREFIX}/bin/embedded-python-static
fi

set +x