-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add UV_SKIP_WHEEL_FILENAME_CHECK
to allow installing invalid wheels
#16046
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
Merged
Merged
Changes from all commits
Commits
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
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 |
---|---|---|
@@ -1,3 +1,74 @@ | ||
pub use env_vars::*; | ||
|
||
mod env_vars; | ||
|
||
/// Parse a boolean environment variable. | ||
/// | ||
/// Adapted from Clap's `BoolishValueParser` which is dual licensed under the MIT and Apache-2.0. | ||
pub fn parse_boolish_environment_variable(name: &'static str) -> Result<Option<bool>, String> { | ||
// See `clap_builder/src/util/str_to_bool.rs` | ||
// We want to match Clap's accepted values | ||
|
||
// True values are `y`, `yes`, `t`, `true`, `on`, and `1`. | ||
const TRUE_LITERALS: [&str; 6] = ["y", "yes", "t", "true", "on", "1"]; | ||
|
||
// False values are `n`, `no`, `f`, `false`, `off`, and `0`. | ||
const FALSE_LITERALS: [&str; 6] = ["n", "no", "f", "false", "off", "0"]; | ||
|
||
// Converts a string literal representation of truth to true or false. | ||
// | ||
// `false` values are `n`, `no`, `f`, `false`, `off`, and `0` (case insensitive). | ||
// | ||
// Any other value will be considered as `true`. | ||
fn str_to_bool(val: impl AsRef<str>) -> Option<bool> { | ||
let pat: &str = &val.as_ref().to_lowercase(); | ||
if TRUE_LITERALS.contains(&pat) { | ||
Some(true) | ||
} else if FALSE_LITERALS.contains(&pat) { | ||
Some(false) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
let Some(value) = std::env::var_os(name) else { | ||
return Ok(None); | ||
}; | ||
|
||
let Some(value) = value.to_str() else { | ||
return Err(format!( | ||
"Failed to parse environment variable `{}` with invalid value `{}`: expected a valid UTF-8 string", | ||
name, | ||
value.to_string_lossy() | ||
)); | ||
}; | ||
|
||
let Some(value) = str_to_bool(value) else { | ||
return Err(format!( | ||
"Failed to parse environment variable `{name}` with invalid value `{value}`: expected a boolish value" | ||
)); | ||
}; | ||
|
||
Ok(Some(value)) | ||
} | ||
|
||
/// Parse a string environment variable. | ||
pub fn parse_string_environment_variable(name: &'static str) -> Result<Option<String>, String> { | ||
match std::env::var(name) { | ||
Ok(v) => { | ||
if v.is_empty() { | ||
Ok(None) | ||
} else { | ||
Ok(Some(v)) | ||
} | ||
} | ||
Err(e) => match e { | ||
std::env::VarError::NotPresent => Ok(None), | ||
std::env::VarError::NotUnicode(err) => Err(format!( | ||
"Failed to parse environment variable `{}` with invalid value `{}`: expected a valid UTF-8 string", | ||
name, | ||
err.to_string_lossy() | ||
)), | ||
}, | ||
} | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to do this once and pass it around, but it's legitimately annoying to do here, because this is ultimately triggered by a
TryFrom
onLockWire
, so even if we did have it as a setting, we'd have to restructure the Serde setup to make it work.Honestly, I kind of think we should parse these once (
EnvironmentOptions
) then set some global flags on a singleton that we can then access anywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this out here: #16047