Skip to content
Draft
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
36 changes: 5 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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(())
}
Expand Down
16 changes: 13 additions & 3 deletions pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -92,20 +94,28 @@ 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(),
)
}

#[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();
}
Expand Down
Loading