From d0b9f80fef53b0bf971a0e0445baca0b4411f351 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 22 Nov 2023 21:55:51 +0800 Subject: [PATCH] Update `cargo-options` to 0.7.1 (#1862) --- Cargo.lock | 18 +++++---- Cargo.toml | 10 ++--- guide/src/develop.md | 81 ++++++++++++++++++++------------------- guide/src/distribution.md | 73 ++++++++++++++++++----------------- src/build_options.rs | 36 +++++++++++------ src/develop.rs | 3 +- src/main.rs | 6 ++- tests/cmd/build.stdout | 73 ++++++++++++++++++----------------- tests/cmd/develop.stdout | 73 ++++++++++++++++++----------------- tests/cmd/publish.stdout | 67 ++++++++++++++++---------------- 10 files changed, 236 insertions(+), 204 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51da7da16..3dece1805 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -238,10 +238,11 @@ dependencies = [ [[package]] name = "cargo-options" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b8e8daa6b2b84aa7cccd57317d9a9b36d969d75bb95923471f4eabbd36f2955" +checksum = "48e06313830a277c39d563be61cea4e008e32a810984e79ee5e46d9cae544018" dependencies = [ + "anstyle", "clap", ] @@ -256,9 +257,9 @@ dependencies = [ [[package]] name = "cargo-xwin" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22822a33c38f3769a3b6b3d7a591fe6fe84e2d72ea658933b198cc8149fb960b" +checksum = "e1f150a9138e0feff7de80b7572e74ac56170888dc6e166ce659aa7065eb197b" dependencies = [ "anyhow", "cargo-config2", @@ -280,9 +281,9 @@ dependencies = [ [[package]] name = "cargo-zigbuild" -version = "0.17.5" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5166694ea85c72f887293af72a665d7ac5a537649e607773bf834cb6303b1da" +checksum = "edc9c2fe646a29983b5f7263bd789175f2aaad7ea42525affa40e2172be93286" dependencies = [ "anyhow", "cargo-options", @@ -2539,14 +2540,15 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "which" -version = "4.4.2" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" dependencies = [ "either", "home", "once_cell", "rustix 0.38.21", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7efec5edf..bebdc0c79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ base64 = "0.21.0" glob = "0.3.0" cargo-config2 = "0.1.9" cargo_metadata = "0.18.0" -cargo-options = "0.6.0" +cargo-options = "0.7.1" cbindgen = { version = "0.26.0", default-features = false } flate2 = "1.0.18" goblin = "0.7.1" @@ -77,12 +77,12 @@ pep508_rs = { version = "0.2.1", features = ["serde"] } time = "0.3.17" # cli -clap = { version = "4.0.0", features = ["derive", "env", "wrap_help"] } +clap = { version = "4.0.0", features = ["derive", "env", "wrap_help", "unstable-styles"] } clap_complete_command = { version = "0.5.1", optional = true } # cross compile -cargo-zigbuild = { version = "0.17.5", default-features = false, optional = true } -cargo-xwin = { version = "0.15.0", default-features = false, optional = true } +cargo-zigbuild = { version = "0.18.0", default-features = false, optional = true } +cargo-xwin = { version = "0.16.0", default-features = false, optional = true } # log tracing = "0.1.36" @@ -113,7 +113,7 @@ pretty_assertions = "1.3.0" rustversion = "1.0.9" time = { version = "0.3.17", features = ["macros"] } trycmd = "0.14.11" -which = "4.3.0" +which = "5.0.0" [features] default = ["full", "rustls"] diff --git a/guide/src/develop.md b/guide/src/develop.md index 5b70768dd..8ee68b754 100644 --- a/guide/src/develop.md +++ b/guide/src/develop.md @@ -18,9 +18,6 @@ Options: [possible values: pyo3, pyo3-ffi, rust-cpython, cffi, uniffi, bin] - -r, --release - Pass --release to cargo - --strip Strip the library for minimum file size @@ -34,30 +31,46 @@ Options: Only works with mixed Rust/Python project layout - --pip-path - Use a specific pip installation instead of the default one. + --pip-path + Use a specific pip installation instead of the default one. - This can be used to supply the path to a pip executable when the current virtualenv does - not provide one. + This can be used to supply the path to a pip executable when the current virtualenv does + not provide one. -q, --quiet Do not print cargo log messages + --ignore-rust-version + Ignore `rust-version` specification in packages + + -v, --verbose... + Use verbose output (-vv very verbose/build.rs output) + + --color + Coloring: auto, always, never + + --config + Override a configuration value (unstable) + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + --future-incompat-report + Outputs a future incompatibility report at the end of the build (unstable) + + -h, --help + Print help (see a summary with '-h') + +Compilation Options: + -r, --release + Pass --release to cargo + -j, --jobs Number of parallel jobs, defaults to # of CPUs --profile Build artifacts with the specified Cargo profile - -F, --features - Space or comma separated list of features to activate - - --all-features - Activate all available features - - --no-default-features - Do not activate the `default` feature - --target Build for the target triple @@ -66,17 +79,22 @@ Options: --target-dir Directory for all generated artifacts - -m, --manifest-path - Path to Cargo.toml + --timings= + Timing output formats (unstable) (comma separated): html, json - --ignore-rust-version - Ignore `rust-version` specification in packages +Feature Selection: + -F, --features + Space or comma separated list of features to activate - -v, --verbose... - Use verbose output (-vv very verbose/build.rs output) + --all-features + Activate all available features - --color - Coloring: auto, always, never + --no-default-features + Do not activate the `default` feature + +Manifest Options: + -m, --manifest-path + Path to Cargo.toml --frozen Require Cargo.lock and cache are up to date @@ -86,21 +104,6 @@ Options: --offline Run without accessing the network - - --config - Override a configuration value (unstable) - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details - - --timings= - Timing output formats (unstable) (comma separated): html, json - - --future-incompat-report - Outputs a future incompatibility report at the end of the build (unstable) - - -h, --help - Print help (see a summary with '-h') ``` ## PEP 660 Editable Installs diff --git a/guide/src/distribution.md b/guide/src/distribution.md index cc16b2d17..b3dd15c04 100644 --- a/guide/src/distribution.md +++ b/guide/src/distribution.md @@ -77,9 +77,6 @@ Arguments: Rustc flags Options: - -r, --release - Build artifacts in release mode, with optimizations - --strip Strip the library for minimum file size @@ -129,21 +126,37 @@ Options: -q, --quiet Do not print cargo log messages + --ignore-rust-version + Ignore `rust-version` specification in packages + + -v, --verbose... + Use verbose output (-vv very verbose/build.rs output) + + --color + Coloring: auto, always, never + + --config + Override a configuration value (unstable) + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + --future-incompat-report + Outputs a future incompatibility report at the end of the build (unstable) + + -h, --help + Print help (see a summary with '-h') + +Compilation Options: + -r, --release + Build artifacts in release mode, with optimizations + -j, --jobs Number of parallel jobs, defaults to # of CPUs --profile Build artifacts with the specified Cargo profile - -F, --features - Space or comma separated list of features to activate - - --all-features - Activate all available features - - --no-default-features - Do not activate the `default` feature - --target Build for the target triple @@ -152,17 +165,22 @@ Options: --target-dir Directory for all generated artifacts - -m, --manifest-path - Path to Cargo.toml + --timings= + Timing output formats (unstable) (comma separated): html, json - --ignore-rust-version - Ignore `rust-version` specification in packages +Feature Selection: + -F, --features + Space or comma separated list of features to activate - -v, --verbose... - Use verbose output (-vv very verbose/build.rs output) + --all-features + Activate all available features - --color - Coloring: auto, always, never + --no-default-features + Do not activate the `default` feature + +Manifest Options: + -m, --manifest-path + Path to Cargo.toml --frozen Require Cargo.lock and cache are up to date @@ -172,21 +190,6 @@ Options: --offline Run without accessing the network - - --config - Override a configuration value (unstable) - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details - - --timings= - Timing output formats (unstable) (comma separated): html, json - - --future-incompat-report - Outputs a future incompatibility report at the end of the build (unstable) - - -h, --help - Print help (see a summary with '-h') ``` ### Cross Compiling diff --git a/src/build_options.rs b/src/build_options.rs index 6ac6c5aea..dfa159c92 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -8,6 +8,7 @@ use crate::python_interpreter::{InterpreterConfig, InterpreterKind, MINIMUM_PYTH use crate::{BuildContext, PythonInterpreter, Target}; use anyhow::{bail, format_err, Context, Result}; use cargo_metadata::{Metadata, Node}; +use cargo_options::heading; use pep440_rs::VersionSpecifiers; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; @@ -47,35 +48,45 @@ pub struct CargoOptions { pub quiet: bool, /// Number of parallel jobs, defaults to # of CPUs - #[arg(short = 'j', long, value_name = "N")] + #[arg(short = 'j', long, value_name = "N", help_heading = heading::COMPILATION_OPTIONS)] pub jobs: Option, /// Build artifacts with the specified Cargo profile - #[arg(long, value_name = "PROFILE-NAME")] + #[arg(long, value_name = "PROFILE-NAME", help_heading = heading::COMPILATION_OPTIONS)] pub profile: Option, /// Space or comma separated list of features to activate - #[arg(short = 'F', long, action = clap::ArgAction::Append)] + #[arg( + short = 'F', + long, + action = clap::ArgAction::Append, + help_heading = heading::FEATURE_SELECTION, + )] pub features: Vec, /// Activate all available features - #[arg(long)] + #[arg(long, help_heading = heading::FEATURE_SELECTION)] pub all_features: bool, /// Do not activate the `default` feature - #[arg(long)] + #[arg(long, help_heading = heading::FEATURE_SELECTION)] pub no_default_features: bool, /// Build for the target triple - #[arg(long, value_name = "TRIPLE", env = "CARGO_BUILD_TARGET")] + #[arg( + long, + value_name = "TRIPLE", + env = "CARGO_BUILD_TARGET", + help_heading = heading::COMPILATION_OPTIONS, + )] pub target: Option, /// Directory for all generated artifacts - #[arg(long, value_name = "DIRECTORY")] + #[arg(long, value_name = "DIRECTORY", help_heading = heading::COMPILATION_OPTIONS)] pub target_dir: Option, /// Path to Cargo.toml - #[arg(short = 'm', long, value_name = "PATH")] + #[arg(short = 'm', long, value_name = "PATH", help_heading = heading::MANIFEST_OPTIONS)] pub manifest_path: Option, /// Ignore `rust-version` specification in packages @@ -91,15 +102,15 @@ pub struct CargoOptions { pub color: Option, /// Require Cargo.lock and cache are up to date - #[arg(long)] + #[arg(long, help_heading = heading::MANIFEST_OPTIONS)] pub frozen: bool, /// Require Cargo.lock is up to date - #[arg(long)] + #[arg(long, help_heading = heading::MANIFEST_OPTIONS)] pub locked: bool, /// Run without accessing the network - #[arg(long)] + #[arg(long, help_heading = heading::MANIFEST_OPTIONS)] pub offline: bool, /// Override a configuration value (unstable) @@ -115,7 +126,8 @@ pub struct CargoOptions { long, value_name = "FMTS", value_delimiter = ',', - require_equals = true + require_equals = true, + help_heading = heading::COMPILATION_OPTIONS, )] pub timings: Option>, diff --git a/src/develop.rs b/src/develop.rs index 8e8dd72b9..f6ed88a4f 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -5,6 +5,7 @@ use crate::PlatformTag; use crate::PythonInterpreter; use crate::Target; use anyhow::{anyhow, bail, Context, Result}; +use cargo_options::heading; use pep508_rs::{MarkerExpression, MarkerOperator, MarkerTree, MarkerValue}; use std::path::Path; use std::path::PathBuf; @@ -23,7 +24,7 @@ pub struct DevelopOptions { )] pub bindings: Option, /// Pass --release to cargo - #[arg(short = 'r', long)] + #[arg(short = 'r', long, help_heading = heading::COMPILATION_OPTIONS,)] pub release: bool, /// Strip the library for minimum file size #[arg(long)] diff --git a/src/main.rs b/src/main.rs index f74eb350b..d87452473 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ //! Run with --help for usage information use anyhow::{bail, Context, Result}; +use cargo_options::heading; #[cfg(feature = "zig")] use cargo_zigbuild::Zig; #[cfg(feature = "cli-completion")] @@ -26,7 +27,8 @@ use tracing::debug; version, name = env!("CARGO_PKG_NAME"), display_order = 1, - after_help = "Visit https://maturin.rs to learn more about maturin." + after_help = "Visit https://maturin.rs to learn more about maturin.", + styles = cargo_options::styles(), )] #[cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] /// Build and publish crates with pyo3, rust-cpython and cffi bindings as well @@ -36,7 +38,7 @@ enum Opt { /// Build the crate into python packages Build { /// Build artifacts in release mode, with optimizations - #[arg(short = 'r', long)] + #[arg(short = 'r', long, help_heading = heading::COMPILATION_OPTIONS)] release: bool, /// Strip the library for minimum file size #[arg(long)] diff --git a/tests/cmd/build.stdout b/tests/cmd/build.stdout index 883fcbeba..0e2b600f3 100644 --- a/tests/cmd/build.stdout +++ b/tests/cmd/build.stdout @@ -7,9 +7,6 @@ Arguments: Rustc flags Options: - -r, --release - Build artifacts in release mode, with optimizations - --strip Strip the library for minimum file size @@ -59,21 +56,37 @@ Options: -q, --quiet Do not print cargo log messages + --ignore-rust-version + Ignore `rust-version` specification in packages + + -v, --verbose... + Use verbose output (-vv very verbose/build.rs output) + + --color + Coloring: auto, always, never + + --config + Override a configuration value (unstable) + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + --future-incompat-report + Outputs a future incompatibility report at the end of the build (unstable) + + -h, --help + Print help (see a summary with '-h') + +Compilation Options: + -r, --release + Build artifacts in release mode, with optimizations + -j, --jobs Number of parallel jobs, defaults to # of CPUs --profile Build artifacts with the specified Cargo profile - -F, --features - Space or comma separated list of features to activate - - --all-features - Activate all available features - - --no-default-features - Do not activate the `default` feature - --target Build for the target triple @@ -82,17 +95,22 @@ Options: --target-dir Directory for all generated artifacts - -m, --manifest-path - Path to Cargo.toml + --timings= + Timing output formats (unstable) (comma separated): html, json - --ignore-rust-version - Ignore `rust-version` specification in packages +Feature Selection: + -F, --features + Space or comma separated list of features to activate - -v, --verbose... - Use verbose output (-vv very verbose/build.rs output) + --all-features + Activate all available features - --color - Coloring: auto, always, never + --no-default-features + Do not activate the `default` feature + +Manifest Options: + -m, --manifest-path + Path to Cargo.toml --frozen Require Cargo.lock and cache are up to date @@ -102,18 +120,3 @@ Options: --offline Run without accessing the network - - --config - Override a configuration value (unstable) - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details - - --timings= - Timing output formats (unstable) (comma separated): html, json - - --future-incompat-report - Outputs a future incompatibility report at the end of the build (unstable) - - -h, --help - Print help (see a summary with '-h') diff --git a/tests/cmd/develop.stdout b/tests/cmd/develop.stdout index fc3ccb31d..0940dc108 100644 --- a/tests/cmd/develop.stdout +++ b/tests/cmd/develop.stdout @@ -12,9 +12,6 @@ Options: [possible values: pyo3, pyo3-ffi, rust-cpython, cffi, uniffi, bin] - -r, --release - Pass --release to cargo - --strip Strip the library for minimum file size @@ -37,21 +34,37 @@ Options: -q, --quiet Do not print cargo log messages + --ignore-rust-version + Ignore `rust-version` specification in packages + + -v, --verbose... + Use verbose output (-vv very verbose/build.rs output) + + --color + Coloring: auto, always, never + + --config + Override a configuration value (unstable) + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + --future-incompat-report + Outputs a future incompatibility report at the end of the build (unstable) + + -h, --help + Print help (see a summary with '-h') + +Compilation Options: + -r, --release + Pass --release to cargo + -j, --jobs Number of parallel jobs, defaults to # of CPUs --profile Build artifacts with the specified Cargo profile - -F, --features - Space or comma separated list of features to activate - - --all-features - Activate all available features - - --no-default-features - Do not activate the `default` feature - --target Build for the target triple @@ -60,17 +73,22 @@ Options: --target-dir Directory for all generated artifacts - -m, --manifest-path - Path to Cargo.toml + --timings= + Timing output formats (unstable) (comma separated): html, json - --ignore-rust-version - Ignore `rust-version` specification in packages +Feature Selection: + -F, --features + Space or comma separated list of features to activate - -v, --verbose... - Use verbose output (-vv very verbose/build.rs output) + --all-features + Activate all available features - --color - Coloring: auto, always, never + --no-default-features + Do not activate the `default` feature + +Manifest Options: + -m, --manifest-path + Path to Cargo.toml --frozen Require Cargo.lock and cache are up to date @@ -80,18 +98,3 @@ Options: --offline Run without accessing the network - - --config - Override a configuration value (unstable) - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details - - --timings= - Timing output formats (unstable) (comma separated): html, json - - --future-incompat-report - Outputs a future incompatibility report at the end of the build (unstable) - - -h, --help - Print help (see a summary with '-h') diff --git a/tests/cmd/publish.stdout b/tests/cmd/publish.stdout index 900622b69..8009f5f0d 100644 --- a/tests/cmd/publish.stdout +++ b/tests/cmd/publish.stdout @@ -102,21 +102,34 @@ Options: -q, --quiet Do not print cargo log messages + --ignore-rust-version + Ignore `rust-version` specification in packages + + -v, --verbose... + Use verbose output (-vv very verbose/build.rs output) + + --color + Coloring: auto, always, never + + --config + Override a configuration value (unstable) + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + --future-incompat-report + Outputs a future incompatibility report at the end of the build (unstable) + + -h, --help + Print help (see a summary with '-h') + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs --profile Build artifacts with the specified Cargo profile - -F, --features - Space or comma separated list of features to activate - - --all-features - Activate all available features - - --no-default-features - Do not activate the `default` feature - --target Build for the target triple @@ -125,17 +138,22 @@ Options: --target-dir Directory for all generated artifacts - -m, --manifest-path - Path to Cargo.toml + --timings= + Timing output formats (unstable) (comma separated): html, json - --ignore-rust-version - Ignore `rust-version` specification in packages +Feature Selection: + -F, --features + Space or comma separated list of features to activate - -v, --verbose... - Use verbose output (-vv very verbose/build.rs output) + --all-features + Activate all available features - --color - Coloring: auto, always, never + --no-default-features + Do not activate the `default` feature + +Manifest Options: + -m, --manifest-path + Path to Cargo.toml --frozen Require Cargo.lock and cache are up to date @@ -145,18 +163,3 @@ Options: --offline Run without accessing the network - - --config - Override a configuration value (unstable) - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details - - --timings= - Timing output formats (unstable) (comma separated): html, json - - --future-incompat-report - Outputs a future incompatibility report at the end of the build (unstable) - - -h, --help - Print help (see a summary with '-h')