mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-30 14:01:13 +00:00
Fix serialization of index URLs (#3289)
Closes https://github.com/astral-sh/uv/issues/3288.
This commit is contained in:
parent
028b407411
commit
42a44dcfff
2 changed files with 22 additions and 1 deletions
|
@ -20,7 +20,7 @@ static DEFAULT_INDEX_URL: Lazy<IndexUrl> =
|
|||
Lazy::new(|| IndexUrl::Pypi(VerbatimUrl::from_url(PYPI_URL.clone())));
|
||||
|
||||
/// The url of an index, newtype'd to avoid mixing it with file urls.
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
|
||||
pub enum IndexUrl {
|
||||
Pypi(VerbatimUrl),
|
||||
Url(VerbatimUrl),
|
||||
|
@ -100,6 +100,25 @@ impl FromStr for IndexUrl {
|
|||
}
|
||||
}
|
||||
|
||||
impl serde::ser::Serialize for IndexUrl {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::ser::Serializer,
|
||||
{
|
||||
self.verbatim().serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> serde::de::Deserialize<'de> for IndexUrl {
|
||||
fn deserialize<D>(deserializer: D) -> Result<IndexUrl, D::Error>
|
||||
where
|
||||
D: serde::de::Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
IndexUrl::from_str(&s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<VerbatimUrl> for IndexUrl {
|
||||
fn from(url: VerbatimUrl) -> Self {
|
||||
if *url.raw() == *PYPI_URL {
|
||||
|
|
|
@ -8217,6 +8217,7 @@ fn resolve_configuration() -> Result<()> {
|
|||
[pip]
|
||||
resolution = "lowest-direct"
|
||||
generate-hashes = true
|
||||
index-url = "https://pypi.org/simple"
|
||||
"#})?;
|
||||
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
|
@ -8358,6 +8359,7 @@ fn resolve_configuration() -> Result<()> {
|
|||
[tool.uv.pip]
|
||||
resolution = "lowest-direct"
|
||||
generate-hashes = true
|
||||
index-url = "https://pypi.org/simple"
|
||||
"#})?;
|
||||
|
||||
// Resolution should use the lowest direct version, and generate hashes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue