From eecba2253a35f685d929aaa8fe20e433eee3f5a8 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 24 Jul 2024 17:08:09 -0500 Subject: [PATCH] Prefer "lockfile" to "lock file" --- CHANGELOG.md | 2 +- STYLE.md | 4 ++++ crates/distribution-types/src/lib.rs | 6 +++--- crates/uv-python/src/environment.rs | 8 ++++---- crates/uv-resolver/src/lock.rs | 22 ++++++++++---------- crates/uv/src/commands/project/tree.rs | 2 +- crates/uv/tests/common/mod.rs | 2 +- crates/uv/tests/pip_compile.rs | 4 ++-- scripts/bench/__main__.py | 28 +++++++++++++------------- 9 files changed, 41 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5364c3d4ad24..105b9c8cd9e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1360,7 +1360,7 @@ pass the `--native-tls` command-line flag to enable this behavior. - Always remove color codes from output file ([#2018](https://github.com/astral-sh/uv/pull/2018)) - Support recursive extras in direct `pyproject.toml` files ([#1990](https://github.com/astral-sh/uv/pull/1990)) - Un-cache editable requirements with dynamic metadata ([#2029](https://github.com/astral-sh/uv/pull/2029)) -- Use a non-local lock file for locking system interpreters ([#2045](https://github.com/astral-sh/uv/pull/2045)) +- Use a non-local lockfile for locking system interpreters ([#2045](https://github.com/astral-sh/uv/pull/2045)) - Surface the `EXTERNALLY-MANAGED` message to users ([#2032](https://github.com/astral-sh/uv/pull/2032)) ## 0.1.11 diff --git a/STYLE.md b/STYLE.md index 696b92e7b941..0d68a4e777d1 100644 --- a/STYLE.md +++ b/STYLE.md @@ -21,6 +21,10 @@ Just uv, please. 1. Do not capitalize, e.g., "Uv", even at the beginning of a sentence. 1. Do not uppercase, e.g., "UV", unless referring to an environment variable, e.g., `UV_PYTHON`. +## Terminology + +1. Use "lockfile" not "lock file". + ## Documentation 1. Use periods at the end of all sentences, including lists unless they enumerate single items. diff --git a/crates/distribution-types/src/lib.rs b/crates/distribution-types/src/lib.rs index 36706b1f0518..dbcdff606ee1 100644 --- a/crates/distribution-types/src/lib.rs +++ b/crates/distribution-types/src/lib.rs @@ -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, } diff --git a/crates/uv-python/src/environment.rs b/crates/uv-python/src/environment.rs index 661c117b5f2f..08618535bbd9 100644 --- a/crates/uv-python/src/environment.rs +++ b/crates/uv-python/src/environment.rs @@ -186,16 +186,16 @@ impl PythonEnvironment { /// Grab a file lock for the environment to prevent concurrent writes across processes. pub fn lock(&self) -> Result { 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(), diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index cb512cbdc287..01e2e07b22b9 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -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, } @@ -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 { // We construct a TOML document manually instead of going through Serde to enable // the use of inline tables. @@ -1302,7 +1302,7 @@ impl From 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 { 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 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 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" )] diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index 601761ea7aa8..6bbc6a5ea9df 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -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, diff --git a/crates/uv/tests/common/mod.rs b/crates/uv/tests/common/mod.rs index c539e5f987c9..cfab294de4f6 100644 --- a/crates/uv/tests/common/mod.rs +++ b/crates/uv/tests/common/mod.rs @@ -877,7 +877,7 @@ pub fn run_and_format>( // 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"), diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 1eb487dac02b..3b5eb94a1879 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -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()?) diff --git a/scripts/bench/__main__.py b/scripts/bench/__main__.py index ac46434bf7ea..2449b7cb85e6 100644 --- a/scripts/bench/__main__.py +++ b/scripts/bench/__main__.py @@ -181,7 +181,7 @@ def command( def resolve_cold(self, requirements_file: str, *, cwd: str) -> Command | None: """Resolve a set of dependencies using pip-tools, from a cold cache. - The resolution is performed from scratch, i.e., without an existing lock file, + The resolution is performed from scratch, i.e., without an existing lockfile, and the cache directory is cleared between runs. """ @@ -189,7 +189,7 @@ def resolve_cold(self, requirements_file: str, *, cwd: str) -> Command | None: def resolve_warm(self, requirements_file: str, *, cwd: str) -> Command | None: """Resolve a set of dependencies using pip-tools, from a warm cache. - The resolution is performed from scratch, i.e., without an existing lock file; + The resolution is performed from scratch, i.e., without an existing lockfile; however, the cache directory is _not_ cleared between runs. """ @@ -199,9 +199,9 @@ def resolve_incremental( ) -> Command | None: """Resolve a modified lockfile using pip-tools, from a warm cache. - The resolution is performed with an existing lock file, and the cache directory + The resolution is performed with an existing lockfile, and the cache directory is _not_ cleared between runs. However, a new dependency is added to the set - of input requirements, which does not appear in the lock file. + of input requirements, which does not appear in the lockfile. """ @abc.abstractmethod @@ -267,7 +267,7 @@ def resolve_incremental( cache_dir = os.path.join(cwd, ".cache") baseline = os.path.join(cwd, "baseline.txt") - # First, perform a cold resolution, to ensure that the lock file exists. + # First, perform a cold resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [ @@ -473,7 +473,7 @@ def resolve_incremental( poetry_lock ), f"Lock file already exists at: {poetry_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [self.path, "lock"], @@ -497,7 +497,7 @@ def resolve_incremental( with open(os.path.join(cwd, "pyproject.toml"), "wb") as fp: tomli_w.dump(pyproject, fp) - # Store the baseline lock file. + # Store the baseline lockfile. baseline = os.path.join(cwd, "baseline.lock") shutil.copyfile(poetry_lock, baseline) @@ -529,7 +529,7 @@ def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None: poetry_lock ), f"Lock file already exists at: {poetry_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [self.path, "lock"], @@ -574,7 +574,7 @@ def install_warm(self, requirements_file: str, *, cwd: str) -> Command | None: poetry_lock ), f"Lock file already exists at: {poetry_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. subprocess.check_call( [self.path, "lock"], cwd=cwd, @@ -690,7 +690,7 @@ def resolve_incremental( pdm_lock = os.path.join(cwd, "pdm.lock") assert not os.path.exists(pdm_lock), f"Lock file already exists at: {pdm_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [self.path, "lock"], @@ -710,7 +710,7 @@ def resolve_incremental( with open(os.path.join(cwd, "pyproject.toml"), "wb") as fp: tomli_w.dump(pyproject, fp) - # Store the baseline lock file. + # Store the baseline lockfile. baseline = os.path.join(cwd, "baseline.lock") shutil.copyfile(pdm_lock, baseline) @@ -735,7 +735,7 @@ def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None: pdm_lock = os.path.join(cwd, "pdm.lock") assert not os.path.exists(pdm_lock), f"Lock file already exists at: {pdm_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [self.path, "lock"], @@ -770,7 +770,7 @@ def install_warm(self, requirements_file: str, *, cwd: str) -> Command | None: pdm_lock = os.path.join(cwd, "pdm.lock") assert not os.path.exists(pdm_lock), f"Lock file already exists at: {pdm_lock}" - # Run a resolution, to ensure that the lock file exists. + # Run a resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [self.path, "lock"], @@ -856,7 +856,7 @@ def resolve_incremental( cache_dir = os.path.join(cwd, ".cache") baseline = os.path.join(cwd, "baseline.txt") - # First, perform a cold resolution, to ensure that the lock file exists. + # First, perform a cold resolution, to ensure that the lockfile exists. # TODO(charlie): Make this a `setup`. subprocess.check_call( [