uv/crates
Ilan Godik b1e4bc779c
[uv-settings]: Correct behavior for relative find-links paths when run from a subdir (#10827)
## One-liner
Relative find-links configuration to local path from a pyproject.toml or
uv.toml is now relative to the config file
## Summary
### Background
One can configure find-links in a `pyproject.toml` or `uv.toml` file,
which are located from the cli arg, system directory, user directory, or
by traversing parent directories until one is encountered.

This PR addresses the following scenario:
- A project directory which includes a `pyproject.toml` or `uv.toml`
file
- The config file includes a `find-links` option. (eg under `[tool.uv]`
for `pyproject.toml`)
- The `find-links` option is configured to point to a local subdirectory
in the project: `packages/`
- There is a subdirectory called `subdir`, which is the current working
directory
- I run `uv run my_script.py`. This will locate the `pyproject.toml` in
the parent directory
### Current Behavior
- uv tries to use the path `subdir/packages/` to find packages, and
fails.
### New Behavior
- uv tries to use the path `packages/` to find the packages, and
succeeds
- Specifically, any relative local find-links path will resolve to be
relative to the configuration file.

### Why is this behavior change OK?
- I believe no one depends on the behavior that a relative find-links
when running in a subdir will refer to different directories each time
- Thus this change only allows a more common use case which didn't work
previously.

## Test Plan
- I re-created the setup mentioned above:
```
UvTest/
├── packages/
│   ├── colorama-0.4.6-py2.py3-none-any.whl
│   └── tqdm-4.67.1-py3-none-any.whl
├── subdir/
│   └── my_script.py
└── pyproject.toml
```
```toml 
# pyproject.toml
[project]
name = "uvtest"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "tqdm>=4.67.1",
]

[tool.uv]
offline = true
no-index = true
find-links = ["packages/"]
```
- With working directory under `subdir`, previously, running `uv sync
--offline` would fail resolving the tdqm package, and after the change
it succeeds.
- Additionally, one can use `uv sync --show-settings` to show the
actually-resolved settings - now having the desired path in
`flat_index.url.path`

## Alternative designs considered
- I considered modifying the `impl Deserialize for IndexUrl` to parse
ahead of time directly with a base directory by having a custom
`Deserializer` with a base dir field, but it seems to contradict the
design of the serde `Deserialize` trait - which should work with all
`Deserializer`s

## Future work
- Support for adjusting all other local-relative paths in `Options`
would be desired, but is out of scope for the current PR.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-01-22 19:44:35 +00:00
..
uv [uv-settings]: Correct behavior for relative find-links paths when run from a subdir (#10827) 2025-01-22 19:44:35 +00:00
uv-auth Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-bench Use structured wheel tags everywhere (#10542) 2025-01-14 01:39:39 +00:00
uv-build-backend Reduce WheelFilename to 48 bytes (#10583) 2025-01-14 14:49:17 +00:00
uv-build-frontend Detect cyclic dependencies during builds (#10258) 2024-12-31 22:22:42 -05:00
uv-cache Use structured wheel tags everywhere (#10542) 2025-01-14 01:39:39 +00:00
uv-cache-info Fix git-tag cache-key reader in case of slashes (#10467) (#10500) 2025-01-11 21:30:46 -05:00
uv-cache-key Remove separate test files in favor of same-file mod tests (#9199) 2024-11-18 20:11:46 +00:00
uv-cli fix(cli): conflict --locked with --upgrade (#10836) 2025-01-21 21:10:19 -06:00
uv-client Remove trailing commas before brackets (#10740) 2025-01-18 19:56:46 +00:00
uv-configuration feat: add --no-default-groups flag (#10618) 2025-01-21 18:03:17 -05:00
uv-console Support interactive input in uv publish (#8158) 2024-10-15 10:00:43 +02:00
uv-dev Shrink Dist from 352 to 288 bytes (#10389) 2025-01-08 09:33:19 -05:00
uv-dirs Eliminate dependencies on directores and dirs-sys (#8048) 2024-11-07 14:29:54 -06:00
uv-dispatch Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-distribution Invalidate lockfile when static versions change (#10858) 2025-01-22 17:58:15 +00:00
uv-distribution-filename Store unsupported tags in wheel filename (#10665) 2025-01-17 04:41:53 +00:00
uv-distribution-types [uv-settings]: Correct behavior for relative find-links paths when run from a subdir (#10827) 2025-01-22 19:44:35 +00:00
uv-extract Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-fs Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-git Remove the FullCommit variant from GitReference (#10803) 2025-01-21 19:26:58 +00:00
uv-globfilter Build backend: Revamp include/exclude (#9525) 2024-12-01 11:32:35 +00:00
uv-install-wheel Remove import re from entrypoint wrapper scripts (#10627) 2025-01-15 19:45:32 +01:00
uv-installer Include commit_id and requested_revision in direct_url.json (#10862) 2025-01-22 12:16:49 -05:00
uv-macros Remove unnecessary prefixes (#10158) 2024-12-25 14:18:01 -05:00
uv-metadata chore: Move all integration tests to a single binary (#8093) 2024-10-11 16:41:35 +02:00
uv-normalize Add a shared uv-small-str crate (#10545) 2025-01-12 20:23:18 +00:00
uv-once-map Use shared resolver state between add and lock (#8146) 2024-10-12 14:58:07 +00:00
uv-options-metadata Upgrade minimum Rust version to 1.83 (#9815) 2024-12-11 10:06:19 -06:00
uv-pep440 Remove trailing commas before brackets (#10740) 2025-01-18 19:56:46 +00:00
uv-pep508 Avoid deserialization error for paths above the root (#10789) 2025-01-20 16:36:18 -05:00
uv-performance-flate2-backend Re-enable zlib-ng on all platforms (except s390x, PowerPC, and FreeBSD) (#10370) 2025-01-07 13:04:34 -05:00
uv-performance-memory-allocator Run cargo update (#10173) 2024-12-26 12:00:58 -05:00
uv-platform-tags Store unsupported tags in wheel filename (#10665) 2025-01-17 04:41:53 +00:00
uv-publish Remove trailing commas before brackets (#10740) 2025-01-18 19:56:46 +00:00
uv-pypi-types Invalidate lockfile when static versions change (#10858) 2025-01-22 17:58:15 +00:00
uv-python fix(#10717): Omit stdout and stderr sections when empty in errors (#10746) 2025-01-21 21:45:29 +00:00
uv-requirements Extract extra-flattening routine from source tree resolver (#10820) 2025-01-21 19:52:55 +00:00
uv-requirements-txt Warn-and-ignore for unsupported requirements.txt options (#10420) 2025-01-09 13:19:51 -05:00
uv-resolver Invalidate lockfile when static versions change (#10858) 2025-01-22 17:58:15 +00:00
uv-scripts Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-settings [uv-settings]: Correct behavior for relative find-links paths when run from a subdir (#10827) 2025-01-22 19:44:35 +00:00
uv-shell Refactor shell quoting (#9055) 2024-11-15 09:06:54 +00:00
uv-small-str Add a shared uv-small-str crate (#10545) 2025-01-12 20:23:18 +00:00
uv-state Add uv-dirs to consolidate directory lookup methods (#8453) 2024-10-22 11:33:25 -05:00
uv-static Add UV_VENV_SEED environment variable (#10715) 2025-01-17 12:08:55 -05:00
uv-tool Guard against self-deletion in uv venv and uv tool (#10206) 2024-12-29 10:46:45 -05:00
uv-trampoline chore: update trampoline windows crate to 0.59.0 (#10524) 2025-01-14 08:54:19 -06:00
uv-trampoline-builder Upgrade Rust toolchain to 1.84.0 (#10533) 2025-01-11 22:19:33 -05:00
uv-types Avoid generating unused hashes during uv lock (#10307) 2025-01-06 00:58:07 +00:00
uv-version Bump version to v0.5.22 (#10829) 2025-01-21 17:03:55 -05:00
uv-virtualenv Revert "improve shell compatibility of venv activate scripts (#10397)" (#10497) 2025-01-11 09:23:07 -05:00
uv-warnings chore: Move all integration tests to a single binary (#8093) 2024-10-11 16:41:35 +02:00
uv-workspace Error when workspace contains conflicting Python requirements (#10841) 2025-01-22 17:22:52 +00:00
README.md Link to Dependency specifiers instead of PEP 508 (#8411) 2024-10-21 14:43:38 -04:00

Crates

uv-bench

Functionality for benchmarking uv.

uv-cache-key

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

uv-distribution-filename

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

uv-distribution-types

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

uv-install-wheel-rs

Install built distributions (wheels) into a virtual environment.

uv-once-map

A waitmap-like concurrent hash map for executing tasks exactly once.

uv-pep440-rs

Utilities for interacting with Python version numbers and specifiers.

uv-pep508-rs

Utilities for parsing and evaluating dependency specifiers, previously known as PEP 508.

uv-platform-tags

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

uv-cli

Command-line interface for the uv package manager.

uv-build-frontend

A PEP 517-compatible build frontend for uv.

uv-cache

Functionality for caching Python packages and associated metadata.

uv-client

Client for interacting with PyPI-compatible HTTP APIs.

uv-dev

Development utilities for uv.

uv-dispatch

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

uv-distribution

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

uv-extract

Utilities for extracting files from archives.

uv-fs

Utilities for interacting with the filesystem.

uv-git

Functionality for interacting with Git repositories.

uv-installer

Functionality for installing Python packages into a virtual environment.

uv-python

Functionality for detecting and leveraging the current Python interpreter.

uv-normalize

Normalize package and extra names as per Python specifications.

uv-requirements

Utilities for reading package requirements from pyproject.toml and requirements.txt files.

uv-resolver

Functionality for resolving Python packages and their dependencies.

uv-shell

Utilities for detecting and manipulating shell environments.

uv-types

Shared traits for uv, to avoid circular dependencies.

uv-pypi-types

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

uv-virtualenv

A venv replacement to create virtual environments in Rust.

uv-warnings

User-facing warnings for uv.

uv-workspace

Workspace abstractions for uv.

uv-requirements-txt

Functionality for parsing requirements.txt files.