diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c29581d2b1..4d80337c5ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -577,37 +577,11 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: rust-src - - name: Install python3 standalone debug build with nox - run: | - PBS_RELEASE="20241219" - PBS_PYTHON_VERSION="3.13.1" - PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst" - wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}" - tar -I zstd -xf "${PBS_ARCHIVE}" - ls -l $(pwd)/python/install/bin - ls -l $(pwd)/python/install/lib - echo PATH=$(pwd)/python/install/bin:$PATH >> $GITHUB_ENV - echo LD_LIBRARY_PATH=$(pwd)/python/install/lib:$LD_LIBRARY_PATH >> $GITHUB_ENV - echo PYTHONHOME=$(pwd)/python/install >> $GITHUB_ENV - echo PYO3_PYTHON=$(pwd)/python/install/bin/python3 >> $GITHUB_ENV - - run: python3 -m sysconfig - - run: python3 -m pip install --upgrade pip && pip install nox[uv] - - run: | - PYO3_CONFIG_FILE=$(mktemp) - cat > $PYO3_CONFIG_FILE << EOF - implementation=CPython - version=3.13 - shared=true - abi3=false - lib_name=python3.13d - lib_dir=${{ github.workspace }}/python/install/lib - executable=${{ github.workspace }}/python/install/bin/python3 - pointer_width=64 - build_flags=Py_DEBUG,Py_REF_DEBUG - suppress_build_script_link_lines=false - EOF - echo PYO3_CONFIG_FILE=$PYO3_CONFIG_FILE >> $GITHUB_ENV - - run: python3 -m nox -s test + - uses: astral-sh/setup-uv@v6 + with: + python-version: "3.13+debug" + - run: uvx python -m sysconfig + - run: uvx nox -s test test-version-limits: needs: [fmt] diff --git a/build.rs b/build.rs index 25e3f54e331..a7dd8f87988 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,7 @@ use std::env; use pyo3_build_config::pyo3_build_script_impl::{cargo_env_var, errors::Result}; use pyo3_build_config::{ - add_python_framework_link_args, bail, print_feature_cfgs, InterpreterConfig, + add_libpython_rpath_link_args, bail, print_feature_cfgs, InterpreterConfig, }; fn ensure_auto_initialize_ok(interpreter_config: &InterpreterConfig) -> Result<()> { @@ -44,7 +44,7 @@ fn configure_pyo3() -> Result<()> { print_feature_cfgs(); // Make `cargo test` etc work on macOS with Xcode bundled Python - add_python_framework_link_args(); + add_libpython_rpath_link_args(); Ok(()) } diff --git a/pyo3-build-config/src/lib.rs b/pyo3-build-config/src/lib.rs index 156ecd309f6..91223eb8183 100644 --- a/pyo3-build-config/src/lib.rs +++ b/pyo3-build-config/src/lib.rs @@ -23,6 +23,8 @@ pub use impl_::{ CrossCompileConfig, InterpreterConfig, PythonImplementation, PythonVersion, Triple, }; +#[cfg(feature = "resolve-config")] +use target_lexicon::Architecture; use target_lexicon::OperatingSystem; /// Adds all the [`#[cfg]` flags](index.html) to the current compilation. @@ -92,9 +94,17 @@ fn _add_extension_module_link_args(triple: &Triple, mut writer: impl std::io::Wr #[cfg(feature = "resolve-config")] pub fn add_libpython_rpath_link_args() { let target = impl_::target_triple_from_env(); + let is_linking_libpython = impl_::is_linking_libpython_for_target(&target); + let is_wasm = matches!( + target.architecture, + Architecture::Wasm32 | Architecture::Wasm64 + ); + let is_emscripten = target.operating_system == target_lexicon::OperatingSystem::Emscripten; _add_libpython_rpath_link_args( get(), - impl_::is_linking_libpython_for_target(&target), + // webassembly targets generally don't support rpath, emscripten is the only exception currently aware of: + // https://github.com/emscripten-core/emscripten/issues/22126 + is_linking_libpython && (!is_wasm || is_emscripten), std::io::stdout(), ) } @@ -102,10 +112,10 @@ pub fn add_libpython_rpath_link_args() { #[cfg(feature = "resolve-config")] fn _add_libpython_rpath_link_args( interpreter_config: &InterpreterConfig, - is_linking_libpython: bool, + should_emit_rpath: bool, mut writer: impl std::io::Write, ) { - if is_linking_libpython { + if should_emit_rpath { if let Some(lib_dir) = interpreter_config.lib_dir.as_ref() { writeln!(writer, "cargo:rustc-link-arg=-Wl,-rpath,{lib_dir}").unwrap(); }