Skip to content

Commit

Permalink
Remove lock path
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 23, 2024
1 parent c544000 commit 13d078f
Show file tree
Hide file tree
Showing 22 changed files with 234 additions and 325 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crates/distribution-types/src/buildable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ impl<'a> From<&'a PathSourceDist> for PathSourceUrl<'a> {
pub struct DirectorySourceUrl<'a> {
pub url: &'a Url,
pub install_path: Cow<'a, Path>,
pub lock_path: Cow<'a, Path>,
pub editable: bool,
}

Expand All @@ -187,7 +186,6 @@ impl<'a> From<&'a DirectorySourceDist> for DirectorySourceUrl<'a> {
Self {
url: &dist.url,
install_path: Cow::Borrowed(&dist.install_path),
lock_path: Cow::Borrowed(&dist.lock_path),
editable: dist.editable,
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/distribution-types/src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ impl CachedDist {
.map_err(|()| anyhow!("Invalid path in file URL"))?;
Ok(Some(ParsedUrl::Directory(ParsedDirectoryUrl {
url: dist.url.raw().clone(),
install_path: path.clone(),
lock_path: path,
install_path: path,
editable: dist.editable,
})))
} else {
Expand Down
28 changes: 3 additions & 25 deletions crates/distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ pub struct PathBuiltDist {
pub filename: WheelFilename,
/// The absolute, canonicalized path to the wheel which we use for installing.
pub install_path: PathBuf,
/// The absolute path or path relative to the workspace root pointing to the wheel
/// which we use for locking. Unlike `given` on the verbatim URL all environment variables
/// are resolved, and unlike the install path, we did not yet join it on the base directory.
pub lock_path: PathBuf,
/// The URL as it was provided by the user.
pub url: VerbatimUrl,
}
Expand Down Expand Up @@ -297,10 +293,6 @@ pub struct PathSourceDist {
pub name: PackageName,
/// The absolute, canonicalized path to the distribution which we use for installing.
pub install_path: PathBuf,
/// The absolute path or path relative to the workspace root pointing to the distribution
/// which we use for locking. Unlike `given` on the verbatim URL all environment variables
/// are resolved, and unlike the install path, we did not yet join it on the base directory.
pub lock_path: PathBuf,
/// The file extension, e.g. `tar.gz`, `zip`, etc.
pub ext: SourceDistExtension,
/// The URL as it was provided by the user.
Expand All @@ -313,10 +305,6 @@ pub struct DirectorySourceDist {
pub name: PackageName,
/// The absolute, canonicalized path to the distribution which we use for installing.
pub install_path: PathBuf,
/// The absolute path or path relative to the workspace root pointing to the distribution
/// which we use for locking. Unlike `given` on the verbatim URL all environment variables
/// are resolved, and unlike the install path, we did not yet join it on the base directory.
pub lock_path: PathBuf,
/// Whether the package should be installed in editable mode.
pub editable: bool,
/// The URL as it was provided by the user.
Expand Down Expand Up @@ -368,7 +356,6 @@ impl Dist {
name: PackageName,
url: VerbatimUrl,
install_path: &Path,
lock_path: &Path,
ext: DistExtension,
) -> Result<Dist, Error> {
// Store the canonicalized path, which also serves to validate that it exists.
Expand All @@ -395,14 +382,12 @@ impl Dist {
Ok(Self::Built(BuiltDist::Path(PathBuiltDist {
filename,
install_path,
lock_path: lock_path.to_path_buf(),
url,
})))
}
DistExtension::Source(ext) => Ok(Self::Source(SourceDist::Path(PathSourceDist {
name,
install_path,
lock_path: lock_path.to_path_buf(),
ext,
url,
}))),
Expand All @@ -414,7 +399,6 @@ impl Dist {
name: PackageName,
url: VerbatimUrl,
install_path: &Path,
lock_path: &Path,
editable: bool,
) -> Result<Dist, Error> {
// Store the canonicalized path, which also serves to validate that it exists.
Expand All @@ -430,7 +414,6 @@ impl Dist {
Ok(Self::Source(SourceDist::Directory(DirectorySourceDist {
name,
install_path,
lock_path: lock_path.to_path_buf(),
editable,
url,
})))
Expand Down Expand Up @@ -461,18 +444,13 @@ impl Dist {
archive.subdirectory,
archive.ext,
),
ParsedUrl::Path(file) => Self::from_file_url(
name,
url.verbatim,
&file.install_path,
&file.lock_path,
file.ext,
),
ParsedUrl::Path(file) => {
Self::from_file_url(name, url.verbatim, &file.install_path, file.ext)
}
ParsedUrl::Directory(directory) => Self::from_directory_url(
name,
url.verbatim,
&directory.install_path,
&directory.lock_path,
directory.editable,
),
ParsedUrl::Git(git) => {
Expand Down
3 changes: 0 additions & 3 deletions crates/distribution-types/src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl From<&ResolvedDist> for Requirement {
}
Dist::Built(BuiltDist::Path(wheel)) => RequirementSource::Path {
install_path: wheel.install_path.clone(),
lock_path: wheel.lock_path.clone(),
url: wheel.url.clone(),
ext: DistExtension::Wheel,
},
Expand Down Expand Up @@ -191,13 +190,11 @@ impl From<&ResolvedDist> for Requirement {
},
Dist::Source(SourceDist::Path(sdist)) => RequirementSource::Path {
install_path: sdist.install_path.clone(),
lock_path: sdist.lock_path.clone(),
url: sdist.url.clone(),
ext: DistExtension::Source(sdist.ext),
},
Dist::Source(SourceDist::Directory(sdist)) => RequirementSource::Directory {
install_path: sdist.install_path.clone(),
lock_path: sdist.lock_path.clone(),
url: sdist.url.clone(),
editable: sdist.editable,
},
Expand Down
30 changes: 2 additions & 28 deletions crates/pypi-types/src/parsed_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ impl UnnamedRequirementUrl for VerbatimParsedUrl {
ParsedUrl::Directory(ParsedDirectoryUrl {
url: verbatim.to_url(),
install_path: verbatim.as_path()?,
lock_path: path.as_ref().to_path_buf(),
editable: false,
})
} else {
ParsedUrl::Path(ParsedPathUrl {
url: verbatim.to_url(),
install_path: verbatim.as_path()?,
lock_path: path.as_ref().to_path_buf(),
ext: DistExtension::from_path(&path).map_err(|err| {
ParsedUrlError::MissingExtensionPath(path.as_ref().to_path_buf(), err)
})?,
Expand All @@ -102,14 +100,12 @@ impl UnnamedRequirementUrl for VerbatimParsedUrl {
ParsedUrl::Directory(ParsedDirectoryUrl {
url: verbatim.to_url(),
install_path: verbatim.as_path()?,
lock_path: path.as_ref().to_path_buf(),
editable: false,
})
} else {
ParsedUrl::Path(ParsedPathUrl {
url: verbatim.to_url(),
install_path: verbatim.as_path()?,
lock_path: path.as_ref().to_path_buf(),
ext: DistExtension::from_path(&path).map_err(|err| {
ParsedUrlError::MissingExtensionPath(path.as_ref().to_path_buf(), err)
})?,
Expand Down Expand Up @@ -187,26 +183,16 @@ pub struct ParsedPathUrl {
pub url: Url,
/// The absolute, canonicalized path to the distribution which we use for installing.
pub install_path: PathBuf,
/// The absolute path or path relative to the workspace root pointing to the distribution
/// which we use for locking. Unlike `given` on the verbatim URL all environment variables
/// are resolved, and unlike the install path, we did not yet join it on the base directory.
pub lock_path: PathBuf,
/// The file extension, e.g. `tar.gz`, `zip`, etc.
pub ext: DistExtension,
}

impl ParsedPathUrl {
/// Construct a [`ParsedPathUrl`] from a path requirement source.
pub fn from_source(
install_path: PathBuf,
lock_path: PathBuf,
ext: DistExtension,
url: Url,
) -> Self {
pub fn from_source(install_path: PathBuf, ext: DistExtension, url: Url) -> Self {
Self {
url,
install_path,
lock_path,
ext,
}
}
Expand All @@ -221,25 +207,15 @@ pub struct ParsedDirectoryUrl {
pub url: Url,
/// The absolute, canonicalized path to the distribution which we use for installing.
pub install_path: PathBuf,
/// The absolute path or path relative to the workspace root pointing to the distribution
/// which we use for locking. Unlike `given` on the verbatim URL all environment variables
/// are resolved, and unlike the install path, we did not yet join it on the base directory.
pub lock_path: PathBuf,
pub editable: bool,
}

impl ParsedDirectoryUrl {
/// Construct a [`ParsedDirectoryUrl`] from a path requirement source.
pub fn from_source(
install_path: PathBuf,
lock_path: PathBuf,
editable: bool,
url: Url,
) -> Self {
pub fn from_source(install_path: PathBuf, editable: bool, url: Url) -> Self {
Self {
url,
install_path,
lock_path,
editable,
}
}
Expand Down Expand Up @@ -393,7 +369,6 @@ impl TryFrom<Url> for ParsedUrl {
Ok(Self::Directory(ParsedDirectoryUrl {
url,
install_path: path.clone(),
lock_path: path,
editable: false,
}))
} else {
Expand All @@ -402,7 +377,6 @@ impl TryFrom<Url> for ParsedUrl {
ext: DistExtension::from_path(&path)
.map_err(|err| ParsedUrlError::MissingExtensionPath(path.clone(), err))?,
install_path: path.clone(),
lock_path: path,
}))
}
} else {
Expand Down
Loading

0 comments on commit 13d078f

Please sign in to comment.