Skip to content

Commit

Permalink
Remove support for building only sdist via maturin build -i
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Feb 18, 2022
1 parent eec1822 commit 418dd64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Add support for `pyo3-ffi` by ijl in [#804](https://github.com/PyO3/maturin/pull/804)
* Defaults to `musllinux_1_2` for musl target if it's not bin bindings in [#808](https://github.com/PyO3/maturin/pull/808)
* Remove support for building only sdist via `maturin build -i` in [#813](https://github.com/PyO3/maturin/pull/813), use `maturin sdist` instead.

## [0.12.9] - 2022-02-09

Expand Down
47 changes: 19 additions & 28 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::path::PathBuf;
const PYO3_BINDING_CRATES: [&str; 2] = ["pyo3-ffi", "pyo3"];

/// High level API for building wheels from a crate which is also used for the CLI
#[derive(Debug, Serialize, Deserialize, clap::Parser, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Serialize, Deserialize, clap::Parser, Clone, Eq, PartialEq)]
#[serde(default)]
pub struct BuildOptions {
/// Control the platform tag on linux.
Expand All @@ -46,33 +46,41 @@ pub struct BuildOptions {
parse(try_from_str)
)]
pub platform_tag: Option<PlatformTag>,
#[clap(short, long)]

/// The python versions to build wheels for, given as the names of the
/// interpreters. Uses autodiscovery if not explicitly set.
pub interpreter: Option<Vec<PathBuf>>,
#[clap(short, long)]
pub interpreter: Vec<PathBuf>,

/// Which kind of bindings to use. Possible values are pyo3, rust-cpython, cffi and bin
#[clap(short, long)]
pub bindings: Option<String>,
#[clap(short = 'm', long = "manifest-path", parse(from_os_str), name = "PATH")]

/// The path to the Cargo.toml
#[clap(short = 'm', long = "manifest-path", parse(from_os_str), name = "PATH")]
pub manifest_path: Option<PathBuf>,

/// The directory to store the built wheels in. Defaults to a new "wheels"
/// directory in the project's target directory
#[clap(short, long, parse(from_os_str))]
pub out: Option<PathBuf>,

/// Don't check for manylinux compliance
#[clap(long = "skip-auditwheel")]
pub skip_auditwheel: bool,

/// For manylinux targets, use zig to ensure compliance for the chosen manylinux version
///
/// Default to manylinux2010/manylinux_2_12 if you do not specify an `--compatibility`
///
/// Make sure you installed zig with `pip install maturin[zig]`
#[clap(long)]
pub zig: bool,

/// The --target option for cargo
#[clap(long, name = "TRIPLE", env = "CARGO_BUILD_TARGET")]
pub target: Option<String>,

/// Extra arguments that will be passed to cargo as `cargo rustc [...] [arg1] [arg2] -- [...]`
///
/// Use as `--cargo-extra-args="--my-arg"`
Expand All @@ -82,35 +90,19 @@ pub struct BuildOptions {
/// be a bit flaky.
#[clap(long = "cargo-extra-args")]
pub cargo_extra_args: Vec<String>,

/// Extra arguments that will be passed to rustc as `cargo rustc [...] -- [...] [arg1] [arg2]`
///
/// Use as `--rustc-extra-args="--my-arg"`
#[clap(long = "rustc-extra-args")]
pub rustc_extra_args: Vec<String>,

/// Control whether to build universal2 wheel for macOS or not.
/// Only applies to macOS targets, do nothing otherwise.
#[clap(long)]
pub universal2: bool,
}

impl Default for BuildOptions {
fn default() -> Self {
BuildOptions {
platform_tag: None,
interpreter: Some(vec![]),
bindings: None,
manifest_path: None,
out: None,
skip_auditwheel: false,
zig: false,
target: None,
cargo_extra_args: Vec::new(),
rustc_extra_args: Vec::new(),
universal2: false,
}
}
}

impl BuildOptions {
/// Get cargo manifest file path
fn manifest_path(&self) -> Result<PathBuf> {
Expand Down Expand Up @@ -265,13 +257,12 @@ impl BuildOptions {
None => PathBuf::from(&cargo_metadata.target_directory).join("wheels"),
};

let interpreter = match self.interpreter {
// Only build a source distribution
Some(ref interpreter) if interpreter.is_empty() => vec![],
// User given list of interpreters
Some(interpreter) => find_interpreter(&bridge, &interpreter, &target, None)?,
let interpreter = if self.interpreter.is_empty() {
// Auto-detect interpreters
None => find_interpreter(&bridge, &[], &target, get_min_python_minor(&metadata21))?,
find_interpreter(&bridge, &[], &target, get_min_python_minor(&metadata21))?
} else {
// User given list of interpreters
find_interpreter(&bridge, &self.interpreter, &target, None)?
};

let mut rustc_extra_args = self.rustc_extra_args.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn develop(

let build_options = BuildOptions {
platform_tag: Some(PlatformTag::Linux),
interpreter: Some(vec![python.clone()]),
interpreter: vec![python.clone()],
bindings,
manifest_path: Some(manifest_file.to_path_buf()),
out: Some(wheel_dir.path().to_path_buf()),
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
metadata_directory,
strip,
} => {
assert!(matches!(
build_options.interpreter.as_ref(),
Some(version) if version.len() == 1
));
assert!(build_options.interpreter.len() == 1);
let context = build_options.into_build_context(true, strip, false)?;

// Since afaik all other PEP 517 backends also return linux tagged wheels, we do so too
Expand Down

0 comments on commit 418dd64

Please sign in to comment.