mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Support socks proxies when fetching versions
This commit is contained in:
parent
54c1db87d6
commit
fea66f25b1
2 changed files with 19 additions and 18 deletions
|
@ -661,7 +661,7 @@ fn fetch_versions(state: &State) -> Result<Vec<String>> {
|
||||||
let mut cmd = Command::new(&state.uv_path);
|
let mut cmd = Command::new(&state.uv_path);
|
||||||
cmd.current_dir(&state.uv_install_root)
|
cmd.current_dir(&state.uv_install_root)
|
||||||
.args(["run", "--no-project", "--no-config", "--managed-python"])
|
.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 = read_file(&state.dist_python_version_path)?;
|
||||||
let python_version_str =
|
let python_version_str =
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
import pip_system_certs.wrapt_requests
|
import pip_system_certs.wrapt_requests
|
||||||
|
import requests
|
||||||
|
|
||||||
pip_system_certs.wrapt_requests.inject_truststore()
|
pip_system_certs.wrapt_requests.inject_truststore()
|
||||||
|
|
||||||
|
@ -15,25 +15,26 @@ def main():
|
||||||
url = "https://pypi.org/pypi/aqt/json"
|
url = "https://pypi.org/pypi/aqt/json"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(url, timeout=30) as response:
|
response = requests.get(url, timeout=30)
|
||||||
data = json.loads(response.read().decode("utf-8"))
|
response.raise_for_status()
|
||||||
releases = data.get("releases", {})
|
data = response.json()
|
||||||
|
releases = data.get("releases", {})
|
||||||
|
|
||||||
# Create list of (version, upload_time) tuples
|
# Create list of (version, upload_time) tuples
|
||||||
version_times = []
|
version_times = []
|
||||||
for version, files in releases.items():
|
for version, files in releases.items():
|
||||||
if files: # Only include versions that have files
|
if files: # Only include versions that have files
|
||||||
# Use the upload time of the first file for each version
|
# Use the upload time of the first file for each version
|
||||||
upload_time = files[0].get("upload_time_iso_8601")
|
upload_time = files[0].get("upload_time_iso_8601")
|
||||||
if upload_time:
|
if upload_time:
|
||||||
version_times.append((version, upload_time))
|
version_times.append((version, upload_time))
|
||||||
|
|
||||||
# Sort by upload time
|
# Sort by upload time
|
||||||
version_times.sort(key=lambda x: x[1])
|
version_times.sort(key=lambda x: x[1])
|
||||||
|
|
||||||
# Extract just the version names
|
# Extract just the version names
|
||||||
versions = [version for version, _ in version_times]
|
versions = [version for version, _ in version_times]
|
||||||
print(json.dumps(versions))
|
print(json.dumps(versions))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error fetching versions: {e}", file=sys.stderr)
|
print(f"Error fetching versions: {e}", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue