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 freezes vcs subdirectory requirements in non-roundtrippable format #1931

Closed
mqudsi opened this issue Feb 23, 2024 · 6 comments · Fixed by #1936
Closed

uv freezes vcs subdirectory requirements in non-roundtrippable format #1931

mqudsi opened this issue Feb 23, 2024 · 6 comments · Fixed by #1936
Assignees
Labels
bug Something isn't working

Comments

@mqudsi
Copy link

mqudsi commented Feb 23, 2024

Apologies in advance if I'm missing something as I'm primarily a low-level (rust + others) dev and speaking from a position of little production Python experience here.

Installing a package via the vcs+https:// protocol and specifying both a revision and a subdirectory results in a subsequent uv pip freeze output that seems to include the entry in a human-readable rather than machine-parseable format. If piped to requirements.txt then fed back into either uv or pip ([uv] pip install -r requirements.txt), this always fails to install as it does not understand the syntax.

Reproduction:

uv pip install insightface@git+https://github.com/deepinsight/insightface.git#subdirectory=python-package@
01a34cd94f7b0f4a3f6c84ce4b988668ad7be329

Resulting in

> uv pip freeze | tee requirements.txt | grep insightface
insightface==0.7.3 (from git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package)

Attempting to install the generated requirements.txt with pip results in the following error:

ERROR: Invalid requirement: 'insightface==0.7.3 (from git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package)' (from line 15 of requirements.txt)
Hint: It looks like a path. File 'insightface==0.7.3 (from git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package)' does not exist.

while attempting to install with uv also fails:

error: Couldn't parse requirement in `requirements.txt` at position 248
  Caused by: Trailing `(from git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package)` is not allowed
insightface==0.7.3 (from git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

whereas it seems that a requirements.txt entry in the following format is supported by both pip and uv pip:

insightface@git+https://github.com/deepinsight/insightface.git@01a34cd94f7b0f4a3f6c84ce4b988668ad7be329#subdirectory=python-package

so presumably this is what uv pip freeze should emit?


Running uv v0.1.10 and pip v23.3.1

@charliermarsh
Copy link
Member

👍 This is a bug. There's another issue for it somewhere...

@charliermarsh charliermarsh added the bug Something isn't working label Feb 23, 2024
@charliermarsh
Copy link
Member

Can't find it, so we'll just track this here.

@mqudsi
Copy link
Author

mqudsi commented Feb 23, 2024

Thanks for confirming I wasn't holding it wrong!
(fwiw I wasn't able to find anything with a quick search before creating this issue either.)

@charliermarsh
Copy link
Member

I swear it's somewhere 😂 But it might be buried.

@charliermarsh charliermarsh self-assigned this Feb 23, 2024
charliermarsh added a commit that referenced this issue Feb 23, 2024
## Summary

We're printing the `Display` representation of `InstalledDist`, which
isn't guaranteed to be (and in fact isn't) a valid PEP 508 requirement,
making it impossible to use the `freeze` output as an input to an
install.

Closes #1931.
@mqudsi
Copy link
Author

mqudsi commented Feb 24, 2024

I was going to submit a PR for this myself, but tbh would not have figured out the test harness changes you implemented in #1936. Thanks for the fix!

@charliermarsh
Copy link
Member

No prob, thanks for reporting @mqudsi!

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

Successfully merging a pull request may close this issue.

2 participants