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
9 changed files with 41 additions and 37 deletions
+1 -1
View File
@@ -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
+4
View File
@@ -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.
+3 -3
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>,
}
+4 -4
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(),
+11 -11
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"
)]
+1 -1
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,
+1 -1
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"),
+2 -2
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()?)
+14 -14
View File
@@ -181,7 +181,7 @@ class Suite(abc.ABC):
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 @@ class Suite(abc.ABC):
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 @@ class Suite(abc.ABC):
) -> 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 @@ class PipCompile(Suite):
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 @@ class Poetry(Suite):
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 @@ class Poetry(Suite):
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 @@ class Poetry(Suite):
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 @@ class Poetry(Suite):
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 @@ class Pdm(Suite):
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 @@ class Pdm(Suite):
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 @@ class Pdm(Suite):
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 @@ class Pdm(Suite):
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 @@ class uv(Suite):
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(
[