Skip to content

Commit

Permalink
Replace structopt with Clap 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 10, 2021
1 parent c04de80 commit f103539
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 166 deletions.
134 changes: 60 additions & 74 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.70"
sha2 = "0.9.3"
shlex = "1.0.0"
structopt = "0.3.21"
tar = "0.4.33"
tempfile = "3.2.0"
toml = "0.5.8"
Expand All @@ -57,6 +56,8 @@ ignore = "0.4.18"
dialoguer = "0.9.0"
console = "0.15.0"
minijinja = "0.8.2"
clap = { version = "3.0.0-rc.3", features = ["derive", "env"] }
clap_generate = "3.0.0-rc.3"

[dev-dependencies]
indoc = "1.0.3"
Expand Down
25 changes: 12 additions & 13 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ use std::collections::{HashMap, HashSet};
use std::env;
use std::io;
use std::path::PathBuf;
use structopt::StructOpt;

/// High level API for building wheels from a crate which is also used for the CLI
#[derive(Debug, Serialize, Deserialize, StructOpt, Clone, Eq, PartialEq)]
#[derive(Debug, Serialize, Deserialize, clap::Parser, Clone, Eq, PartialEq)]
#[serde(default)]
pub struct BuildOptions {
/// Control the platform tag on linux.
Expand All @@ -34,22 +33,22 @@ pub struct BuildOptions {
/// The default is the lowest compatible `manylinux` tag, or plain `linux` if nothing matched
///
/// This option is ignored on all non-linux platforms
#[structopt(
#[clap(
name = "compatibility",
long = "compatibility",
alias = "manylinux",
parse(try_from_str)
)]
pub platform_tag: Option<PlatformTag>,
#[structopt(short, long)]
#[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>>,
/// Which kind of bindings to use. Possible values are pyo3, rust-cpython, cffi and bin
#[structopt(short, long)]
#[clap(short, long)]
pub bindings: Option<String>,
#[structopt(
short = "m",
#[clap(
short = 'm',
long = "manifest-path",
parse(from_os_str),
default_value = "Cargo.toml",
Expand All @@ -59,13 +58,13 @@ pub struct BuildOptions {
pub manifest_path: PathBuf,
/// The directory to store the built wheels in. Defaults to a new "wheels"
/// directory in the project's target directory
#[structopt(short, long, parse(from_os_str))]
#[clap(short, long, parse(from_os_str))]
pub out: Option<PathBuf>,
/// Don't check for manylinux compliance
#[structopt(long = "skip-auditwheel")]
#[clap(long = "skip-auditwheel")]
pub skip_auditwheel: bool,
/// The --target option for cargo
#[structopt(long, name = "TRIPLE", env = "CARGO_BUILD_TARGET")]
#[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] -- [...]`
///
Expand All @@ -74,16 +73,16 @@ pub struct BuildOptions {
/// Note that maturin invokes cargo twice: Once as `cargo metadata` and then as `cargo rustc`.
/// maturin tries to pass only the shared subset of options to cargo metadata, but this is may
/// be a bit flaky.
#[structopt(long = "cargo-extra-args")]
#[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"`
#[structopt(long = "rustc-extra-args")]
#[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.
#[structopt(long)]
#[clap(long)]
pub universal2: bool,
}

Expand Down
Loading

0 comments on commit f103539

Please sign in to comment.