https://pantsbuild.org/ logo
#general
Title
# general
a

acceptable-guitar-79854

02/17/2021, 1:37 PM
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

hundreds-father-404

02/17/2021, 2:47 PM
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

acceptable-guitar-79854

02/17/2021, 2:57 PM
somehow related but this is more of a single set of requirements stemming from multiple files
šŸ‘ 1
h

hundreds-father-404

02/17/2021, 3:08 PM
How are you inheriting? Are you able to get that working with stand-alone Pex and pip?
a

acceptable-guitar-79854

02/17/2021, 3:32 PM
ā€¢ 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

hundreds-father-404

02/17/2021, 3:58 PM
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

acceptable-guitar-79854

02/17/2021, 4:15 PM
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

enough-analyst-54434

02/17/2021, 5:39 PM
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

happy-kitchen-89482

02/17/2021, 6:51 PM
Doesn't pants support the union of multiple lockfiles?
h

hundreds-father-404

02/17/2021, 6:52 PM
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

happy-kitchen-89482

02/17/2021, 6:53 PM
Reasonable
Probably we will need to parse and handle includes to get this really correct