wooden-library-2965
02/22/2022, 1:54 PMwooden-library-2965
02/22/2022, 1:55 PMwooden-library-2965
02/22/2022, 1:59 PM./pants test ::
I get the following error:
/Users/david/.cache/pants/named_caches/pex_root/venvs/s/305a3081/venv/lib/python3.9/site-packages/attrs/_init_.py:31: in <module>
from attr._next_gen import asdict, astuple
E ImportError: cannot import name 'asdict' from 'attr._next_gen' (/Users/david/.cache/pants/named_caches/pex_root/venvs/s/305a3081/venv/lib/python3.9/site-packages/attr/_next_gen.py)
This is suspicious because the attr and attrs packages are both provided by the attrs library, so they should not be out of sync with each other. Looking inside the site-packages directory referenced in the error message, I discovered that attrs/__init__.py is from attrs 21.4.0, but attr/_next_gen.py is from an older version.
I am using constraints.txt, generated by poetry as suggested in the documentation, and it specifies attrs 21.4.0:
attrs==21.4.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
wooden-library-2965
02/22/2022, 2:01 PMattrs==21.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" \
--hash=sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1 \
--hash=sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb
wooden-library-2965
02/22/2022, 2:05 PMpolite-garden-50641
02/22/2022, 2:53 PMenough-analyst-54434
02/22/2022, 3:22 PMsys.path
wins for any overlaps. Since we don't support shading the pytest tool depencies yet, you'll have to force the pytest tool to use the same version of attrs. See here for the recipe: https://www.pantsbuild.org/docs/python-third-party-dependencies#tool-lockfiles
You'll want to add an extra requirement for pytest on attrs directly with the version your code needs. This assumes that version is compatible with pytest (transitive) requirements. I haven't checked.enough-analyst-54434
02/22/2022, 3:34 PMwooden-library-2965
02/22/2022, 3:59 PMextra_requirements.add = ["attrs==21.4.0"]
worked!enough-analyst-54434
02/22/2022, 4:31 PM