uv/crates/uv-python/src
konsti bf96c60e3e
Lock during uv sync, uv add and uv remove to avoid race conditions (#13869)
Surprisingly, we weren't locking during `uv sync` so far, so running `uv
sync` in parallel could cause errors in filesystem races.

I've also added locks to `uv add` and `uv remove` which concurrently
modify `pyproject.toml`. These locks only apply after we determined the
interpreter, so they don't actually prevent computing the same thing
twice when running `uv add` in parallel.

All other subcommands that I checked were already locking (with no claim
to exhaustiveness)

Fixes #12751

# Test Plan

I don't have CI-sized reproducer for this.

```toml
[project]
name = "debug"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
  "boto3>=1.38.30",
  "fastapi>=0.115.12",
  "numba>=0.61.2",
  "polars>=1.30.0",
  "protobuf>=6.31.1",
  "pyarrow>=20.0.0",
  "pydantic>=2.11.5",
  "requests>=2.32.3",
  "urllib3>=2.4.0",
  "scikit-learn>=1.6.1",
  "jupyter>=1.1.1",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
```

```
rm -rf .venv && parallel -n0 "uv sync -q" ::: {1..10}
```
2025-06-06 14:16:40 +02:00
..
sysconfig Update tag for Python sysconfig metadata (#13851) 2025-06-05 11:21:35 -05:00
cpuinfo.rs Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
discovery.rs allow running non-default Python interpreters directly via uvx (#13583) 2025-05-30 09:12:39 -07:00
downloads.rs Update Rust crate tempfile to v3.20.0 (#13776) 2025-06-02 07:47:08 +00:00
environment.rs Lock during uv sync, uv add and uv remove to avoid race conditions (#13869) 2025-06-06 14:16:40 +02:00
implementation.rs Prefer Python executable names that match the request over default names (#9066) 2024-11-13 10:00:23 -06:00
installation.rs Implement ordering for Python architectures to prefer native installations (#13709) 2025-05-29 19:06:33 +00:00
interpreter.rs Lock during uv sync, uv add and uv remove to avoid race conditions (#13869) 2025-06-06 14:16:40 +02:00
lib.rs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
libc.rs make the error message clearer when running distroless containers (#13549) 2025-05-29 10:29:01 -07:00
macos_dylib.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
managed.rs make the error message clearer when running distroless containers (#13549) 2025-05-29 10:29:01 -07:00
microsoft_store.rs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
platform.rs Add Pyodide support (#12731) 2025-06-03 12:01:26 -05:00
pointer_size.rs Change "toolchain" to "python" (#4735) 2024-07-03 07:44:29 -05:00
prefix.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
python_version.rs Report Python versions in pyvenv.cfg version mismatch (#13027) 2025-04-25 18:06:46 +00:00
target.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
version_files.rs Ignore arbitrary Python requests in version files (#12909) 2025-04-29 16:37:00 -05:00
virtualenv.rs Report Python versions in pyvenv.cfg version mismatch (#13027) 2025-04-25 18:06:46 +00:00
windows_registry.rs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00