Skip to content
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
7 changes: 5 additions & 2 deletions crates/uv-distribution-types/src/buildable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ impl SourceUrl<'_> {
pub fn is_editable(&self) -> bool {
matches!(
self,
Self::Directory(DirectorySourceUrl { editable: true, .. })
Self::Directory(DirectorySourceUrl {
editable: Some(true),
..
})
)
}

Expand Down Expand Up @@ -210,7 +213,7 @@ impl<'a> From<&'a PathSourceDist> for PathSourceUrl<'a> {
pub struct DirectorySourceUrl<'a> {
pub url: &'a DisplaySafeUrl,
pub install_path: Cow<'a, Path>,
pub editable: bool,
pub editable: Option<bool>,
}

impl std::fmt::Display for DirectorySourceUrl<'_> {
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ pub struct DirectorySourceDist {
/// The absolute path to the distribution which we use for installing.
pub install_path: Box<Path>,
/// Whether the package should be installed in editable mode.
pub editable: bool,
pub editable: Option<bool>,
/// Whether the package should be built and installed.
pub r#virtual: bool,
pub r#virtual: Option<bool>,
/// The URL as it was provided by the user.
pub url: VerbatimUrl,
}
Expand Down Expand Up @@ -452,8 +452,8 @@ impl Dist {
name: PackageName,
url: VerbatimUrl,
install_path: &Path,
editable: bool,
r#virtual: bool,
editable: Option<bool>,
r#virtual: Option<bool>,
) -> Result<Dist, Error> {
// Convert to an absolute path.
let install_path = path::absolute(install_path)?;
Expand Down Expand Up @@ -655,15 +655,15 @@ impl SourceDist {
/// Returns `true` if the distribution is editable.
pub fn is_editable(&self) -> bool {
match self {
Self::Directory(DirectorySourceDist { editable, .. }) => *editable,
Self::Directory(DirectorySourceDist { editable, .. }) => editable.unwrap_or(false),
_ => false,
}
}

/// Returns `true` if the distribution is virtual.
pub fn is_virtual(&self) -> bool {
match self {
Self::Directory(DirectorySourceDist { r#virtual, .. }) => *r#virtual,
Self::Directory(DirectorySourceDist { r#virtual, .. }) => r#virtual.unwrap_or(false),
_ => false,
}
}
Expand Down
32 changes: 19 additions & 13 deletions crates/uv-distribution-types/src/requirement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ pub enum RequirementSource {
/// The absolute path to the distribution which we use for installing.
install_path: Box<Path>,
/// For a source tree (a directory), whether to install as an editable.
editable: bool,
editable: Option<bool>,
/// For a source tree (a directory), whether the project should be built and installed.
r#virtual: bool,
r#virtual: Option<bool>,
/// The PEP 508 style URL in the format
/// `file:///<path>#subdirectory=<subdirectory>`.
url: VerbatimUrl,
Expand Down Expand Up @@ -545,7 +545,13 @@ impl RequirementSource {

/// Returns `true` if the source is editable.
pub fn is_editable(&self) -> bool {
matches!(self, Self::Directory { editable: true, .. })
matches!(
self,
Self::Directory {
editable: Some(true),
..
}
)
}

/// Returns `true` if the source is empty.
Expand Down Expand Up @@ -792,11 +798,11 @@ impl From<RequirementSource> for RequirementSourceWire {
r#virtual,
url: _,
} => {
if editable {
if editable.unwrap_or(false) {
Self::Editable {
editable: PortablePathBuf::from(install_path),
}
} else if r#virtual {
} else if r#virtual.unwrap_or(false) {
Self::Virtual {
r#virtual: PortablePathBuf::from(install_path),
}
Expand Down Expand Up @@ -908,8 +914,8 @@ impl TryFrom<RequirementSourceWire> for RequirementSource {
))?;
Ok(Self::Directory {
install_path: directory,
editable: false,
r#virtual: false,
editable: Some(false),
r#virtual: Some(false),
url,
})
}
Expand All @@ -920,8 +926,8 @@ impl TryFrom<RequirementSourceWire> for RequirementSource {
))?;
Ok(Self::Directory {
install_path: editable,
editable: true,
r#virtual: false,
editable: Some(true),
r#virtual: Some(false),
url,
})
}
Expand All @@ -932,8 +938,8 @@ impl TryFrom<RequirementSourceWire> for RequirementSource {
))?;
Ok(Self::Directory {
install_path: r#virtual,
editable: false,
r#virtual: true,
editable: Some(false),
r#virtual: Some(true),
url,
})
}
Expand Down Expand Up @@ -980,8 +986,8 @@ mod tests {
marker: MarkerTree::TRUE,
source: RequirementSource::Directory {
install_path: PathBuf::from(path).into_boxed_path(),
editable: false,
r#virtual: false,
editable: Some(false),
r#virtual: Some(false),
url: VerbatimUrl::from_absolute_path(path).unwrap(),
},
origin: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-distribution/src/index/built_wheel_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'a> BuiltWheelIndex<'a> {
) -> Result<Option<CachedWheel>, Error> {
let cache_shard = self.cache.shard(
CacheBucket::SourceDistributions,
if source_dist.editable {
if source_dist.editable.unwrap_or(false) {
WheelCache::Editable(&source_dist.url).root()
} else {
WheelCache::Path(&source_dist.url).root()
Expand Down
20 changes: 11 additions & 9 deletions crates/uv-distribution/src/metadata/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ impl LoweredRequirement {
RequirementSource::Directory {
install_path: install_path.into_boxed_path(),
url,
editable: true,
r#virtual: false,
editable: Some(true),
r#virtual: Some(false),
}
} else {
RequirementSource::Directory {
install_path: install_path.into_boxed_path(),
url,
editable: false,
r#virtual: true,
editable: Some(false),
r#virtual: Some(true),
}
};
(source, marker)
Expand Down Expand Up @@ -724,8 +724,8 @@ fn path_source(
Ok(RequirementSource::Directory {
install_path: install_path.into_boxed_path(),
url,
editable: true,
r#virtual: false,
editable,
r#virtual: Some(false),
})
} else {
// Determine whether the project is a package or virtual.
Expand All @@ -738,12 +738,14 @@ fn path_source(
.unwrap_or(true)
});

// If the project is not a package, treat it as a virtual dependency.
let r#virtual = !is_package;

Ok(RequirementSource::Directory {
install_path: install_path.into_boxed_path(),
url,
editable: false,
// If a project is not a package, treat it as a virtual dependency.
r#virtual: !is_package,
editable: Some(false),
r#virtual: Some(r#virtual),
})
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {

let cache_shard = self.build_context.cache().shard(
CacheBucket::SourceDistributions,
if resource.editable {
if resource.editable.unwrap_or(false) {
WheelCache::Editable(resource.url).root()
} else {
WheelCache::Path(resource.url).root()
Expand Down Expand Up @@ -1173,7 +1173,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {

let cache_shard = self.build_context.cache().shard(
CacheBucket::SourceDistributions,
if resource.editable {
if resource.editable.unwrap_or(false) {
WheelCache::Editable(resource.url).root()
} else {
WheelCache::Path(resource.url).root()
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-installer/src/satisfies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl RequirementSatisfaction {
return Self::Mismatch;
};

if *requested_editable != installed_editable.unwrap_or_default() {
if requested_editable != installed_editable {
trace!(
"Editable mismatch: {:?} vs. {:?}",
*requested_editable,
Expand Down
29 changes: 17 additions & 12 deletions crates/uv-pypi-types/src/parsed_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl UnnamedRequirementUrl for VerbatimParsedUrl {
ParsedUrl::Directory(ParsedDirectoryUrl {
url,
install_path,
editable: false,
r#virtual: false,
editable: None,
r#virtual: None,
})
} else {
ParsedUrl::Path(ParsedPathUrl {
Expand Down Expand Up @@ -118,8 +118,8 @@ impl UnnamedRequirementUrl for VerbatimParsedUrl {
ParsedUrl::Directory(ParsedDirectoryUrl {
url,
install_path,
editable: false,
r#virtual: false,
editable: None,
r#virtual: None,
})
} else {
ParsedUrl::Path(ParsedPathUrl {
Expand Down Expand Up @@ -187,7 +187,10 @@ impl ParsedUrl {
pub fn is_editable(&self) -> bool {
matches!(
self,
Self::Directory(ParsedDirectoryUrl { editable: true, .. })
Self::Directory(ParsedDirectoryUrl {
editable: Some(true),
..
})
)
}
}
Expand Down Expand Up @@ -226,16 +229,18 @@ pub struct ParsedDirectoryUrl {
pub url: DisplaySafeUrl,
/// The absolute path to the distribution which we use for installing.
pub install_path: Box<Path>,
pub editable: bool,
pub r#virtual: bool,
/// Whether the project at the given URL should be installed in editable mode.
pub editable: Option<bool>,
/// Whether the project at the given URL should be treated as a virtual package.
pub r#virtual: Option<bool>,
}

impl ParsedDirectoryUrl {
/// Construct a [`ParsedDirectoryUrl`] from a path requirement source.
pub fn from_source(
install_path: Box<Path>,
editable: bool,
r#virtual: bool,
editable: Option<bool>,
r#virtual: Option<bool>,
url: DisplaySafeUrl,
) -> Self {
Self {
Expand Down Expand Up @@ -399,8 +404,8 @@ impl TryFrom<DisplaySafeUrl> for ParsedUrl {
Ok(Self::Directory(ParsedDirectoryUrl {
url,
install_path: path.into_boxed_path(),
editable: false,
r#virtual: false,
editable: None,
r#virtual: None,
}))
} else {
Ok(Self::Path(ParsedPathUrl {
Expand Down Expand Up @@ -445,7 +450,7 @@ impl From<&ParsedDirectoryUrl> for DirectUrl {
Self::LocalDirectory {
url: value.url.to_string(),
dir_info: DirInfo {
editable: value.editable.then_some(true),
editable: value.editable,
},
subdirectory: None,
}
Expand Down
6 changes: 4 additions & 2 deletions crates/uv-requirements-txt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,8 +2064,10 @@ mod test {
fragment: None,
},
install_path: "/foo/bar",
editable: true,
virtual: false,
editable: Some(
true,
),
virtual: None,
},
),
verbatim: VerbatimUrl {
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-requirements-txt/src/requirement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl RequirementsTxtRequirement {
version_or_url: Some(uv_pep508::VersionOrUrl::Url(VerbatimParsedUrl {
verbatim: url.verbatim,
parsed_url: ParsedUrl::Directory(ParsedDirectoryUrl {
editable: true,
editable: Some(true),
..parsed_url
}),
})),
Expand All @@ -115,7 +115,7 @@ impl RequirementsTxtRequirement {
url: VerbatimParsedUrl {
verbatim: requirement.url.verbatim,
parsed_url: ParsedUrl::Directory(ParsedDirectoryUrl {
editable: true,
editable: Some(true),
..parsed_url
}),
},
Expand Down
Loading
Loading