diff --git a/src/upload.rs b/src/upload.rs index a547bc0ed..926285709 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -45,7 +45,7 @@ pub struct PublishOpt { /// Password for pypi or your custom registry. /// /// Can also be set via MATURIN_PASSWORD environment variable. - #[arg(short, long)] + #[arg(short, long, env = "MATURIN_PASSWORD")] password: Option, /// Continue uploading files if one already exists. /// (Only valid when uploading to PyPI. Other implementations may not support this.) @@ -235,14 +235,13 @@ fn resolve_pypi_cred( } // fallback to username and password - if opt.non_interactive { + if opt.non_interactive && (opt.username.is_none() || opt.password.is_none()) { bail!("Credentials not found and non-interactive mode is enabled"); } let username = opt.username.clone().unwrap_or_else(get_username); let password = opt .password .clone() - .or_else(|| env::var("MATURIN_PASSWORD").ok()) .unwrap_or_else(|| get_password(&username)); Ok((username, password)) } diff --git a/tests/cmd/publish.stdout b/tests/cmd/publish.stdout index 3329c61a6..45ac4e9d1 100644 --- a/tests/cmd/publish.stdout +++ b/tests/cmd/publish.stdout @@ -45,6 +45,8 @@ Options: Password for pypi or your custom registry. Can also be set via MATURIN_PASSWORD environment variable. + + [env: MATURIN_PASSWORD=] --skip-existing Continue uploading files if one already exists. (Only valid when uploading to PyPI. Other diff --git a/tests/cmd/upload.stdout b/tests/cmd/upload.stdout index dfbda34ba..ceee45513 100644 --- a/tests/cmd/upload.stdout +++ b/tests/cmd/upload.stdout @@ -38,6 +38,8 @@ Options: Password for pypi or your custom registry. Can also be set via MATURIN_PASSWORD environment variable. + + [env: MATURIN_PASSWORD=] --skip-existing Continue uploading files if one already exists. (Only valid when uploading to PyPI. Other