hi, is there a way to use inheritance in constrain...
# general
a
hi, is there a way to use inheritance in constraints.txt with pants. Basically, jupyter needs a few different packages for Windows and Linux. I have a common constraints.txt and I am "inheriting" from it in linux-constraints.txt and windows-constraints.txt (i.e.
-r constraints.txt
). pants.toml points to linux-constraints.txt but it complains that constraints.txt does not exist. I tried to add constraints.txt as resources but the issue persists. I had a look here https://www.pantsbuild.org/docs/python-third-party-dependencies but i did not find any options for
python_requirements
that would help. I know pants is Linux only, but imho there are justified use cases for inheritance in requirements files like the one above (better than duplicating the constraints).
h
No there is not. This is sort of related to https://github.com/pantsbuild/pants/issues/11165, but even then I think not quite the same
a
somehow related but this is more of a single set of requirements stemming from multiple files
šŸ‘ 1
h
How are you inheriting? Are you able to get that working with stand-alone Pex and pip?
a
ā€¢ constraints.txt
Copy code
pytest==...
pandas==...
ā€¢ windows-constraints.txt
Copy code
-r constraints.txt
pywin==...
ā€¢ linux-constraints.txt
Copy code
-r constraints.txt
few linux only deps==...
šŸ‘ 1
pip install -r linux-constraints.txt works
h
Here, you're treating your
constraints.txt
as a requirements file, rather than a constraints file. Instead, Pants is doing the equivalent of
pip install -c constraints.txt req1 req2
. I suspect the
-r constraints.txt
would be ignored in that case with pip too
a
thanks
good point, let me try
yes, pip still works with ā€¢ constraints.txt ā€¢ linux-constraints.txt (-c constraints.txt and some other stuff)
Copy code
pip install -c linux-constraints.txt -r requirements.txt
e
Pex works with all that too.
šŸ‘ 1
Pants has a tricker job because it needs to track those includes somehow.
For file invalidation reasons.
h
Doesn't pants support the union of multiple lockfiles?
h
Doesn't pants support the union of multiple lockfiles?
No, you can only specify a single constraints file with the
[python-setup]
option. I originally implemented it to work with multiple, but John very rightfully encouraged keeping it simple until we better understood the semantics of multiple
h
Reasonable
Probably we will need to parse and handle includes to get this really correct