uv/crates
konsti 5051b2c004
Use tempfile to prevent install io race crashes (#929)
On ubuntu and python 3.10,

```
cargo run -q -- pip-install --find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html "jax[cuda12_pip]==0.4.23"
```

non-deterministically but for me consistently fails to install with
messages such as

```
error: Failed to install: nvidia_nccl_cu12-2.19.3-py3-none-manylinux1_x86_64.whl (nvidia-nccl-cu12==2.19.3)
  Caused by: failed to remove file `/home/konsti/projects/puffin/.venv/lib/python3.10/site-packages/nvidia/__init__.py`
  Caused by: No such file or directory (os error 2)
```

```
error: Failed to install: nvidia_cublas_cu12-12.3.4.1-py3-none-manylinux1_x86_64.whl (nvidia-cublas-cu12==12.3.4.1)
  Caused by: Replacing an existing file or directory failed
```

```
error: Failed to install: nvidia_cuda_nvcc_cu12-12.3.107-py3-none-manylinux1_x86_64.whl (nvidia-cuda-nvcc-cu12==12.3.107)
  Caused by: failed to hardlink file from /home/konsti/.cache/puffin/wheels-v0/pypi/nvidia-cuda-nvcc-cu12/nvidia_cuda_nvcc_cu12-12.3.107-py3-none-manylinux1_x86_64/nvidia/__init__.py to /home/konsti/projects/puffin/.venv/lib/python3.10/site-packages/nvidia/__init__.py
  Caused by: File exists (os error 17)
```

We install a lot of nvidia package, that all contain
`nvidia/__init__.py`, since they all install themselves into the
`nvidia` module:

```
nvidia-cublas-cu12==12.3.4.1
nvidia-cuda-cupti-cu12==12.3.101
nvidia-cuda-nvcc-cu12==12.3.107
nvidia-cuda-nvrtc-cu12==12.3.107
nvidia-cuda-runtime-cu12==12.3.101
nvidia-cudnn-cu12==8.9.7.29
nvidia-cufft-cu12==11.0.12.1
nvidia-cusolver-cu12==11.5.4.101
nvidia-cusparse-cu12==12.2.0.103
nvidia-nccl-cu12==2.19.3
nvidia-nvjitlink-cu12==12.3.101
```

```
$  tree -L 1 .venv/lib/python3.10/site-packages/nvidia
.venv/lib/python3.10/site-packages/nvidia
├── cublas
├── cuda_cupti
├── cuda_nvcc
├── cuda_nvrtc
├── cuda_runtime
├── cudnn
├── cufft
├── cusolver
├── cusparse
├── __init__.py
├── nccl
└── nvjitlink
```

When installing we get a race condition, each package installation is
its own thread:
* Installer Thread 1 creates `nvidia/__init__.py`
* Installer Thread 2 sees an existing  `nvidia/__init__.py`
* Installer Thread 3 sees an existing  `nvidia/__init__.py`
* Installer Thread 2 removes `nvidia/__init__.py`
* Installer Thread 3 tries to remove `nvidia/__init__.py`, it doesn't
exist anymore -> failure.

We switch to a new strategy: When the target files exists, we don't
remove it, but instead hardlink the source file to a tempfile first,
then renaming the tempfile to the target file. Renaming is considered an
atomic operation.

I've put the logging on debug level because they cases indicate a
conflict between two packages while being rare.

Closes #925

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-01-16 21:07:39 +00:00
..
bench Use Clippy lint table over Cargo config (#490) 2023-11-22 15:10:27 +00:00
cache-key Split puffin-cache into Puffin-specific and generic utilities (#728) 2023-12-25 14:38:56 +00:00
distribution-filename Implement --find-links as flat indexes (directories in pip-compile) (#912) 2024-01-15 02:04:10 +00:00
distribution-types Move Puffin subcommands to a pip namespace (#921) 2024-01-15 16:36:45 +00:00
gourgeist Cleanup deps and docs (#882) 2024-01-11 10:43:40 +00:00
install-wheel-rs Use tempfile to prevent install io race crashes (#929) 2024-01-16 21:07:39 +00:00
pep440-rs Remove PubGrubVersion (#924) 2024-01-15 08:51:12 -05:00
pep508-rs Implement --find-links as flat indexes (directories in pip-compile) (#912) 2024-01-15 02:04:10 +00:00
platform-host Error when ldd is not in path (#506) 2023-11-28 05:55:04 +00:00
platform-tags Cache Tags on Interpreter (#726) 2023-12-25 13:41:10 +00:00
puffin-build Default to PEP 517-based builds (#843) 2024-01-10 01:27:06 +00:00
puffin-cache Move Puffin subcommands to a pip namespace (#921) 2024-01-15 16:36:45 +00:00
puffin-cli Share a single Index across resolutions (#906) 2024-01-16 05:37:15 +00:00
puffin-client Fetch --find-links indexes in parallel (#934) 2024-01-16 11:37:35 +01:00
puffin-dev Share a single Index across resolutions (#906) 2024-01-16 05:37:15 +00:00
puffin-dispatch Share a single Index across resolutions (#906) 2024-01-16 05:37:15 +00:00
puffin-distribution Remove clone from RegistryWheelIndex (#937) 2024-01-15 16:18:12 -05:00
puffin-extract Use fs_err in more places (#926) 2024-01-15 09:39:33 +00:00
puffin-fs Show resource and lockfile when waiting (#715) 2023-12-21 00:05:49 +01:00
puffin-git Split puffin-cache into Puffin-specific and generic utilities (#728) 2023-12-25 14:38:56 +00:00
puffin-installer Share in-flight map across resolutions (#932) 2024-01-15 13:11:22 -05:00
puffin-interpreter Adjust markers to match target Python version (#909) 2024-01-14 15:39:15 +00:00
puffin-normalize Avoid some additional clones for PackageName (#896) 2024-01-12 17:54:40 +00:00
puffin-resolver Share a single Index across resolutions (#906) 2024-01-16 05:37:15 +00:00
puffin-traits Share in-flight map across resolutions (#932) 2024-01-15 13:11:22 -05:00
puffin-warnings Migrate back to owo-colors (#824) 2024-01-08 08:54:57 +00:00
puffin-workspace Use Clippy lint table over Cargo config (#490) 2023-11-22 15:10:27 +00:00
pypi-types Make hashes optional (#910) 2024-01-14 16:32:55 -05:00
requirements-txt Update dependencies (#794) 2024-01-05 11:40:12 -05:00
README.md Split puffin-cache into Puffin-specific and generic utilities (#728) 2023-12-25 14:38:56 +00:00

Crates

bench

Functionality for benchmarking Puffin.

cache-key

Generic functionality for caching paths, URLs, and other resources across platforms.

distribution-filename

Parse built distribution (wheel) and source distribution (sdist) filenames to extract structured metadata.

distribution-types

Abstractions for representing built distributions (wheels) and source distributions (sdists), and the sources from which they can be downloaded.

gourgeist

A venv replacement to create virtual environments in Rust.

install-wheel-rs

Install built distributions (wheels) into a virtual environment.]

pep440-rs

Utilities for interacting with Python version numbers and specifiers.

pep508-rs

Utilities for interacting with PEP 508 dependency specifiers.

platform-host

Functionality for detecting the current platform (operating system, architecture, etc.).

platform-tags

Functionality for parsing and inferring Python platform tags as per PEP 425.

puffin-build

A PEP 517-compatible build frontend for Puffin.

puffin-cache

Functionality for caching Python packages and associated metadata.

puffin-cli

Command-line interface for the Puffin package manager.

puffin-client

Client for interacting with PyPI-compatible HTTP APIs.

puffin-dev

Development utilities for Puffin.

puffin-dispatch

A centralized struct for resolving and building source distributions in isolated environments. Implements the traits defined in puffin-traits.

puffin-distribution

Client for interacting with built distributions (wheels) and source distributions (sdists). Capable of fetching metadata, distribution contents, etc.

puffin-extract

Utilities for extracting files from archives.

puffin-fs

Utilities for interacting with the filesystem.

puffin-git

Functionality for interacting with Git repositories.

puffin-installer

Functionality for installing Python packages into a virtual environment.

puffin-interpreter

Functionality for detecting and leveraging the current Python interpreter.

puffin-normalize

Normalize package and extra names as per Python specifications.

puffin-package

Types and functionality for working with Python packages, e.g., parsing wheel files.

puffin-resolver

Functionality for resolving Python packages and their dependencies.

puffin-traits

Shared traits for Puffin, to avoid circular dependencies.

pypi-types

General-purpose type definitions for types used in PyPI-compatible APIs.

puffin-warnings

User-facing warnings for Puffin.

requirements-txt

Functionality for parsing requirements.txt files.