Support socks proxies when fetching versions

This commit is contained in:
Damien Elmes 2025-08-08 20:21:48 +10:00 committed by Thomas Rixen
parent 54c1db87d6
commit fea66f25b1
2 changed files with 19 additions and 18 deletions

View file

@ -661,7 +661,7 @@ fn fetch_versions(state: &State) -> Result<Vec<String>> {
let mut cmd = Command::new(&state.uv_path);
cmd.current_dir(&state.uv_install_root)
.args(["run", "--no-project", "--no-config", "--managed-python"])
.args(["--with", "pip-system-certs"]);
.args(["--with", "pip-system-certs,requests[socks]"]);
let python_version = read_file(&state.dist_python_version_path)?;
let python_version_str =

View file

@ -3,9 +3,9 @@
import json
import sys
import urllib.request
import pip_system_certs.wrapt_requests
import requests
pip_system_certs.wrapt_requests.inject_truststore()
@ -15,25 +15,26 @@ def main():
url = "https://pypi.org/pypi/aqt/json"
try:
with urllib.request.urlopen(url, timeout=30) as response:
data = json.loads(response.read().decode("utf-8"))
releases = data.get("releases", {})
response = requests.get(url, timeout=30)
response.raise_for_status()
data = response.json()
releases = data.get("releases", {})
# Create list of (version, upload_time) tuples
version_times = []
for version, files in releases.items():
if files: # Only include versions that have files
# Use the upload time of the first file for each version
upload_time = files[0].get("upload_time_iso_8601")
if upload_time:
version_times.append((version, upload_time))
# Create list of (version, upload_time) tuples
version_times = []
for version, files in releases.items():
if files: # Only include versions that have files
# Use the upload time of the first file for each version
upload_time = files[0].get("upload_time_iso_8601")
if upload_time:
version_times.append((version, upload_time))
# Sort by upload time
version_times.sort(key=lambda x: x[1])
# Sort by upload time
version_times.sort(key=lambda x: x[1])
# Extract just the version names
versions = [version for version, _ in version_times]
print(json.dumps(versions))
# Extract just the version names
versions = [version for version, _ in version_times]
print(json.dumps(versions))
except Exception as e:
print(f"Error fetching versions: {e}", file=sys.stderr)
sys.exit(1)