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.67k stars 608 forks source link

Omit options like extra-index-url in requirements.txt #2017

Closed liebsc21 closed 8 months ago

liebsc21 commented 9 months ago

What's the problem this feature will solve?

I have a package which depends on packages on pypi.org and a private pypi server. Furthermore I use pyproject.toml to store meta data. To compile requirements.in, I specify extra-index-url on the CL. This stores --extra-index-url <URL> in requirements.txt, which works fine, when I run pip install -r requirements.txt. However. if I build with python -m build or use the editable install pip install -e ., setuptools complains: setuptools.extern.packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier --extra-index-url <URL> I use pip-tools 7.3.0, setuptools 65.5.0. pip 22.3.1 and Python 3.10.

Describe the solution you'd like

I read in this post that it is not good practise to store information like extra-index-url in the repo/package itself, because the user should have ultimate control over the package and decide whether he wants to allow access to an extra pypi server.

So instead of making setuptools accept/read in extra-index-url, I conclude that an option in pip-compile would be helpful. This option controls whether options like extra-index-url are written to requirements.txt (default) or not.

5cat commented 8 months ago

pip-compile --no-emit-index-url

liebsc21 commented 8 months ago

Thanks. pip compile --no-emit-options is even better for me.