hatch-requirements-txt icon indicating copy to clipboard operation
hatch-requirements-txt copied to clipboard

Adding support for `python_version`

Open IlyaMichlin opened this issue 2 years ago • 0 comments

Sometimes (like in my case) there are different requirements.txt files for different python versions. Currently the only way to enforce package installation based on python version is in the requirements.txt file level i.e.: requirements.txt

numpy==1.22.0; python_version>="3.8"
pandas==1.5.0; python_version>="3.8"

requirements-python-37.txt

numpy==1.18.0; python_version<"3.8"
pandas==1.0.0; python_version<"3.8"

It will be much cleaner setting the python_version on the hatch level similar to this:

files = [
    { file = "requirements.txt", python_version = ">=3.8" },
    { file = "requirements-python-37.txt", python_version = "<3.8" }
]

And add this capability to [tool.hatch.metadata.hooks.requirements_txt] as well as to [tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]

IlyaMichlin avatar Jan 01 '23 13:01 IlyaMichlin