Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network proxy support to upload command #939

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ clap_complete_fig = "3.1.0"
configparser = { version = "3.0.0", optional = true }
multipart = { version = "0.18.0", features = ["client"], default-features = false, optional = true }
rpassword = { version = "6.0.1", optional = true }
ureq = { version = "2.3.1", features = ["gzip"], default-features = false, optional = true }
ureq = { version = "2.3.1", features = ["gzip", "socks-proxy"], default-features = false, optional = true }
native-tls-crate = { package = "native-tls", version = "0.2.8", optional = true }
tracing = "0.1.34"

Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fix abi3 wheel build issue when no Python interpreters found on host in [#933](https://github.com/PyO3/maturin/pull/933)
* Add Python 3.11 sysconfigs for Linux, macOS and Windows in [#934](https://github.com/PyO3/maturin/pull/934)
* Add Python 3.11 sysconfig for arm64 Windows in [#936](https://github.com/PyO3/maturin/pull/936)
* Add network proxy support to upload command in [#939](https://github.com/PyO3/maturin/pull/939)

## [0.12.17] - 2022-05-18

Expand Down
24 changes: 20 additions & 4 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,31 @@ pub fn upload(registry: &Registry, wheel_path: &Path) -> Result<(), UploadError>

let encoded = base64::encode(&format!("{}:{}", registry.username, registry.password));

let http_proxy = env::var("HTTPS_PROXY")
.or_else(|_| env::var("https_proxy"))
.or_else(|_| env::var("HTTP_PROXY"))
.or_else(|_| env::var("http_proxy"));

#[cfg(not(feature = "native-tls"))]
let agent = ureq::agent();
let agent = {
let mut builder = ureq::builder();
if let Ok(proxy) = http_proxy {
let proxy = ureq::Proxy::new(proxy)?;
builder = builder.proxy(proxy);
};
builder.build()
};

#[cfg(feature = "native-tls")]
let agent = {
use std::sync::Arc;
ureq::builder()
.tls_connector(Arc::new(native_tls_crate::TlsConnector::new()?))
.build()
let mut builder =
ureq::builder().tls_connector(Arc::new(native_tls_crate::TlsConnector::new()?));
if let Ok(proxy) = http_proxy {
let proxy = ureq::Proxy::new(proxy)?;
builder = builder.proxy(proxy);
};
builder.build()
};

let response = agent
Expand Down