Hi, Why are 3rd party dependencies global and not ...
# general
r
Hi, Why are 3rd party dependencies global and not local? Is it more complicated to keep it local like other targets? The issue I am facing right now with a monorepo is that I have to actively maintain 3rdparty dependencies for all individual python packages inside my monorepo.
w
from my experience with other tools, it’s just that their definitions are global so they are visible in a single common place but that doesn’t mean all the individual compilation units use them all (i.e. that’s how it is in Bazel). As far as I can tell from Pant’s code, Pants uses those as reference too but then assign a subset of them to each target. Now, since Pants does some dependency inference, that may be interfering with you being explicit about them. From Pants docs, you can disable dependency inference using
[python-infer].imports = false
h
it’s just that their definitions are global so they are visible in a single common place but that doesn’t mean all the individual compilation units use them all
Indeed. Double checking that you read the conceptual model at https://www.pantsbuild.org/docs/python-third-party-dependencies?
The issue I am facing right now with a monorepo is that I have to actively maintain 3rdparty dependencies for all individual python packages inside my monorepo.
Is there a particular issue you're running into?
r
I have multiple (for now 2) python packages inside my monorepo. They both have their own list of 3rd party dependencies defined in
pyproject.toml
, which was generated by poetry. I tried to build
pants package package1/packag2
, which have common dependency
pandas
, but
pants
was failing since it saw two
pandas
targets. This was done using
poetry_requirements
in the BUILD file. After this issue I created a top level
3rdparty
folder with just a single
requirements.txt
like you have in
pants
github repository. This global ``requirements.txt`works fine but now I have to ensure whatever dependencies I add in one of the packages say using
poetry add <dependencies>
should also be added to
requirements.txt
If we could have leveraged local 3rd party dependencies, then we could have also used the lock files generated by poetry easily?
e
I would find it useful if there was a mechanism to specify some 3rdparty
python_requirement(s)
as "default" so that any target will infer dependence on them, but individual targets be able to specify overrides. This way one "binary" can depend on a different version w/o all the other build files in the repo needing to be updated to list it explcitily.
👍 1