Skip to content

Commit

Permalink
Prefer "lockfile" to "lock file" (#5427)
Browse files Browse the repository at this point in the history
Closes #5415
  • Loading branch information
zanieb committed Jul 25, 2024
1 parent d091932 commit 42e76e2
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,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
Expand Down
4 changes: 4 additions & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions crates/distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/uv-python/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
22 changes: 11 additions & 11 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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>,
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")]
Expand All @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(_)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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}`.
Expand Down Expand Up @@ -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"
)]
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/src/commands/project/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()?)
Expand Down
28 changes: 14 additions & 14 deletions scripts/bench/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ 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.
"""

@abc.abstractmethod
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.
"""

Expand All @@ -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
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -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"],
Expand All @@ -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)

Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"],
Expand All @@ -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)

Expand All @@ -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"],
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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(
[
Expand Down

0 comments on commit 42e76e2

Please sign in to comment.