mirror of https://github.com/astral-sh/uv
Add a dedicated struct for source annotations (#3478)
This commit is contained in:
parent
8bcb2365bf
commit
f16cbfda7e
|
|
@ -1,9 +1,14 @@
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
use pep508_rs::VerbatimUrl;
|
||||||
use uv_fs::Simplified;
|
use uv_fs::Simplified;
|
||||||
|
use uv_normalize::PackageName;
|
||||||
|
|
||||||
/// Source of a dependency, e.g., a `-r requirements.txt` file.
|
/// Source of a dependency, e.g., a `-r requirements.txt` file.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub enum SourceAnnotation {
|
pub enum SourceAnnotation {
|
||||||
/// A `pyproject.toml` file.
|
/// A `pyproject.toml` file.
|
||||||
PyProject {
|
PyProject {
|
||||||
|
|
@ -18,16 +23,6 @@ pub enum SourceAnnotation {
|
||||||
Requirement(PathBuf),
|
Requirement(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for SourceAnnotation {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let s = String::deserialize(deserializer)?;
|
|
||||||
Ok(SourceAnnotation::Requirement(PathBuf::from(s)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for SourceAnnotation {
|
impl std::fmt::Display for SourceAnnotation {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
@ -50,3 +45,38 @@ impl std::fmt::Display for SourceAnnotation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A collection of source annotations.
|
||||||
|
#[derive(Default, Debug, Clone)]
|
||||||
|
pub struct SourceAnnotations {
|
||||||
|
packages: BTreeMap<PackageName, BTreeSet<SourceAnnotation>>,
|
||||||
|
editables: BTreeMap<Url, BTreeSet<SourceAnnotation>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SourceAnnotations {
|
||||||
|
/// Add a source annotation to the collection for the given package.
|
||||||
|
pub fn add(&mut self, package: &PackageName, annotation: SourceAnnotation) {
|
||||||
|
self.packages
|
||||||
|
.entry(package.clone())
|
||||||
|
.or_default()
|
||||||
|
.insert(annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add an source annotation to the collection for the given editable.
|
||||||
|
pub fn add_editable(&mut self, url: &VerbatimUrl, annotation: SourceAnnotation) {
|
||||||
|
self.editables
|
||||||
|
.entry(url.to_url())
|
||||||
|
.or_default()
|
||||||
|
.insert(annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the source annotations for a given package.
|
||||||
|
pub fn get(&self, package: &PackageName) -> Option<&BTreeSet<SourceAnnotation>> {
|
||||||
|
self.packages.get(package)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the source annotations for a given editable.
|
||||||
|
pub fn get_editable(&self, url: &VerbatimUrl) -> Option<&BTreeSet<SourceAnnotation>> {
|
||||||
|
self.editables.get(url.raw())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl Requirement {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
source,
|
source,
|
||||||
path: requirement.path,
|
path: requirement.source,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,14 +149,14 @@ pub struct Requirement<T: Pep508Url = VerbatimUrl> {
|
||||||
/// Those are a nested and/or tree.
|
/// Those are a nested and/or tree.
|
||||||
pub marker: Option<MarkerTree>,
|
pub marker: Option<MarkerTree>,
|
||||||
/// The source file containing the requirement.
|
/// The source file containing the requirement.
|
||||||
pub path: Option<PathBuf>,
|
pub source: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Requirement {
|
impl Requirement {
|
||||||
/// Set the source file containing the requirement.
|
/// Set the source file containing the requirement.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_source(self, path: Option<PathBuf>) -> Self {
|
pub fn with_source(self, source: Option<PathBuf>) -> Self {
|
||||||
Self { path, ..self }
|
Self { source, ..self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -492,7 +492,7 @@ impl<T: Pep508Url> Requirement<T> {
|
||||||
extras,
|
extras,
|
||||||
version_or_url,
|
version_or_url,
|
||||||
marker,
|
marker,
|
||||||
path,
|
source,
|
||||||
} = self;
|
} = self;
|
||||||
Requirement {
|
Requirement {
|
||||||
name,
|
name,
|
||||||
|
|
@ -505,7 +505,7 @@ impl<T: Pep508Url> Requirement<T> {
|
||||||
Some(VersionOrUrl::Url(url)) => Some(VersionOrUrl::Url(U::from(url))),
|
Some(VersionOrUrl::Url(url)) => Some(VersionOrUrl::Url(U::from(url))),
|
||||||
},
|
},
|
||||||
marker,
|
marker,
|
||||||
path,
|
source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1029,7 +1029,7 @@ fn parse_pep508_requirement<T: Pep508Url>(
|
||||||
extras,
|
extras,
|
||||||
version_or_url: requirement_kind,
|
version_or_url: requirement_kind,
|
||||||
marker,
|
marker,
|
||||||
path: None,
|
source: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1171,7 +1171,7 @@ mod tests {
|
||||||
operator: MarkerOperator::LessThan,
|
operator: MarkerOperator::LessThan,
|
||||||
r_value: MarkerValue::QuotedString("2.7".to_string()),
|
r_value: MarkerValue::QuotedString("2.7".to_string()),
|
||||||
})),
|
})),
|
||||||
path: None,
|
source: None,
|
||||||
};
|
};
|
||||||
assert_eq!(requests, expected);
|
assert_eq!(requests, expected);
|
||||||
}
|
}
|
||||||
|
|
@ -1397,7 +1397,7 @@ mod tests {
|
||||||
extras: vec![],
|
extras: vec![],
|
||||||
marker: None,
|
marker: None,
|
||||||
version_or_url: Some(VersionOrUrl::Url(Url::parse(url).unwrap())),
|
version_or_url: Some(VersionOrUrl::Url(Url::parse(url).unwrap())),
|
||||||
path: None,
|
source: None,
|
||||||
};
|
};
|
||||||
assert_eq!(pip_url, expected);
|
assert_eq!(pip_url, expected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ pub struct UnnamedRequirement {
|
||||||
/// Those are a nested and/or tree.
|
/// Those are a nested and/or tree.
|
||||||
pub marker: Option<MarkerTree>,
|
pub marker: Option<MarkerTree>,
|
||||||
/// The source file containing the requirement.
|
/// The source file containing the requirement.
|
||||||
pub path: Option<PathBuf>,
|
pub source: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnnamedRequirement {
|
impl UnnamedRequirement {
|
||||||
|
|
@ -46,8 +46,8 @@ impl UnnamedRequirement {
|
||||||
|
|
||||||
/// Set the source file containing the requirement.
|
/// Set the source file containing the requirement.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_source(self, path: Option<PathBuf>) -> Self {
|
pub fn with_source(self, source: Option<PathBuf>) -> Self {
|
||||||
Self { path, ..self }
|
Self { source, ..self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ fn parse_unnamed_requirement(
|
||||||
url,
|
url,
|
||||||
extras,
|
extras,
|
||||||
marker,
|
marker,
|
||||||
path: None,
|
source: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,13 @@ impl FindLink {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct EditableRequirement {
|
pub struct EditableRequirement {
|
||||||
|
/// The underlying [`VerbatimUrl`] from the `requirements.txt` file or similar.
|
||||||
pub url: VerbatimUrl,
|
pub url: VerbatimUrl,
|
||||||
|
/// The extras that should be included when resolving the editable requirements.
|
||||||
pub extras: Vec<ExtraName>,
|
pub extras: Vec<ExtraName>,
|
||||||
|
/// The local path to the editable.
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
/// The source file containing the requirement.
|
||||||
/// Path of the original file (where existing)
|
|
||||||
pub source: Option<PathBuf>,
|
pub source: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1813,7 +1815,7 @@ mod test {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/subdir/sibling.txt",
|
"<REQUIREMENTS_DIR>/subdir/sibling.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -1878,7 +1880,7 @@ mod test {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/requirements.txt",
|
"<REQUIREMENTS_DIR>/requirements.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -2075,7 +2077,7 @@ mod test {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/./sibling.txt",
|
"<REQUIREMENTS_DIR>/./sibling.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -2105,7 +2107,7 @@ mod test {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/requirements.txt",
|
"<REQUIREMENTS_DIR>/requirements.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -2137,7 +2139,7 @@ mod test {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/requirements.txt",
|
"<REQUIREMENTS_DIR>/requirements.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -2169,7 +2171,7 @@ mod test {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/requirements.txt",
|
"<REQUIREMENTS_DIR>/requirements.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -2199,7 +2201,7 @@ mod test {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/requirements.txt",
|
"<REQUIREMENTS_DIR>/requirements.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -84,7 +84,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -114,7 +114,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -144,7 +144,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -174,7 +174,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-a.txt",
|
"<REQUIREMENTS_DIR>/constraints-a.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -76,7 +76,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/editable.txt",
|
"<REQUIREMENTS_DIR>/editable.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -59,7 +59,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/editable.txt",
|
"<REQUIREMENTS_DIR>/editable.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -73,7 +73,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -111,7 +111,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-b.txt",
|
"<REQUIREMENTS_DIR>/include-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -43,7 +43,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-a.txt",
|
"<REQUIREMENTS_DIR>/include-a.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-b.txt",
|
"<REQUIREMENTS_DIR>/include-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -110,7 +110,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -180,7 +180,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -239,7 +239,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -299,7 +299,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/small.txt",
|
"<REQUIREMENTS_DIR>/small.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/small.txt",
|
"<REQUIREMENTS_DIR>/small.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/whitespace.txt",
|
"<REQUIREMENTS_DIR>/whitespace.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -59,7 +59,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/whitespace.txt",
|
"<REQUIREMENTS_DIR>/whitespace.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -84,7 +84,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -114,7 +114,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -144,7 +144,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -174,7 +174,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/basic.txt",
|
"<REQUIREMENTS_DIR>/basic.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-a.txt",
|
"<REQUIREMENTS_DIR>/constraints-a.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -76,7 +76,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
"<REQUIREMENTS_DIR>/constraints-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -73,7 +73,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -111,7 +111,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
"<REQUIREMENTS_DIR>/for-poetry.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-b.txt",
|
"<REQUIREMENTS_DIR>/include-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -43,7 +43,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-a.txt",
|
"<REQUIREMENTS_DIR>/include-a.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/include-b.txt",
|
"<REQUIREMENTS_DIR>/include-b.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -110,7 +110,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -180,7 +180,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -239,7 +239,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -299,7 +299,7 @@ RequirementsTxt {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/small.txt",
|
"<REQUIREMENTS_DIR>/small.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/small.txt",
|
"<REQUIREMENTS_DIR>/small.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ RequirementsTxt {
|
||||||
},
|
},
|
||||||
extras: [],
|
extras: [],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -60,7 +60,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -91,7 +91,7 @@ RequirementsTxt {
|
||||||
},
|
},
|
||||||
extras: [],
|
extras: [],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ RequirementsTxt {
|
||||||
extras: [],
|
extras: [],
|
||||||
version_or_url: None,
|
version_or_url: None,
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/whitespace.txt",
|
"<REQUIREMENTS_DIR>/whitespace.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -59,7 +59,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/whitespace.txt",
|
"<REQUIREMENTS_DIR>/whitespace.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ RequirementsTxt {
|
||||||
},
|
},
|
||||||
extras: [],
|
extras: [],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -60,7 +60,7 @@ RequirementsTxt {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -91,7 +91,7 @@ RequirementsTxt {
|
||||||
},
|
},
|
||||||
extras: [],
|
extras: [],
|
||||||
marker: None,
|
marker: None,
|
||||||
path: Some(
|
source: Some(
|
||||||
"<REQUIREMENTS_DIR>/bare-url.txt",
|
"<REQUIREMENTS_DIR>/bare-url.txt",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ pub(crate) async fn resolve_many(args: ResolveManyArgs) -> Result<()> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(equals_version),
|
version_or_url: Some(equals_version),
|
||||||
marker: None,
|
marker: None,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requirement
|
requirement
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +148,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: Some(project_path.clone()),
|
source: Some(project_path.clone()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +188,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: Some(project_path.clone()),
|
source: Some(project_path.clone()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,7 +276,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
version_or_url: Some(VersionOrUrl::Url(requirement.url)),
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
path: requirement.path,
|
source: requirement.source,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::BTreeSet;
|
||||||
use std::hash::BuildHasherDefault;
|
use std::hash::BuildHasherDefault;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
|
||||||
use distribution_types::{
|
use distribution_types::{
|
||||||
Dist, DistributionMetadata, IndexUrl, LocalEditable, Name, ParsedUrlError, Requirement,
|
Dist, DistributionMetadata, IndexUrl, LocalEditable, Name, ParsedUrlError, Requirement,
|
||||||
ResolvedDist, SourceAnnotation, Verbatim, VersionId, VersionOrUrlRef,
|
ResolvedDist, SourceAnnotations, Verbatim, VersionId, VersionOrUrlRef,
|
||||||
};
|
};
|
||||||
use once_map::OnceMap;
|
use once_map::OnceMap;
|
||||||
use pep440_rs::Version;
|
use pep440_rs::Version;
|
||||||
|
|
@ -545,20 +545,20 @@ pub struct DisplayResolutionGraph<'a> {
|
||||||
/// package.
|
/// package.
|
||||||
annotation_style: AnnotationStyle,
|
annotation_style: AnnotationStyle,
|
||||||
/// External sources for each package: requirements, constraints, and overrides.
|
/// External sources for each package: requirements, constraints, and overrides.
|
||||||
sources: BTreeMap<String, BTreeSet<SourceAnnotation>>,
|
sources: SourceAnnotations,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a ResolutionGraph> for DisplayResolutionGraph<'a> {
|
impl<'a> From<&'a ResolutionGraph> for DisplayResolutionGraph<'a> {
|
||||||
fn from(resolution: &'a ResolutionGraph) -> Self {
|
fn from(resolution: &'a ResolutionGraph) -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
resolution,
|
resolution,
|
||||||
BTreeMap::default(),
|
|
||||||
&[],
|
&[],
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
AnnotationStyle::default(),
|
AnnotationStyle::default(),
|
||||||
|
SourceAnnotations::default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -568,13 +568,13 @@ impl<'a> DisplayResolutionGraph<'a> {
|
||||||
#[allow(clippy::fn_params_excessive_bools, clippy::too_many_arguments)]
|
#[allow(clippy::fn_params_excessive_bools, clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
underlying: &'a ResolutionGraph,
|
underlying: &'a ResolutionGraph,
|
||||||
sources: BTreeMap<String, BTreeSet<SourceAnnotation>>,
|
|
||||||
no_emit_packages: &'a [PackageName],
|
no_emit_packages: &'a [PackageName],
|
||||||
show_hashes: bool,
|
show_hashes: bool,
|
||||||
include_extras: bool,
|
include_extras: bool,
|
||||||
include_annotations: bool,
|
include_annotations: bool,
|
||||||
include_index_annotation: bool,
|
include_index_annotation: bool,
|
||||||
annotation_style: AnnotationStyle,
|
annotation_style: AnnotationStyle,
|
||||||
|
sources: SourceAnnotations,
|
||||||
) -> DisplayResolutionGraph<'a> {
|
) -> DisplayResolutionGraph<'a> {
|
||||||
Self {
|
Self {
|
||||||
resolution: underlying,
|
resolution: underlying,
|
||||||
|
|
@ -726,15 +726,14 @@ impl std::fmt::Display for DisplayResolutionGraph<'_> {
|
||||||
edges.sort_unstable_by_key(|package| package.name());
|
edges.sort_unstable_by_key(|package| package.name());
|
||||||
|
|
||||||
// Include all external sources (e.g., requirements files).
|
// Include all external sources (e.g., requirements files).
|
||||||
let source_name: String = match node {
|
let default = BTreeSet::default();
|
||||||
Node::Editable(_package_name, local_editable) => {
|
let source = match node {
|
||||||
local_editable.url.given().unwrap_or_default().to_string()
|
Node::Editable(_, editable) => {
|
||||||
|
self.sources.get_editable(&editable.url).unwrap_or(&default)
|
||||||
}
|
}
|
||||||
Node::Distribution(name, _, _) => name.to_string(),
|
Node::Distribution(name, _, _) => self.sources.get(name).unwrap_or(&default),
|
||||||
};
|
};
|
||||||
|
|
||||||
let source = self.sources.get(&source_name).cloned().unwrap_or_default();
|
|
||||||
|
|
||||||
match self.annotation_style {
|
match self.annotation_style {
|
||||||
AnnotationStyle::Line => {
|
AnnotationStyle::Line => {
|
||||||
if !edges.is_empty() {
|
if !edges.is_empty() {
|
||||||
|
|
@ -742,7 +741,7 @@ impl std::fmt::Display for DisplayResolutionGraph<'_> {
|
||||||
let deps = edges
|
let deps = edges
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|dependency| format!("{}", dependency.name()))
|
.map(|dependency| format!("{}", dependency.name()))
|
||||||
.chain(source.into_iter().map(|source| source.to_string()))
|
.chain(source.iter().map(std::string::ToString::to_string))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
let comment = format!("# via {deps}").green().to_string();
|
let comment = format!("# via {deps}").green().to_string();
|
||||||
|
|
@ -766,8 +765,8 @@ impl std::fmt::Display for DisplayResolutionGraph<'_> {
|
||||||
edges => {
|
edges => {
|
||||||
let separator = "\n";
|
let separator = "\n";
|
||||||
let deps = source
|
let deps = source
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|source| source.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.chain(
|
.chain(
|
||||||
edges
|
edges
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::io::stdout;
|
use std::io::stdout;
|
||||||
|
|
@ -17,7 +16,8 @@ use tempfile::tempdir_in;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use distribution_types::{
|
use distribution_types::{
|
||||||
IndexLocations, LocalEditable, LocalEditables, ParsedUrlError, SourceAnnotation, Verbatim,
|
IndexLocations, LocalEditable, LocalEditables, ParsedUrlError, SourceAnnotation,
|
||||||
|
SourceAnnotations, Verbatim,
|
||||||
};
|
};
|
||||||
use distribution_types::{Requirement, Requirements};
|
use distribution_types::{Requirement, Requirements};
|
||||||
use install_wheel_rs::linker::LinkMode;
|
use install_wheel_rs::linker::LinkMode;
|
||||||
|
|
@ -354,61 +354,58 @@ pub(crate) async fn pip_compile(
|
||||||
.resolve()
|
.resolve()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut sources: BTreeMap<String, BTreeSet<SourceAnnotation>> = BTreeMap::new();
|
// Generate a map from requirement to originating source file.
|
||||||
|
let mut sources = SourceAnnotations::default();
|
||||||
|
|
||||||
for requirement in &requirements {
|
for requirement in &requirements {
|
||||||
if let Some(path) = &requirement.path {
|
if let Some(path) = &requirement.path {
|
||||||
if path.ends_with("pyproject.toml") {
|
if path.ends_with("pyproject.toml") {
|
||||||
sources
|
sources.add(
|
||||||
.entry(requirement.name.to_string())
|
&requirement.name,
|
||||||
.or_default()
|
SourceAnnotation::PyProject {
|
||||||
.insert(SourceAnnotation::PyProject {
|
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
project_name: project.as_ref().map(ToString::to_string),
|
project_name: project.as_ref().map(ToString::to_string),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
sources
|
sources.add(
|
||||||
.entry(requirement.name.to_string())
|
&requirement.name,
|
||||||
.or_default()
|
SourceAnnotation::Requirement(path.clone()),
|
||||||
.insert(SourceAnnotation::Requirement(path.clone()));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for requirement in &constraints {
|
for requirement in &constraints {
|
||||||
if let Some(path) = &requirement.path {
|
if let Some(path) = &requirement.path {
|
||||||
sources
|
sources.add(
|
||||||
.entry(requirement.name.to_string())
|
&requirement.name,
|
||||||
.or_default()
|
SourceAnnotation::Constraint(path.clone()),
|
||||||
.insert(SourceAnnotation::Constraint(path.clone()));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for requirement in &overrides {
|
for requirement in &overrides {
|
||||||
if let Some(path) = &requirement.path {
|
if let Some(path) = &requirement.path {
|
||||||
sources
|
sources.add(&requirement.name, SourceAnnotation::Override(path.clone()));
|
||||||
.entry(requirement.name.to_string())
|
|
||||||
.or_default()
|
|
||||||
.insert(SourceAnnotation::Override(path.clone()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for editable in &editables {
|
for editable in &editables {
|
||||||
let package_name = editable.url.given().unwrap_or_default().to_string();
|
|
||||||
if let Some(source) = &editable.source {
|
if let Some(source) = &editable.source {
|
||||||
if source.ends_with("pyproject.toml") {
|
if source.ends_with("pyproject.toml") {
|
||||||
sources
|
sources.add_editable(
|
||||||
.entry(package_name)
|
editable.url(),
|
||||||
.or_default()
|
SourceAnnotation::PyProject {
|
||||||
.insert(SourceAnnotation::PyProject {
|
|
||||||
path: source.clone(),
|
path: source.clone(),
|
||||||
project_name: project.as_ref().map(ToString::to_string),
|
project_name: project.as_ref().map(ToString::to_string),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
sources
|
sources.add_editable(
|
||||||
.entry(package_name)
|
editable.url(),
|
||||||
.or_default()
|
SourceAnnotation::Requirement(source.clone()),
|
||||||
.insert(SourceAnnotation::Requirement(source.clone()));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -654,13 +651,13 @@ pub(crate) async fn pip_compile(
|
||||||
"{}",
|
"{}",
|
||||||
DisplayResolutionGraph::new(
|
DisplayResolutionGraph::new(
|
||||||
&resolution,
|
&resolution,
|
||||||
sources,
|
|
||||||
&no_emit_packages,
|
&no_emit_packages,
|
||||||
generate_hashes,
|
generate_hashes,
|
||||||
include_extras,
|
include_extras,
|
||||||
include_annotations,
|
include_annotations,
|
||||||
include_index_annotation,
|
include_index_annotation,
|
||||||
annotation_style,
|
annotation_style,
|
||||||
|
sources,
|
||||||
)
|
)
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue