Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Fix mirror configuration not working during launcher download
Use environment variable instead of configuration file
  • Loading branch information
aldlss committed Sep 1, 2025
commit d667bf394bdfe1c03fab20ec0e39a2ec68298969
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Thomas Rixen <[email protected]>
Siyuan Mattuwu Yan <[email protected]>
Lee Doughty <[email protected]>
memchr <[email protected]>
Aldlss <[email protected]>

********************

Expand Down
23 changes: 14 additions & 9 deletions qt/launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re
command.env("UV_NO_CACHE", "1");
}

// Add mirror environment variable if enabled
if let Some((python_mirror, pypi_mirror)) = get_mirror_urls(state)? {
command
.env("UV_PYTHON_INSTALL_MIRROR", &python_mirror)
.env("UV_DEFAULT_INDEX", &pypi_mirror);
}

match command.ensure_success() {
Ok(_) => {
// Sync succeeded
Expand Down Expand Up @@ -673,6 +680,12 @@ fn fetch_versions(state: &State) -> Result<Vec<String>> {

cmd.arg(&versions_script);

// Add mirror environment variable if enabled
if let Some((python_mirror, pypi_mirror)) = get_mirror_urls(state)? {
cmd.env("UV_PYTHON_INSTALL_MIRROR", &python_mirror)
.env("UV_DEFAULT_INDEX", &pypi_mirror);
}

let output = match cmd.utf8_output() {
Ok(output) => output,
Err(e) => {
Expand Down Expand Up @@ -725,15 +738,7 @@ fn apply_version_kind(version_kind: &VersionKind, state: &State) -> Result<()> {
&format!("anki-release=={version}\",\n \"anki=={version}\",\n \"aqt=={version}"),
),
};

// Add mirror configuration if enabled
let final_content = if let Some((python_mirror, pypi_mirror)) = get_mirror_urls(state)? {
format!("{updated_content}\n\n[[tool.uv.index]]\nname = \"mirror\"\nurl = \"{pypi_mirror}\"\ndefault = true\n\n[tool.uv]\npython-install-mirror = \"{python_mirror}\"\n")
} else {
updated_content
};

write_file(&state.user_pyproject_path, &final_content)?;
write_file(&state.user_pyproject_path, &updated_content)?;

// Update .python-version based on version kind
match version_kind {
Expand Down