-
Notifications
You must be signed in to change notification settings - Fork 0
Install gate, Phase 1: core gate — corgea pip|npm install <named targets> #111
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
Open
juangaitanv
wants to merge
3
commits into
install-gate-phase-0
Choose a base branch
from
install-gate-phase-1
base: install-gate-phase-0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ed18f39
Phase 1: core install gate — corgea pip|npm install <named targets>
juangaitanv d2d99d5
Phase 1 review fixes: gate npm --tag and pip --pre; warn on custom re…
juangaitanv 5fb3e5d
Phase 1 second-round review fixes: canonical pypi names, last-wins --…
juangaitanv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| //! Resolve and exec the real package manager, forwarding args and exit codes. | ||
|
|
||
| use std::ffi::OsString; | ||
| use std::process::Command; | ||
|
|
||
| use super::PackageManager; | ||
|
|
||
| pub(super) fn exec_install_with_args( | ||
| manager: PackageManager, | ||
| subcommand: &str, | ||
| rest: &[String], | ||
| ) -> i32 { | ||
| let mut full = Vec::with_capacity(rest.len() + 1); | ||
| full.push(subcommand.to_string()); | ||
| full.extend(rest.iter().cloned()); | ||
| exec_command(manager.binary_name(), &full) | ||
| } | ||
|
|
||
| /// Resolve `binary` on PATH. On Windows this finds `.cmd` shims. pip is the | ||
| /// one manager with a conventional alias, so a missing `pip` retries `pip3`. | ||
| /// The error names the binary and any fallback tried. | ||
| pub(super) fn resolve_binary(binary: &str) -> Result<std::path::PathBuf, String> { | ||
| if let Ok(p) = which::which(binary) { | ||
| return Ok(p); | ||
| } | ||
| if binary == "pip" { | ||
| if let Ok(p) = which::which("pip3") { | ||
| return Ok(p); | ||
| } | ||
| return Err("error: 'pip' not found on PATH (also tried 'pip3')".to_string()); | ||
| } | ||
| Err(format!("error: '{binary}' not found on PATH")) | ||
| } | ||
|
|
||
| pub(super) fn exec_command(binary: &str, args: &[String]) -> i32 { | ||
| let resolved = match resolve_binary(binary) { | ||
| Ok(p) => p, | ||
| Err(msg) => { | ||
| eprintln!("{msg}"); | ||
| return 127; | ||
| } | ||
| }; | ||
|
|
||
| let os_args: Vec<OsString> = args.iter().map(OsString::from).collect(); | ||
|
|
||
| let mut command = Command::new(&resolved); | ||
| command.args(&os_args); | ||
| match command.status() { | ||
| Ok(status) => status.code().unwrap_or_else(|| { | ||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::process::ExitStatusExt; | ||
| if let Some(sig) = status.signal() { | ||
| return 128 + sig; | ||
| } | ||
| } | ||
| 1 | ||
| }), | ||
| Err(e) => { | ||
| // Name the resolved path: it may be the pip3 fallback, not `binary`. | ||
| eprintln!("failed to exec {}: {}", resolved.display(), e); | ||
| 1 | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.