I have a project that looks like: |--> Common/...
# general
a
I have a project that looks like: |--> Common/Common/foo.py |--> Specific/Specific/bar.py "from common.foo import ..." |--> Specific/Tests/conftest.py "from specific.bar import ..." Source roots are set to common and specific If I package up bar.py as a pex and run it all the imports work fine, however when I try and run the tests the specific "from common.foo import ..." import fails with no module named common.foo. I could use any pointers on what I might need to configure to get it to work as I have run out of ideas.
βœ… 1
r
Are you using pants to run tests too?
a
Yes
r
And all of these packages have an
___init___.py
?
a
Yeah
Interestingly changing the import to
from common.common.foo
Seems to fix it when doing ./pants test . So maybe something to do with source roots?
r
so the dunder init files should only be inside
Common/Common
and same goes for Specific
a
Ah yeah that seems to have sorted it. Thanks!
r
πŸ‘ 1
It’s more python thing than pants
c
I think it would be nice if Pants could be able to detect this issue and provide helpful hints, though.. πŸ™‚
πŸ’― 2
w
Agreed, I still run into this type of problem a lot when I'm not thinking about it