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

Better error messages when trying to uv pip install a wheel file without a package name #1407

Closed
carlosperate opened this issue Feb 16, 2024 · 8 comments
Assignees
Labels
error messages Messaging when something goes wrong

Comments

@carlosperate
Copy link

carlosperate commented Feb 16, 2024

In the spirit of PR #669, it'd be nice if some of the error messages when trying to install a wheel without specifiying the package name were a bit more helpful.

The error message for a relative path is good:

$ uv pip install mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl
error: Failed to parse `mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl`
  Caused by: URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ https://...`).
mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But the error for a full path that starts with /, is not as helpful:

$ uv pip install /Users/microbit-carlos/workspace/tmp/mu-tests/mu/mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl
error: Failed to parse `/Users/microbit-carlos/workspace/tmp/mu-tests/mu/mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl`
  Caused by: Expected package name starting with an alphanumeric character, found '/'
/Users/microbit-carlos/workspace/tmp/mu-tests/mu/mu/wheels/1.2.2/appnope-0.1.4-py2.py3-none-any.whl
^

And the error when the path is a filename in a local directory is not as helpful either:

$ cd mu/wheels/1.2.2/
$ uv pip install appnope-0.1.4-py2.py3-none-any.whl
  × No solution found when resolving dependencies:
  ╰─▶ Because appnope-0-1-4-py2-py3-none-any-whl was not found in the package registry and you require appnope-0-1-4-py2-py3-none-any-whl, we can
      conclude that the requirements are unsatisfiable.
@charliermarsh charliermarsh added the error messages Messaging when something goes wrong label Feb 16, 2024
@charliermarsh
Copy link
Member

Nice, those are great cases to handle, thanks.

@zanieb
Copy link
Member

zanieb commented Feb 16, 2024

@akx
Copy link
Contributor

akx commented Feb 16, 2024

👍 from me. I have a Dockerfile that does a multistage build where wheels are built in a chunkier container and installed (only) from those wheels in a second stage.

FROM something AS requirements
COPY requirements.txt /wheels/requirements.txt
RUN cd /wheels && pip wheel --no-cache-dir -r requirements.txt
# ...
FROM somethingelse AS runtime
# ...
RUN --mount=type=cache,ro,from=requirements,source=/wheels,target=/wheels pip install --no-cache-dir --no-index --find-links /wheels /wheels/*.whl

Trying to replace pip install with uv pip install goes

0.171 error: Failed to parse `/wheels/Babel-2.14.0-py3-none-any.whl`
0.171   Caused by: Expected package name starting with an alphanumeric character, found '/'
0.171 /wheels/Babel-2.14.0-py3-none-any.whl

(Replacing pip wheel with uv pip wheel fails too, because wheel isn't a subcommand yet, but that's #920.)

@charliermarsh
Copy link
Member

(You should be able to use Babel @ /wheels/Babel-2.14.0-py3-none-any.whl -- does that work?)

@akx
Copy link
Contributor

akx commented Feb 16, 2024

@charliermarsh Can't try that easily unfortunately since the list of requirements comes from shell wildcard expansion 😅

@charliermarsh
Copy link
Member

Oh hah. Okay, got it :) It sounds like you need #313.

@matthewfeickert
Copy link

Can't try that easily unfortunately since the list of requirements comes from shell wildcard expansion

Yeah, this is something that I run into as well, when I have validation shell scripts that find all the wheels from an archive that's been downloaded and then execute something similar to

uv pip install "./archive/*.whl"

(I know that this is already in the works over on Issue #313, so thank you!, I just wanted to give another example of a common workflow.)

@charliermarsh
Copy link
Member

This is now supported, so no need to improve the error messages!

@charliermarsh charliermarsh self-assigned this Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

No branches or pull requests

5 participants