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

Always write --index-url before --extra-index-url #1278

Merged
merged 1 commit into from
Jul 25, 2024
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
2 changes: 1 addition & 1 deletion rye/src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fn find_best_matches_with_unearth(
Some(ver) => ver.format_simple(),
None => "".into(),
})
.arg(&format_requirement(requirement).to_string())
.arg(format_requirement(requirement).to_string())
.arg(serde_json::to_string(&sources)?);
if pre {
unearth.arg("--pre");
Expand Down
2 changes: 1 addition & 1 deletion rye/src/cli/rye.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ fn uninstall(args: UninstallCommand) -> Result<(), Error> {
let shim_dir = app_dir.join("shims");
if let Ok(dir) = shim_dir.read_dir() {
for entry in dir.flatten() {
fs::remove_file(&entry.path()).ok();
fs::remove_file(entry.path()).ok();
}
}

Expand Down
4 changes: 2 additions & 2 deletions rye/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn install(
}
cmd.env("PYTHONWARNINGS", "ignore");
}
cmd.arg("--").arg(&requirement.to_string());
cmd.arg("--").arg(requirement.to_string());

// we don't support versions below 3.7, but for 3.7 we need importlib-metadata
// to be installed
Expand Down Expand Up @@ -410,7 +410,7 @@ fn uninstall_helper(target_venv_path: &Path, shim_dir: &Path) -> Result<(), Erro
let script = script?;
if let Some(base_name) = script.path().file_name() {
let shim_path = shim_dir.join(base_name);
if let Ok(true) = is_same_file(&shim_path, &script.path()) {
if let Ok(true) = is_same_file(&shim_path, script.path()) {
fs::remove_file(&shim_path).ok();
}
}
Expand Down
47 changes: 31 additions & 16 deletions rye/src/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,17 +1421,25 @@ impl ExpandedSources {

/// Attach common pip args to a command.
pub fn add_as_pip_args(&self, cmd: &mut Command) {
for (url, default) in self.index_urls.iter() {
if *default {
cmd.arg("--index-url");
} else {
cmd.arg("--extra-index-url");
}
cmd.arg(&url.to_string());
for url in self
.index_urls
.iter()
.filter_map(|(url, default)| if *default { Some(url) } else { None })
{
cmd.arg("--index-url");
cmd.arg(url.to_string());
}
for url in self
.index_urls
.iter()
.filter_map(|(url, default)| if *default { None } else { Some(url) })
{
cmd.arg("--extra-index-url");
cmd.arg(url.to_string());
}
for link in &self.find_links {
cmd.arg("--find-links");
cmd.arg(&link.to_string());
cmd.arg(link.to_string());
}
for host in &self.trusted_hosts {
cmd.arg("--trusted-host");
Expand All @@ -1441,18 +1449,25 @@ impl ExpandedSources {

/// Write the sources to a lockfile.
pub fn add_to_lockfile(&self, out: &mut dyn std::io::Write) -> std::io::Result<()> {
for (url, default) in self.index_urls.iter() {
if *default {
writeln!(out, "--index-url {}", url)?;
} else {
writeln!(out, "--extra-index-url {}", url)?;
}
for url in self
.index_urls
.iter()
.filter_map(|(url, default)| if *default { Some(url) } else { None })
{
writeln!(out, "--index-url {url}")?;
}
for url in self
.index_urls
.iter()
.filter_map(|(url, default)| if *default { None } else { Some(url) })
{
writeln!(out, "--extra-index-url {url}")?;
}
for link in &self.find_links {
writeln!(out, "--find-links {}", link)?;
writeln!(out, "--find-links {link}")?;
}
for host in &self.trusted_hosts {
writeln!(out, "--trusted-host {}", host)?;
writeln!(out, "--trusted-host {host}")?;
}
Ok(())
}
Expand Down