From fea66f25b1fe2560ae2e7e7e1b117166fa2aca04 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 8 Aug 2025 20:21:48 +1000 Subject: [PATCH] Support socks proxies when fetching versions --- qt/launcher/src/main.rs | 2 +- qt/launcher/versions.py | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/qt/launcher/src/main.rs b/qt/launcher/src/main.rs index 02fc08e76..297df5b8b 100644 --- a/qt/launcher/src/main.rs +++ b/qt/launcher/src/main.rs @@ -661,7 +661,7 @@ fn fetch_versions(state: &State) -> Result> { 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 = diff --git a/qt/launcher/versions.py b/qt/launcher/versions.py index 5d314d84f..0fdf69c84 100644 --- a/qt/launcher/versions.py +++ b/qt/launcher/versions.py @@ -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)