wonderful-boots-93625
02/14/2023, 9:02 PMpython_distribution(
name="dist",
dependencies=[
"iai_fl_client:reqs",
"iai_auth:dist",
"iai_fl_client/src/iai_fl_client",
"iai_fl_client/src/iai_fl_client/utils",
"iai_fl_client/src/iai_fl_client/client",
],
provides=python_artifact(
name="iai-fl-client",
version="2.0.24",
),
wheel_config_settings={"--global-option": ["--python-tag", "py37.py38.py39"]},
)
and in the tests BUILD
python_tests(
name="tests",
timeout=120,
runtime_package_dependencies=[
"iai_fl_client:dist",
"iai_auth:dist",
]
)
And when running tests it can’t import iai_fl_client.utils
- what am I doing wrong?
_________________ ERROR collecting tests/test_client_utils.py __________________
ImportError while importing test module '/private/var/folders/xn/yvv0m2ln4dg_vyr8rp8_3xzh0000gn/T/pants-sandbox-dNO8Kw/iai_fl_client/tests/test_client_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Users/nasron/.pyenv/versions/3.8.13/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
iai_fl_client/tests/test_client_utils.py:3: in <module>
from iai_fl_client.utils.util import poll_server_info
E ModuleNotFoundError: No module named 'iai_fl_client.utils'
curved-television-6568
02/14/2023, 10:07 PMwonderful-boots-93625
02/15/2023, 4:14 PM$ ./pants dependencies --transitive iai_fl_client:test | grep iai_fl_client/utils/util.py
iai_fl_client/src/iai_fl_client/utils/util.py
$ ./pants roots | grep iai_fl_client
iai_fl_client/src
What am i missing?python_sources()
python_tests(
name="test",
sources=[
'tests/test*.py'
]
)
and relying more on the inferred dependenciescurved-television-6568
02/15/2023, 4:55 PMiai_fl_client/utils/util.py
what is ^^ ?
doesn’t seem to be part of any source root?
but you’ve filtered your output so hard to tell….wonderful-boots-93625
02/15/2023, 6:35 PMiai_fl_client\
src\
iai_fl_client\
utils\
setup.py
and I’m using default root_patternscurved-television-6568
02/15/2023, 6:53 PMwonderful-boots-93625
02/15/2023, 7:32 PMcurved-television-6568
02/15/2023, 7:37 PMwonderful-boots-93625
02/15/2023, 7:44 PMexport PEX_EXTRA_SYS_PATH=$'iai_fl_client/src ....'
so when the test runs, it tries to import at ./iai_fl_client
instead from ./iai_fl_client/src/iai_fl_client
because the current directory seems to be included in the sys path? So its kind of a conflict in a way.
If I manually edit the __run.sh and rename directories in the sandbox, it works.export PEX_EXTRA_SYS_PATH=$'stuff/iai_fl_client/src ....'
and move the directory under stuff/
then rerunning __run.sh
in the sandbox works