Another dependency question. [SOLVED] I’m a bit h...
# general
c
Another dependency question. [SOLVED] I’m a bit hazy on how dep inference works when importing 3rdparty libs. Say I have a project, that imports
django
, which in turns comes with a bunch of optional dependencies based on what “extras” I install it with. Say I
from django.db.mongo import MongoClient
just to make something up, and that part of django imports mongo. Then
mongo
will be another 3rd party lib we depend on. Is this also inferred? Thing is, I have an issue getting our imports to infer our dependencies properly.. and try to narrow down what could be the cause for it.
h
Good question: I'm not sure how we handle extras in 3rdparty dep inference. @witty-crayon-22786?
w
afaik, inference only includes or excludes the 3rdparty target, which corresponds to a single requirement.
if that requirement includes extras, then anyone depending on that target will get all of the transitive dependencies, including any required for the extras
👍 1
h
Try .
/pants dependencies --type=3rdparty path/to/app.py
to see the top-level requirement strings depends upon by the file
c
Hmm…
--type=3rdparty
came out empty.. although, with
--transitive
I get a list of 3rdparty libs..
hmm… using poetry for deps, is there a way to see if the extras are propagated.. ?
h
They should be! There are unit tests that we handle
extras
. The only way I know to confirm is find the target name, like
//:requests
, then make sure something depends on it, e.g. by adding
//:requests
to the
dependencies
field of a target. Then run
./pants dependencies --type=3rdparty
c
will try that
Ah, OK, yep, 3rpdparty worked, when I added transitive too…
Copy code
$ ./pants dependencies --transitive --type=3rdparty tests:tests0
backoff<2.0.0,>=1.11.1
cachetools<5.0.0,>=4.2.2
flasgger<0.10.0,>=0.9.5
flask-cors<4.0.0,>=3.0.10
flask<3.0.0,>=2.0.1
gevent<22.0.0,>=21.8.0
memorised==1.1.0
requests<3.0.0,>=2.26.0
svs-configuration<4.0.0,>=3.3.2
svs-logging<3.0.0,>=2.0.0
svs-stats<3.0.0,>=2.0.2
svs-utils[default,testutils]<5.0.0,>=4.24.2
However, in
svs-utils
there is a dep for another svs lib for the
testutils
extra, which isn’t included in the venv when running pytest..
Copy code
$ ./pants test tests/auth_test.py 
19:20:12.08 [INFO] Completed: Building pytest.pex with 2 requirements: pytest-cov>=2.10.1,<2.12, pytest>=6.0.1,<6.3
19:20:12.09 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
....
no, wait, now I hade another lib missing, which is a test plugin, which is expected, so perhaps this was a caching issue, that I got an old venv after fixing a missing extra on my dep.
h
Where is your pyproject.toml located? This might be another issue with Pantsd invalidation
c
Oh, right. The pyproject is at the project root, however the constraints file is under /deps..
This because I already had a dir at root namned build, in conflict with BUILD, so to avoid a BUILD file at root.
OK, after some more dependency fiddling, all tests now pass. YAY! 🎉 It’s not been entirely straight forward, despite being somewhat familiar with pants by now. Although, I must say, that all tests pass, and I haven’t had to change a single line of code (only configuration etc). Kudos!
🚀 2