Hi all โ€” has anyone seen `./pants test` install pa...
# general
b
Hi all โ€” has anyone seen
./pants test
install packages that donโ€™t match the lockfile? In my case, the test PEX ends up with two
attrs
versions (
24.2.0
and
25.3.0
). Python imports the older one first, which breaks
cattrs 25.x
with
ImportError: cannot import name 'NothingType' from 'attrs'
. When I run
./pants export ::
, the exported venv correctly has only
attrs==25.3.0
. Iโ€™ve cleaned caches, but the duplicate older
attrs
returns during
pants test
. Is this a known issue or a misconfig on my end?
e
do you happen to have both defined in
python_requirement
targets? maybe the export process can handle the de-duplicating, but the sandboxing for tests has a more difficulr time?
(just a guess to get started somewhere)
b
Not explicitly at least. I did not have attrs or cattrs explicitly in any of my requirement files. But is pulled in as a requirement. I have tried to pin these packages to 25.3 and 24.2, but it doesn't change anything ๐Ÿ˜•
I made one mistake. Pinning both packages <25.0 seems to work. But I still do not understand why version 24 of attr is installed when I pin both to version 25.
b
I'll let an actual Pants maintainer wake up and explain this to you, and simply point here to prompt them: https://github.com/pantsbuild/pants/blob/24c4ecae0e84b795fb090c1219ba7dd4aeb0968d/3rdparty/python/pytest.lock#L65-L77 In short, this is a known shortcoming of how Pants Python handling does tools. The JVM side, IIUC handles this well by shading the tool and its internal deps as much as possible whereas the Python backend simply mushes 2 PYTHONPATHs together and prays for the best,
๐Ÿ‘ 1
b
Thank you. Then I at least know why it happens. So as long I pin cattrs and attrs to the same version as used by pants, I should be fine. Does that sound right?