https://pantsbuild.org/ logo
#general
Title
# general
r

rhythmic-morning-87313

04/29/2022, 2:22 PM
Q8: When I run
./pants test tests/common:tests
, pytest gets executed but all tests immediately fails with import errors because there is no 3rd-party dependencies installed.
tests/common/BUILD
simply consists of
python_tests(name="tests")
and its siblings include
conftest.py
and
test_xxx.py
stuffs. How do I let pants install 3rd party dependencies for tests?
1
ok, I got it working with the root-level
requirements.txt
and
BUILD
with
python_requirements(name="reqs", source="requirements.txt")
which are referenced as
//:reqs
in the dependencies of
src/ai/backend/common:lib
which is also referenced by
tests/common:tests
.
now it fails with import error of a subpkg of the common pkg....
hmmmmm
it seems that Python got confused with import from
ai.backend.common.redis
and
tests/common/redis/
...
i had resolved this issue by adding
__init__.py
to the tests directory, but it seems that this might not be recognized..
r

refined-addition-53644

04/29/2022, 2:44 PM
it could be simpler if you define requirements.txt under
3rdparty
folder at the root of your repo. Check pants own repository. This is a "standard" location known to pants. You wouldn't need to mention
requirements.txt
everywhere this way https://github.com/pantsbuild/pants/tree/main/3rdparty/python
3 Views