jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.69k stars 610 forks source link

support per-requirement options #2000

Open belm0 opened 11 months ago

belm0 commented 11 months ago

What's the problem this feature will solve?

pip supports per-requirement options, e.g. --config-settings

I'm forced to use per-requirement --config-settings, because there are cases where pip intentionally does not honor the command-line --config-settings.

Configuration settings provided via --config-settings command line options (or the equivalent environment variables or configuration file entries) are passed to the build of requirements explicitly provided as pip command line arguments. They are not passed to the build of dependencies, or to the build of requirements provided in requirement files.

But pip-compile does not seem to propagate per-requirement options.

Describe the solution you'd like

I'd like pip-compile to propagate per-requirement options from .in to .txt

$ echo 'scipy==1.10.1; --config-settings="setup-args=-Dblas=blas"' > r.in

$ pip-compile -r r.in
numpy==1.24.4
    # via scipy
scipy==1.10.1; --config-settings="setup-args=-Dblas=blas"
    # via -r r2.in

Alternative Solutions

Command line pip --config-settings doesn't work, because I'm passing a requirements file to pip wheel, and pip intentionally doesn't propagate the settings.

My current workaround is to build the affected packages separately, avoiding use of a requirements file. But it's not good for my use case, which is to build all the transitive dependencies for an application (targeting an alternative python implementation). pip wheel -r ... is best suited for this.

webknjaz commented 11 months ago

Pip doesn't put them into comments like that, though. Said section is reserved for the environment markers.

webknjaz commented 11 months ago

Also, it appears you confuse the function of constraint files compared to the incoming requirements. Constraints probably don't need this.

AndydeCleyre commented 10 months ago

Just to add to workaround thoughts (not sure if I'm using the option syntax right, but this is what I understand from the docs):

r.in:

scipy==1.10.1
$ pip-compile r.in

configured.txt:

-r r.txt
--config-settings="setup-args=-Dblas=blas" scipy
$ pip install -r configured.txt

Would that work?

NickDarvey commented 7 months ago

Just to add to workaround thoughts

That works for me, thanks @AndydeCleyre