From 71f470587551ecade68f0c7b97e9a429d0d405e2 Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 20 Jul 2019 00:17:42 +0200 Subject: [PATCH] More informative error on upload errors --- Cargo.lock | 18 ++++++-- Cargo.toml | 2 +- appveyor.yml | 2 +- src/main.rs | 119 ++++++++++++++++++++++++++------------------------- 4 files changed, 76 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e007ea0c2..1825476a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1115,7 +1115,7 @@ dependencies = [ [[package]] name = "pyo3-pack" -version = "0.7.0-beta.7" +version = "0.7.0-beta.9" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1130,7 +1130,7 @@ dependencies = [ "platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1347,7 +1347,7 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.9.18" +version = "0.9.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1377,6 +1377,7 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2115,6 +2116,14 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winreg" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2292,7 +2301,7 @@ dependencies = [ "checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" "checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)" = "00eb63f212df0e358b427f0f40aa13aaea010b470be642ad422bcbca2feff2e4" +"checksum reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" "checksum rle-decode-fast 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" "checksum rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c34fa7bcae7fca3c8471e8417088bbc3ad9af8066b0ecf4f3c0d98a0d772716e" @@ -2382,6 +2391,7 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" +"checksum winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73f1f3c6c4d3cab118551b96c476a2caab920701e28875b64a458f2ecb96ec9d" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" "checksum zip 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c18fc320faf909036e46ac785ea827f72e485304877faf1a3a39538d3714dbc3" diff --git a/Cargo.toml b/Cargo.toml index a30d76bba..85016f050 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["konstin "] name = "pyo3-pack" -version = "0.7.0-beta.8" +version = "0.7.0-beta.9" description = "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages" exclude = ["test-crates/**/*", "sysconfig/*", "test-data/*", "ci/*", "tests/*"] readme = "Readme.md" diff --git a/appveyor.yml b/appveyor.yml index 6cd4c6a96..227313141 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,7 @@ install: - ps: if ($env:channel -like "nightly-2019-05-04") { .\ci\setup.ps1 } # From and for ring - - IF "%CHANNEL%" == "nightly-2019-05-04" (call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64) + - IF "%CHANNEL%" == "nightly-2019-05-04" (call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64) - echo %PATH% - echo %LIBPATH% diff --git a/src/main.rs b/src/main.rs index 1fc3b6b1c..352531b53 100644 --- a/src/main.rs +++ b/src/main.rs @@ -320,69 +320,70 @@ fn upload_ui(build: BuildOptions, publish: &PublishOpt, no_sdist: bool) -> Resul loop { println!("🚀 Uploading {} packages", wheels.len()); - // Upload all wheels, aborting on the first error - let result = wheels - .iter() - .map(|(wheel_path, supported_versions, _)| { - upload( - ®istry, - &wheel_path, - &build_context.metadata21, - &supported_versions, - ) - }) - .collect(); - - match result { - Ok(()) => { - println!("✨ Packages uploaded succesfully"); - - #[cfg(feature = "keyring")] - { - // We know the password is correct, so we can save it in the keyring - let username = registry.username.clone(); - let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &username); - let password = registry.password.clone(); - keyring.set_password(&password).unwrap_or_else(|e| { - eprintln!("âš  Failed to store the password in the keyring: {:?}", e) - }); - } - - return Ok(()); - } - Err(UploadError::AuthenticationError) if reenter => { - println!("â›” Username and/or password are wrong"); - - #[cfg(feature = "keyring")] - { - // Delete the wrong password from the keyring - let old_username = registry.username.clone(); - let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &old_username); - match keyring.delete_password() { - Ok(()) => {} - Err(KeyringError::NoPasswordFound) | Err(KeyringError::NoBackendFound) => {} - _ => eprintln!("âš  Failed to remove password from keyring"), + for (wheel_path, supported_versions, _) in &wheels { + let result = upload( + ®istry, + &wheel_path, + &build_context.metadata21, + &supported_versions, + ); + match result { + Ok(()) => { + println!("✨ Packages uploaded succesfully"); + + #[cfg(feature = "keyring")] + { + // We know the password is correct, so we can save it in the keyring + let username = registry.username.clone(); + let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &username); + let password = registry.password.clone(); + keyring.set_password(&password).unwrap_or_else(|e| { + eprintln!("âš  Failed to store the password in the keyring: {:?}", e) + }); } + + return Ok(()); } + Err(UploadError::AuthenticationError) if reenter => { + println!("â›” Username and/or password are wrong"); + + #[cfg(feature = "keyring")] + { + // Delete the wrong password from the keyring + let old_username = registry.username.clone(); + let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &old_username); + match keyring.delete_password() { + Ok(()) => {} + Err(KeyringError::NoPasswordFound) + | Err(KeyringError::NoBackendFound) => {} + _ => eprintln!("âš  Failed to remove password from keyring"), + } + } - let username = get_username(); - let password = rpassword::prompt_password_stdout("Please enter your password: ") - .unwrap_or_else(|_| { - // So we need this fallback for pycharm on windows - let mut password = String::new(); - io::stdin() - .read_line(&mut password) - .expect("Failed to read line"); - password.trim().to_string() - }); - - registry = Registry::new(username, password, registry.url); - println!("… Retrying") - } - Err(UploadError::AuthenticationError) => { - bail!("Username and/or password are wrong"); + let username = get_username(); + let password = + rpassword::prompt_password_stdout("Please enter your password: ") + .unwrap_or_else(|_| { + // So we need this fallback for pycharm on windows + let mut password = String::new(); + io::stdin() + .read_line(&mut password) + .expect("Failed to read line"); + password.trim().to_string() + }); + + registry = Registry::new(username, password, registry.url); + println!("… Retrying"); + break; + } + Err(UploadError::AuthenticationError) => { + bail!("Username and/or password are wrong"); + } + Err(err) => { + let filename = wheel_path.file_name().unwrap_or(&wheel_path.as_os_str()); + return Err(err).context(format!("💥 Failed to upload {:?}", filename))?; + } } - Err(err) => return Err(err).context("💥 Failed to upload")?, } } }