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

average-flag-94768

11/29/2022, 10:16 AM
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

refined-addition-53644

11/29/2022, 10:59 AM
Are you using pants to run tests too?
a

average-flag-94768

11/29/2022, 11:00 AM
Yes
r

refined-addition-53644

11/29/2022, 11:02 AM
And all of these packages have an
___init___.py
?
a

average-flag-94768

11/29/2022, 11:03 AM
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

refined-addition-53644

11/29/2022, 11:13 AM
so the dunder init files should only be inside
Common/Common
and same goes for Specific
a

average-flag-94768

11/29/2022, 11:15 AM
Ah yeah that seems to have sorted it. Thanks!
r

refined-addition-53644

11/29/2022, 11:15 AM
πŸ‘ 1
It’s more python thing than pants
c

curved-television-6568

11/29/2022, 12:02 PM
I think it would be nice if Pants could be able to detect this issue and provide helpful hints, though.. πŸ™‚
πŸ’― 2
w

wide-midnight-78598

11/29/2022, 12:31 PM
Agreed, I still run into this type of problem a lot when I'm not thinking about it
4 Views