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 incorrectly determines local package availability as part of install_requires #2726

Closed
ikalchev opened this issue Mar 29, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@ikalchev
Copy link

First of all - wow this thing is fast! I recently moved a project's six of the linters/formatters to ruff and now uv is equally impressive. Cheers folks, splendid work!

I think there is an issue when you attempt to install two packages from a local folder that depend on each other.

Steps to reproduce below. We have two packages - aaa and bbb. bbb depends on aaa on some version. Both aaa and bbb share a package namespace foo. The packages themselves are empty.

Package aaa:

$ tree aaa
aaa
├── foo
│   ├── __init__.py
│   └── aaa
│       └── __init__.py

$ cat aaa/setup.py
from setuptools import setup, find_packages

version = "1.2.3"

setup(
    name="foo-aaa",
    namespace_packages=["foo"],
    extras_require={},
    version=version,
    packages=find_packages(),
    description="aaa",
)

$ cat aaa/foo/__init__.py
__import__("pkg_resources").declare_namespace(__name__)

Package bbb:

$ tree bbb
bbb
├── foo
│   ├── __init__.py
│   └── bbb
│       └── __init__.py

$ cat bbb/setup.py
from setuptools import setup, find_packages

version = "3.2.1"

setup(
    name="foo-bbb",
    namespace_packages=["foo"],
    version=version,
    install_requires=["foo-aaa~=1.2.3"],
    extras_require={},
    packages=find_packages(),
    description="bbb",
)

$ cat bbb/foo/__init__.py
__import__("pkg_resources").declare_namespace(__name__)

Installing aaa:

$ uv pip install -e "./aaa"
   Built file:///Users/ikalchev/dev/test/aaa                                                                                                          Built 1 editable in 352ms
Resolved 1 package in 0.23ms
Installed 1 package in 0.74ms
 + foo-aaa==1.2.3 (from file:///Users/ikalchev/dev/test/aaa)

Installing bbb (fails):

$ uv pip install -e "./bbb"  
   Built file:///Users/ikalchev/dev/test/bbb                                                                                                          Built 1 editable in 262ms
  × No solution found when resolving dependencies:
  ╰─▶ Because foo-aaa>=1.2.3, <1.3.dev0 was not found in the package registry and foo-bbb==3.2.1 depends on foo-aaa>=1.2.3,<1.3.dev0, we can
      conclude that foo-bbb==3.2.1 cannot be used.
      And because you require foo-bbb==3.2.1, we can conclude that the requirements are unsatisfiable.

      hint: foo-aaa was requested with a pre-release marker (e.g., foo-aaa>=1.2.3,<1.3.dev0), but pre-releases weren't enabled (try:
      `--prerelease=allow`)

Oddly enough, when I change the install_requires=["foo-aaa~=1.2"] (just remove the maintenance version part), it fails again but have a look at the "found" version for foo-aaa:

$ uv pip install -e "./bbb"
   Built file:///Users/ikalchev/dev/test/bbb                                                                                                          Built 1 editable in 368ms
  × No solution found when resolving dependencies:
  ╰─▶ Because foo-aaa>=1.2, <2.dev0 was not found in the package registry and foo-bbb==3.2.1 depends on foo-aaa>=1.2,<2.dev0, we can conclude that
      foo-bbb==3.2.1 cannot be used.
      And because you require foo-bbb==3.2.1, we can conclude that the requirements are unsatisfiable.

      hint: foo-aaa was requested with a pre-release marker (e.g., foo-aaa>=1.2,<2.dev0), but pre-releases weren't enabled (try:
      `--prerelease=allow`)

Note that if I try to install bbb after that with pip, it succeeds:

$ pip install -e "./bbb"
Obtaining file:///Users/ikalchev/dev/test/bbb
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: foo-aaa~=1.2.3 in ./venv_test/lib/python3.10/site-packages (from foo-bbb==3.2.1) (1.2.3)
Building wheels for collected packages: foo-bbb
  Building editable for foo-bbb (pyproject.toml) ... done
  Created wheel for foo-bbb: filename=foo_bbb-3.2.1-0.editable-py3-none-any.whl size=3085 sha256=bc90e3fc0255e0e3e1321b87f3a0c6dc32339a6ef0a1b83e592f39febd6c1dd3
  Stored in directory: /private/var/folders/8p/znpv_6555dnc6tqwv_bvkdb80000gn/T/pip-ephem-wheel-cache-h0lzvry0/wheels/83/66/26/26bae4c6dee3068d97be61cb5b3594a7140a46d287d2f915f0
Successfully built foo-bbb
Installing collected packages: foo-bbb
Successfully installed foo-bbb-3.2.1

Env:

  • macOS 14.4 (23E214)
  • python 3.10
  • uv 0.1.26 (7b685a8 2024-03-28)

Let me know if I can be of further help.

@aliencaocao
Copy link

Same issue here, can observe with >= requirements too.
Example is installing bitsandbytes when a torch already exists locally. pip would succeed in this case while uv will go and reinstall torch again.

@zanieb
Copy link
Member

zanieb commented Mar 29, 2024

This looks like a duplicate of #1661 which was resolved in #2596 and will be in the next release.

@zanieb zanieb added the duplicate This issue or pull request already exists label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants