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

Order of entries in pyproject.toml [dependencies] defines what versions get installed. #7965

Closed
MatteoLacki opened this issue Oct 7, 2024 · 9 comments
Assignees
Labels
question Asking for clarification or support

Comments

@MatteoLacki
Copy link

Hi,

I have a funny problem here, might be an application issue of course.
I run your code inside 2 independent docker containers with one common Dockerfile:

## common Dockerfile

# Base image
FROM ubuntu:22.04

# Set up some basic utilities (example customization)
RUN apt-get update && apt-get install -y curl

# Set a label (or anything to differentiate the images)
LABEL description="Ubuntu 22.04 based image 1"

# Default command
CMD ["bash"]

After setting up both images, in the first one I run this:


cd /root
curl -LsSf https://astral.sh/uv/install.sh | sh
/root/.cargo/bin/uv --version
/root/.cargo/bin/uv venv ve_test
. ./ve_test/bin/activate
apt install git -y
git clone https://github.com/midiaIDorg/pandas_ops
cd pandas_ops
git checkout uv_problem
/root/.cargo/bin/uv pip install -e .

and in the second one this:

cd /root
curl -LsSf https://astral.sh/uv/install.sh | sh
/root/.cargo/bin/uv --version
/root/.cargo/bin/uv venv ve_test
. ./ve_test/bin/activate
apt install git -y
git clone https://github.com/midiaIDorg/pandas_ops
cd pandas_ops
git checkout uv_problem_not_working
/root/.cargo/bin/uv pip install -e .

the only difference between the two pandas_ops branches (that's a simply repo of mine) is the order of the dependencies:
in the first container it is:

dependencies = [
    "numba",
    "numpy",
    "pandas",
    "tqdm",
    "duckdb",
]

and this works. on the second one, it is:

dependencies = [
    "numpy",
    "numba",
    "pandas",
    "tqdm",
    "duckdb",
]

and this fails. numba has a specific lower version of numpy as a dependency.
I cannot put the versions above for it would miss the point. Of course, the problem might disappear later on when numba devs catch up with numpy. But as such, it seems to be and issue with uv that putting a dependency of another dependency creates confusion.

In the first container I get:

Resolved 11 packages in 296ms
   Built pandas-ops @ file:///root/pandas_ops
Prepared 11 packages in 15.21s
Installed 11 packages in 88ms
 + duckdb==1.1.1
 + llvmlite==0.43.0
 + numba==0.60.0
 + numpy==2.0.2
 + pandas==2.2.3
 + pandas-ops==0.0.2 (from file:///root/pandas_ops)
 + python-dateutil==2.9.0.post0
 + pytz==2024.2
 + six==1.16.0
 + tqdm==4.66.5
 + tzdata==2024.2

on the second one:

error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: numba==0.53.1
  Caused by: Build backend failed to determine requirements with `build_wheel()` (exit status: 1)
--- stdout:

--- stderr:
/root/.cache/uv/sdists-v4/pypi/numba/0.53.1/yVZrZDqwUxw8GhzvANsQo/numba-0.53.1.tar.gz/versioneer.py:335: SyntaxWarning: invalid escape sequence '\s'
  LONG_VERSION_PY['git'] = '''
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/root/.cache/uv/builds-v0/.tmpfMTGFT/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/uv/builds-v0/.tmpfMTGFT/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
    self.run_setup()
  File "/root/.cache/uv/builds-v0/.tmpfMTGFT/lib/python3.12/site-packages/setuptools/build_meta.py", line 503, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/root/.cache/uv/builds-v0/.tmpfMTGFT/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 50, in <module>
  File "<string>", line 47, in _guard_py_ver
RuntimeError: Cannot install on Python version 3.12.6; only versions >=3.6,<3.10 are supported.
---

both are using:

(ve_test) root@e626094d7176:~/pandas_ops# /root/.cargo/bin/uv --version
uv 0.4.18

Best wishes,

@charliermarsh
Copy link
Member

There's more on the general topic here: #5161. We do rely on the order to aid in prioritization.

@charliermarsh
Copy link
Member

The Numba / NumPy thing is a common issue. If you put NumPy first, then we prioritize solving for the last version of NumPy, which leads us to backtrack to a version of Numba that does not include a strict upper-bound. I'd suggest adding constraints to your version specifiers if you want to ensure that uv lands on a certain solve!

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
@charliermarsh charliermarsh self-assigned this Oct 8, 2024
@charliermarsh charliermarsh added the question Asking for clarification or support label Oct 8, 2024
@charliermarsh
Copy link
Member

Similar issues here #7881 and here #6281 (comment) RE Numba.

@MatteoLacki
Copy link
Author

Hi,

please unclose this bug report or modify the documentation.
You do write there, I quote:

image

However, order of dependencies does not matter for pip.
If there are $n$ dependencies, there are now $n!$ possible permutations that you leave on user to check, which is likely breaking up the speed gains :)

@MatteoLacki
Copy link
Author

I do really really like this project, don't think I don't. It's just not working here as advertised and I hope this can be fixed.

@charliermarsh
Copy link
Member

There are always going to be minor differences between pip and uv, and we cover them in the docs. In particular, there's a section on package priority here.

@MatteoLacki
Copy link
Author

Hi,

at least on their documentation, pip people write that dependencies are topologically sorted.
In particular that means, that user order should be neglected.

Have a look here:
https://pip.pypa.io/en/stable/cli/pip_install/

image

Maybe that could provide some solution to the problem?

Again, I am only trying not to make user check all of n! possibilities: think how much electricity that will save ;)

Best wishes,

@MatteoLacki
Copy link
Author

In particular, I indeed do get the same dependencies installed with pip independent of the order in the example I posted above (numpy + numba thingie).

@MatteoLacki
Copy link
Author

I also do get it that you have tons of work on your plate, and that this is not a game-breaker as such, but in the context I would still consider this being a bug, albeit one that can be handled later on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

2 participants