From f6e1f26676cf8785e7b0baeeb975a5d3fa27f493 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Mon, 5 Jun 2023 18:48:11 +0200 Subject: [PATCH] Enable v2 resolver on the workspace to enable dropping PYO3_CI workaround. --- .github/workflows/build.yml | 3 --- Cargo.toml | 1 + build.rs | 39 ++++++++++++++----------------------- noxfile.py | 1 - 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c30c434..24731221 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -198,6 +198,3 @@ jobs: RUST_BACKTRACE: 1 RUSTFLAGS: "-D warnings" RUSTDOCFLAGS: "-D warnings" - # TODO: this is a hack to workaround compile_error! warnings about auto-initialize on PyPy - # Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this. - PYO3_CI: 1 diff --git a/Cargo.toml b/Cargo.toml index 651d4157..48f61a1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,6 +188,7 @@ members = [ "examples", "xtask" ] +resolver = "2" [package.metadata.docs.rs] no-default-features = true diff --git a/build.rs b/build.rs index 207f122c..aff03653 100644 --- a/build.rs +++ b/build.rs @@ -4,30 +4,21 @@ use pyo3_build_config::pyo3_build_script_impl::{cargo_env_var, errors::Result}; use pyo3_build_config::{bail, print_feature_cfgs, InterpreterConfig}; fn ensure_auto_initialize_ok(interpreter_config: &InterpreterConfig) -> Result<()> { - if cargo_env_var("CARGO_FEATURE_AUTO_INITIALIZE").is_some() { - if !interpreter_config.shared { - bail!( - "The `auto-initialize` feature is enabled, but your python installation only supports \ - embedding the Python interpreter statically. If you are attempting to run tests, or a \ - binary which is okay to link dynamically, install a Python distribution which ships \ - with the Python shared library.\n\ - \n\ - Embedding the Python interpreter statically does not yet have first-class support in \ - PyO3. If you are sure you intend to do this, disable the `auto-initialize` feature.\n\ - \n\ - For more information, see \ - https://pyo3.rs/v{pyo3_version}/\ - building_and_distribution.html#embedding-python-in-rust", - pyo3_version = env::var("CARGO_PKG_VERSION").unwrap() - ); - } - - // TODO: PYO3_CI env is a hack to workaround CI with PyPy, where the `dev-dependencies` - // currently cause `auto-initialize` to be enabled in CI. - // Once MSRV is 1.51 or higher, use cargo's `resolver = "2"` instead. - if interpreter_config.implementation.is_pypy() && env::var_os("PYO3_CI").is_none() { - bail!("the `auto-initialize` feature is not supported with PyPy"); - } + if cargo_env_var("CARGO_FEATURE_AUTO_INITIALIZE").is_some() && !interpreter_config.shared { + bail!( + "The `auto-initialize` feature is enabled, but your python installation only supports \ + embedding the Python interpreter statically. If you are attempting to run tests, or a \ + binary which is okay to link dynamically, install a Python distribution which ships \ + with the Python shared library.\n\ + \n\ + Embedding the Python interpreter statically does not yet have first-class support in \ + PyO3. If you are sure you intend to do this, disable the `auto-initialize` feature.\n\ + \n\ + For more information, see \ + https://pyo3.rs/v{pyo3_version}/\ + building_and_distribution.html#embedding-python-in-rust", + pyo3_version = env::var("CARGO_PKG_VERSION").unwrap() + ); } Ok(()) } diff --git a/noxfile.py b/noxfile.py index c30c687a..c6b3248c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -628,7 +628,6 @@ def _for_all_version_configs( with tempfile.NamedTemporaryFile("r+") as config: env = os.environ.copy() env["PYO3_CONFIG_FILE"] = config.name - env["PYO3_CI"] = "1" def _job_with_config(implementation, version) -> bool: config.seek(0)