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 pip compile Does not retain PEP-508 environment markers in output #1429

Closed
CoolCat467 opened this issue Feb 16, 2024 · 11 comments · Fixed by #4503
Closed

uv pip compile Does not retain PEP-508 environment markers in output #1429

CoolCat467 opened this issue Feb 16, 2024 · 11 comments · Fixed by #4503
Labels
bug Something isn't working compatibility Compatibility with another interface or tool

Comments

@CoolCat467
Copy link

CoolCat467 commented Feb 16, 2024

uv pip compile does not respect PEP-508 Environment Markers (such as ; implementation_name ==).

> uv --version
uv 0.1.11

For example, we have test-requirements.in:

black; implementation_name == "cpython"

and running

> uv pip compile test-requirements.in -o test-requirements.txt

yields black==24.2.0 instead of black==24.2.0 ; implementation_name == "cpython"

@zanieb zanieb added bug Something isn't working compatibility Compatibility with another interface or tool labels Feb 16, 2024
@charliermarsh
Copy link
Member

I'm surprised that pip-compile retains those markers, but seems like we should too.

@jakkdl
Copy link

jakkdl commented Feb 16, 2024

If removing ; python_version markers depending on the --python-version flag is intended, then maybe the same thing should happen here and you have a flag for specifying platform that makes use of those markers and can be used to generate multiple requirements.txt files depending on version+implementation

@CoolCat467 CoolCat467 changed the title uv pip compile does not respect ; implementation_name == specifiers uv pip compile Does Not Respect PEP-508 Environment Markers Feb 27, 2024
@CoolCat467
Copy link
Author

This is currently a blocker for python-trio/trio#2958

@charliermarsh
Copy link
Member

I'm open to including them but I don't know that it's a "correct" requirement. E.g., in the Trio example, it's not really "safe" to install from that file with a non-CPython implementation, because it could be missing dependencies that are required for PyPy or any other implementation. The locked requirements are only guaranteed to be correct on the same Python platform as that which generated the lock file.

@A5rocks
Copy link

A5rocks commented Feb 27, 2024

I don't think the markers are propagated either, though I haven't checked against pip-compile. We use pip install -r <locked file> so missing dependencies are fine (we don't have hashes because requirement files vary per platform, and since lockfiles are more anti-bitrot than for security).

I think that copying over the marker to the output, even if not necessarily "correct," is a step forward towards platform independent lockfiles. (is there an issue for that? I know there's a section in the readme)

@charliermarsh
Copy link
Member

@A5rocks - There's a standardized proposal for multi-platform (but not platform-independent) installer files (to replace requirements.txt for this purpose), we've been participating in the discussion.

@charliermarsh charliermarsh changed the title uv pip compile Does Not Respect PEP-508 Environment Markers uv pip compile Does not retain PEP-508 environment markers in output Mar 7, 2024
@sondr3
Copy link

sondr3 commented Mar 20, 2024

Could markers like platform_system be included at the very least in the beginning? We keep running into issues where developers are updating dependencies on their Windows machines that crash in CI when using uv that works with pip-compile. We've need to add pywin32==306 ; platform_system=='Windows' to our pyproject.toml (using rye) which works with pip-compile but not uv.

@Franky1
Copy link

Franky1 commented Mar 23, 2024

I have this in my requirements.txt file

my-lib@https://github.com/path-to-my-lib-wheel.whl; platform_system=="Windows" and python_version=="3.10"

and uv pip install --upgrade --requirement requirements.txt fails with

error: Couldn't parse requirement in `requirements.txt` at position 180
  Caused by: Missing space before ';', the end of the URL is ambiguous

@charliermarsh
Copy link
Member

The grammar is technically ambiguous for some URLs so we require a space before the ; when it follows a URL. pip also accepts this (though does not always require it). So in this case:

my-lib@https://github.com/path-to-my-lib-wheel.whl ; platform_system=="Windows" and python_version=="3.10"

@Franky1
Copy link

Franky1 commented Mar 23, 2024

so we require a space before the ; when it follows a URL

Thanks for the quick reply, that was indeed the solution, tried it and it works now ❤️

@adminy
Copy link

adminy commented Jun 5, 2024

Also pip-compile does not support the --trusted-host argument or the --config=pyproject.toml argument.

When you run pip compile it does not put --index-url or --trusted-host in its output, generating the requirements.txt without indication of the source.

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

Successfully merging a pull request may close this issue.

8 participants