Prefer "lockfile" to "lock file" (#5427)

Closes https://github.com/astral-sh/uv/issues/5415
This commit is contained in:
Zanie Blue 2024-07-25 10:22:36 -04:00 committed by GitHub
parent d0919329fd
commit 42e76e2545
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 41 additions and 37 deletions

View file

@ -223,9 +223,9 @@ pub struct RegistrySourceDist {
/// available wheels too. There are many reasons why a wheel might not
/// have been chosen (maybe none available are compatible with the
/// current environment), but we still want to track that they exist. In
/// particular, for generating a universal lock file, we do not want to
/// skip emitting wheels to the lock file just because the host generating
/// the lock file didn't have any compatible wheels available.
/// particular, for generating a universal lockfile, we do not want to
/// skip emitting wheels to the lockfile just because the host generating
/// the lockfile didn't have any compatible wheels available.
pub wheels: Vec<RegistryBuiltWheel>,
}

View file

@ -186,16 +186,16 @@ impl PythonEnvironment {
/// Grab a file lock for the environment to prevent concurrent writes across processes.
pub fn lock(&self) -> Result<LockedFile, std::io::Error> {
if let Some(target) = self.0.interpreter.target() {
// If we're installing into a `--target`, use a target-specific lock file.
// If we're installing into a `--target`, use a target-specific lockfile.
LockedFile::acquire(target.root().join(".lock"), target.root().user_display())
} else if let Some(prefix) = self.0.interpreter.prefix() {
// Likewise, if we're installing into a `--prefix`, use a prefix-specific lock file.
// Likewise, if we're installing into a `--prefix`, use a prefix-specific lockfile.
LockedFile::acquire(prefix.root().join(".lock"), prefix.root().user_display())
} else if self.0.interpreter.is_virtualenv() {
// If the environment a virtualenv, use a virtualenv-specific lock file.
// If the environment a virtualenv, use a virtualenv-specific lockfile.
LockedFile::acquire(self.0.root.join(".lock"), self.0.root.user_display())
} else {
// Otherwise, use a global lock file.
// Otherwise, use a global lockfile.
LockedFile::acquire(
env::temp_dir().join(format!("uv-{}.lock", cache_key::digest(&self.0.root))),
self.0.root.user_display(),

View file

@ -46,7 +46,7 @@ use crate::{
ResolutionMode, VersionMap, VersionsResponse,
};
/// The current version of the lock file format.
/// The current version of the lockfile format.
const VERSION: u32 = 1;
#[derive(Clone, Debug, serde::Deserialize, PartialEq, Eq)]
@ -72,7 +72,7 @@ pub struct Lock {
/// It is guaranteed that every distribution in this lock has an entry in
/// this map, and that every dependency for every distribution has an ID
/// that exists in this map. That is, there are no dependencies that don't
/// have a corresponding locked distribution entry in the same lock file.
/// have a corresponding locked distribution entry in the same lockfile.
by_id: FxHashMap<DistributionId, usize>,
}
@ -441,7 +441,7 @@ impl Lock {
Ok(Resolution::new(map, hashes, diagnostics))
}
/// Returns the TOML representation of this lock file.
/// Returns the TOML representation of this lockfile.
pub fn to_toml(&self) -> anyhow::Result<String> {
// We construct a TOML document manually instead of going through Serde to enable
// the use of inline tables.
@ -1302,7 +1302,7 @@ impl From<DistributionId> for DistributionIdForDependency {
///
/// NOTE: Care should be taken when adding variants to this enum. Namely, new
/// variants should be added without changing the relative ordering of other
/// variants. Otherwise, this could cause the lock file to have a different
/// variants. Otherwise, this could cause the lockfile to have a different
/// canonical ordering of distributions.
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, serde::Deserialize)]
#[serde(try_from = "SourceWire")]
@ -1318,7 +1318,7 @@ enum Source {
/// A [`PathBuf`], but we show `.` instead of an empty path.
///
/// We also normalize backslashes to forward slashes on Windows, to ensure
/// that the lock file contains portable paths.
/// that the lockfile contains portable paths.
fn serialize_path_with_dot(path: &Path) -> Cow<str> {
let path = path.to_slash_lossy();
if path.is_empty() {
@ -1593,7 +1593,7 @@ struct DirectSource {
/// NOTE: Care should be taken when adding variants to this enum. Namely, new
/// variants should be added without changing the relative ordering of other
/// variants. Otherwise, this could cause the lock file to have a different
/// variants. Otherwise, this could cause the lockfile to have a different
/// canonical ordering of distributions.
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
struct GitSource {
@ -1788,7 +1788,7 @@ impl SourceDist {
distribution_types::SourceDist::DirectUrl(ref direct_dist) => {
SourceDist::from_direct_dist(id, direct_dist, hashes).map(Some)
}
// An actual sdist entry in the lock file is only required when
// An actual sdist entry in the lockfile is only required when
// it's from a registry or a direct URL. Otherwise, it's strictly
// redundant with the information in all other kinds of `source`.
distribution_types::SourceDist::Git(_)
@ -2092,7 +2092,7 @@ impl TryFrom<WheelWire> for Wheel {
}
}
/// A single dependency of a distribution in a lock file.
/// A single dependency of a distribution in a lockfile.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
struct Dependency {
distribution_id: DistributionId,
@ -2232,7 +2232,7 @@ impl std::fmt::Display for Dependency {
}
}
/// A single dependency of a distribution in a lock file.
/// A single dependency of a distribution in a lockfile.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, serde::Deserialize)]
struct DependencyWire {
#[serde(flatten)]
@ -2265,7 +2265,7 @@ impl From<Dependency> for DependencyWire {
}
}
/// A single hash for a distribution artifact in a lock file.
/// A single hash for a distribution artifact in a lockfile.
///
/// A hash is encoded as a single TOML string in the format
/// `{algorithm}:{digest}`.
@ -2394,7 +2394,7 @@ enum LockErrorKind {
),
/// An error that occurs when there's an unrecognized dependency.
///
/// That is, a dependency for a distribution that isn't in the lock file.
/// That is, a dependency for a distribution that isn't in the lockfile.
#[error(
"for distribution `{id}`, found dependency `{dependency}` with no locked distribution"
)]

View file

@ -64,7 +64,7 @@ pub(crate) async fn tree(
.await?
.into_interpreter();
// Update the lock file, if necessary.
// Update the lockfile, if necessary.
let lock = project::lock::do_safe_lock(
locked,
frozen,

View file

@ -877,7 +877,7 @@ pub fn run_and_format<T: AsRef<str>>(
// cause the set of dependencies to be the same across platforms.
if cfg!(windows) {
if let Some(windows_filters) = windows_filters {
// The optional leading +/- is for install logs, the optional next line is for lock files
// The optional leading +/- is for install logs, the optional next line is for lockfiles
let windows_only_deps = [
("( [+-] )?colorama==\\d+(\\.[\\d+])+\n( # via .*\n)?"),
("( [+-] )?colorama==\\d+(\\.[\\d+])+(\\s+# via .*)?\n"),

View file

@ -9747,7 +9747,7 @@ fn local_version_of_remote_package() -> Result<()> {
Resolved 3 packages in [TIME]
"###);
// Write a lock file with the local version
// Write a lockfile with the local version
let requirements_txt = context.temp_dir.child("requirements.txt");
requirements_txt.write_str(&indoc::formatdoc! {r"
anyio @ {workspace_root}/scripts/packages/anyio_local
@ -9757,7 +9757,7 @@ fn local_version_of_remote_package() -> Result<()> {
// The local version is _still_ excluded from the resolution
// `uv pip compile` does not have access to an environment and cannot consider installed packages
// We may want to allow the lock file to be preserved in this case in the future, but right now
// We may want to allow the lockfile to be preserved in this case in the future, but right now
// we require the URL to always be in the input file.
uv_snapshot!(context.filters(), context.pip_compile()
.arg(requirements_in.canonicalize()?)