Hey :slightly_smiling_face: I am wondering what’s ...
# general
r
Hey 🙂 I am wondering what’s the correct way to handle transitive dependencies of 3rdparty Python requirements. For example a package like
flask
will depend on
werkzeug
and a few more. If I want to ensure that I have a consistent dependency set, do I really have to list them all everytime I want to use
flask
(e.g. as
'3rdparty/python:flask'
,
'3rdparty/python:werkzeug',
…)? This gets even more interesting with packages like
pandas
that only work with certain binary compatible
numpy
versions. This sounds brittle to maintain in a larger codebase with regularly changing requirements. Am I missing a trick or concept here?
As a bit of a background in case somebody is interested: Outside of the pants world we have mostly been using https://github.com/jazzband/pip-tools to generate fully pinned
requirement.txt
files for our apps. This kind of worked nicely as I would only need to depend on flask but the transitive dependencies would be pulled in automatically in a somewhat deterministic fashion.
h
Does that fully pinned
requirements.txt
get checked in to your repo? Because Pants can use that
All you need is a BUILD file in the same dir as the requirements.txt file, and all that BUILD file need contain is the line
python_requirements()
Which means “get requirements from the requirements.txt in this directory”
The target names are then the names of the requirements
E.g., if the dir is
3rdparty/python
then
3rdparty/python:flask
,
3rdparty/python:werkzeug
, etc.
Does that make sense?
r
@happy-kitchen-89482 thanks for the response. Yes that makes sense and matches my current understanding.
The potential problem I would like to understand though: if a user specifies flask but forgets werkzeug, what werkzeug version will he get?
I guess it won't pull in the version from my requirements.txt but just the latest version.
h
You mean if werkzeug isn’t pinned in your requirements.txt? I thought that was the whole point of letting pip-tools generate the requirements.txt?
I guess my point is that your outside-of-pants method should work for pants too.