uv/scripts/packages
Zanie Blue e1878c8359
Consider installed packages during resolution (#2596)
Previously, we did not consider installed distributions as candidates
while performing resolution. Here, we update the resolver to use
installed distributions that satisfy requirements instead of pulling new
distributions from the registry.

The implementation details are as follows:

- We now provide `SitePackages` to the `CandidateSelector`
- If an installed distribution satisfies the requirement, we prefer it
over remote distributions
- We do not want to allow installed distributions in some cases, i.e.,
upgrade and reinstall
- We address this by introducing an `Exclusions` type which tracks
installed packages to ignore during selection
- There's a new `ResolvedDist` wrapper with `Installed(InstalledDist)`
and `Installable(Dist)` variants
- This lets us pass already installed distributions throughout the
resolver

The user-facing behavior is thoroughly covered in the tests, but
briefly:

- Installing a package that depends on an already-installed package
prefers the local version over the index
- Installing a package with a name that matches an already-installed URL
package does not reinstall from the index
- Reinstalling (--reinstall) a package by name _will_ pull from the
index even if an already-installed URL package is present
- To reinstall the URL package, you must specify the URL in the request

Closes https://github.com/astral-sh/uv/issues/1661

Addresses:

- https://github.com/astral-sh/uv/issues/1476
- https://github.com/astral-sh/uv/issues/1856
- https://github.com/astral-sh/uv/issues/2093
- https://github.com/astral-sh/uv/issues/2282
- https://github.com/astral-sh/uv/issues/2383
- https://github.com/astral-sh/uv/issues/2560

## Test plan

- [x] Reproduction at `charlesnicholson/uv-pep420-bug` passes
- [x] Unit test for editable package
([#1476](https://github.com/astral-sh/uv/issues/1476))
- [x] Unit test for previously installed package with empty registry
- [x] Unit test for local non-editable package
- [x] Unit test for new version available locally but not in registry
([#2093](https://github.com/astral-sh/uv/issues/2093))
- ~[ ] Unit test for wheel not available in registry but already
installed locally
([#2282](https://github.com/astral-sh/uv/issues/2282))~ (seems
complicated and not worthwhile)
- [x] Unit test for install from URL dependency then with matching
version ([#2383](https://github.com/astral-sh/uv/issues/2383))
- [x] Unit test for install of new package that depends on installed
package does not change version
([#2560](https://github.com/astral-sh/uv/issues/2560))
- [x] Unit test that `pip compile` does _not_ consider installed
packages
2024-03-28 13:49:17 -05:00
..
anyio_local Consider installed packages during resolution (#2596) 2024-03-28 13:49:17 -05:00
black_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
dependent_editables Consider installed packages during resolution (#2596) 2024-03-28 13:49:17 -05:00
dependent_locals Consider installed packages during resolution (#2596) 2024-03-28 13:49:17 -05:00
deptry_reproducer Avoid ignore crate finding cache gitignore (#2615) 2024-03-22 14:36:07 -05:00
hatchling_dynamic Avoid prepare_metadata_for_build_wheel calls for Hatch packages with dynamic dependencies (#2645) 2024-03-25 22:26:51 +00:00
hatchling_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
maturin_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
poetry_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
root_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
setup_cfg_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
setup_py_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
setuptools_editable Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00
README Rename scripts/editable-installs to scripts/packages (#2644) 2024-03-25 03:56:00 +00:00

# packages

A collection of packages used to test editable installs and bespoke behaviors in packaging setups
and definitions.