Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv ignores system installed packages #2282

Closed
RonNabuurs opened this issue Mar 7, 2024 · 5 comments
Closed

uv ignores system installed packages #2282

RonNabuurs opened this issue Mar 7, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@RonNabuurs
Copy link

While trying to implement uv in my current pipeline I came across an issue regarding dependencies.

To sketch a summary of my setup.

I'm running my pipeline in alpine, which brings some challenges. Some packages cannot be easily compiled (and don't have a wheel available), which is why I use the extra index https://github.com/alpine-wheels/index .

I use that index for packages like mysqlcient and reportlab.

My pipeline also wants to install cryptography==41.0.3, but because cryptography is available in the alpine-wheel index, it tries to install it from there. Though cryptography already has available wheels via pypi, so I don't want it to install via the alpine-wheels repo.

My thought was to first run uv once to only install cryptography, so I dont use the index. And after that I run uv with my normal dependencies via pyproject.toml. But it appears that uv doesn't see the already installed cryptography.

Because I run uv in a pipeline I use the --system flag.

See the output below:

/ # uv pip install --system cryptography==41.0.3
Resolved 3 packages in 114ms
Downloaded 3 packages in 114ms
Installed 3 packages in 6ms
 + cffi==1.16.0
 - cryptography==40.0.2
 + cryptography==41.0.3
 + pycparser==2.21
/ # uv pip install --system --extra-index-url https://alpine-wheels.github.io/index -r pyproject.toml
  x No solution found when resolving dependencies:
  `-> Because there is no version of cryptography==41.0.3 and <my-project> depends on cryptography==41.0.3, we can conclude that the requirements are unsatisfiable.
@charliermarsh
Copy link
Member

I believe this is the same as #1661. We don't consider the current environment to be a "source" for identifying packages, though we probably should. (Merging into #1661.)

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Mar 7, 2024
zanieb added a commit that referenced this issue Mar 28, 2024
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 #1661

Addresses:

- #1476
- #1856
- #2093
- #2282
- #2383
- #2560

## Test plan

- [x] Reproduction at `charlesnicholson/uv-pep420-bug` passes
- [x] Unit test for editable package
([#1476](#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](#2093))
- ~[ ] Unit test for wheel not available in registry but already
installed locally
([#2282](#2282 (seems
complicated and not worthwhile)
- [x] Unit test for install from URL dependency then with matching
version ([#2383](#2383))
- [x] Unit test for install of new package that depends on installed
package does not change version
([#2560](#2560))
- [x] Unit test that `pip compile` does _not_ consider installed
packages
@zanieb
Copy link
Member

zanieb commented Apr 1, 2024

Hi! This should be addressed in the latest release (0.1.27) via #2596.

Let us know if you have any problems.

@RonNabuurs
Copy link
Author

Hi! This should be addressed in the latest release (0.1.27) via #2596.

Let us know if you have any problems.

This issue is still persistent in my pipelines using uv 0.1.29.

My test scenario:

docker run -it --rm alpine:3.18 sh
apk add python3 py3-pip
apk add py3-mysqlclient
apk add curl
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv pip install --system mysqlclient==2.1.1

@charliermarsh charliermarsh self-assigned this Apr 5, 2024
@charliermarsh
Copy link
Member

I can take a look.

@charliermarsh
Copy link
Member

Oh, I think the issue here is that those packages are installed as eggs, which we don't support:

/ # ls /usr/lib/python3.11/site-packages
MySQLdb                            distutils-precedence.pth           packaging-23.1.dist-info           pkg_resources                      setuptools
README.txt                         mysqlclient-2.1.1-py3.11.egg-info  pip                                pyparsing                          setuptools-67.7.2-py3.11.egg-info
_distutils_hack                    packaging                          pip-23.1.2-py3.11.egg-info         pyparsing-3.0.9.dist-info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants