-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
114 changed files
with
14,358 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
variables: | ||
toolchain: nightly-2024-08-05 | ||
toolchain: nightly-2024-09-13 | ||
|
||
jobs: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[package] | ||
name = "pyo3-build-config" | ||
version = "0.23.0-dev" | ||
description = "Build configuration for the PyO3 ecosystem" | ||
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"] | ||
keywords = ["pyo3", "python", "cpython", "ffi"] | ||
homepage = "https://github.com/pyo3/pyo3" | ||
repository = "https://github.com/pyo3/pyo3" | ||
categories = ["api-bindings", "development-tools::ffi"] | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
once_cell = "1" | ||
python3-dll-a = { version = "0.2.6", optional = true } | ||
target-lexicon = "0.12.14" | ||
|
||
[build-dependencies] | ||
python3-dll-a = { version = "0.2.6", optional = true } | ||
target-lexicon = "0.12.14" | ||
|
||
[features] | ||
default = [] | ||
|
||
# Attempt to resolve a Python interpreter config for building in the build | ||
# script. If this feature isn't enabled, the build script no-ops. | ||
resolve-config = [] | ||
|
||
# This feature is enabled by pyo3 when building an extension module. | ||
extension-module = [] | ||
|
||
# These features are enabled by pyo3 when building Stable ABI extension modules. | ||
abi3 = [] | ||
abi3-py37 = ["abi3-py38"] | ||
abi3-py38 = ["abi3-py39"] | ||
abi3-py39 = ["abi3-py310"] | ||
abi3-py310 = ["abi3-py311"] | ||
abi3-py311 = ["abi3-py312"] | ||
abi3-py312 = ["abi3"] | ||
|
||
[package.metadata.docs.rs] | ||
features = ["resolve-config"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Import some modules from this crate inline to generate the build config. | ||
// Allow dead code because not all code in the modules is used in this build script. | ||
|
||
#[path = "src/impl_.rs"] | ||
#[allow(dead_code)] | ||
mod impl_; | ||
|
||
#[path = "src/errors.rs"] | ||
#[allow(dead_code)] | ||
mod errors; | ||
|
||
use std::{env, path::Path}; | ||
|
||
use errors::{Context, Result}; | ||
use impl_::{make_interpreter_config, InterpreterConfig}; | ||
|
||
fn configure(interpreter_config: Option<InterpreterConfig>, name: &str) -> Result<bool> { | ||
let target = Path::new(&env::var_os("OUT_DIR").unwrap()).join(name); | ||
if let Some(config) = interpreter_config { | ||
config | ||
.to_writer(&mut std::fs::File::create(&target).with_context(|| { | ||
format!("failed to write config file at {}", target.display()) | ||
})?)?; | ||
Ok(true) | ||
} else { | ||
std::fs::File::create(&target) | ||
.with_context(|| format!("failed to create new file at {}", target.display()))?; | ||
Ok(false) | ||
} | ||
} | ||
|
||
fn generate_build_configs() -> Result<()> { | ||
// If PYO3_CONFIG_FILE is set, copy it into the crate. | ||
let configured = configure( | ||
InterpreterConfig::from_pyo3_config_file_env().transpose()?, | ||
"pyo3-build-config-file.txt", | ||
)?; | ||
|
||
if configured { | ||
// Don't bother trying to find an interpreter on the host system | ||
// if the user-provided config file is present. | ||
configure(None, "pyo3-build-config.txt")?; | ||
} else { | ||
configure(Some(make_interpreter_config()?), "pyo3-build-config.txt")?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
if std::env::var("CARGO_FEATURE_RESOLVE_CONFIG").is_ok() { | ||
if let Err(e) = generate_build_configs() { | ||
eprintln!("error: {}", e.report()); | ||
std::process::exit(1) | ||
} | ||
} else { | ||
eprintln!("resolve-config feature not enabled; build script in no-op mode"); | ||
} | ||
} |
Oops, something went wrong.