delightful-lizard-12586
02/15/2021, 9:14 AM|--news
|------src
|----------api
|--------------application.py
|----------tests
|--------------test_application.py
|--common
|------src
|----------common
|--------------utils.py
|----------tests
|--------------test_utils.py
In application.py I want to import function run from utils.py. I can do it only using from from common.src.common.utils import run but I'd like to have from common.utils import run (now it raises: "No module named common.utils")
Command pants roots says:
.
common/src
news/src
In test_utils.py I can import from common.utils import run
In test_application.py I can import from api.application import something
common BUILD file looks like: (
python_library(
name = "common",
sources = [
"src/common/*.py"
],
interpreter_constraints=[">=3.6.9"]
)
python_tests(
name = "common_test",
sources = [
"src/tests/test_*.py"
],
dependencies = [
":common"
],
interpreter_constraints=[">=3.6.9"]
)
news BUILD file looks like:
python_library(
name = "news",
sources = [
"src/api/*.py",
],
dependencies = [
"common:common"
],
interpreter_constraints=[">=3.6.9"]
)
python_tests(
name = "news_test",
sources = [
"src/tests/test_*.py"
],
dependencies = [
":news",
"common:common"
],
interpreter_constraints=[">=3.6.9"]
)
Do you have an idea what else should be configured there?happy-kitchen-89482
02/15/2021, 7:07 PMhappy-kitchen-89482
02/15/2021, 7:09 PMhappy-kitchen-89482
02/15/2021, 7:10 PMhappy-kitchen-89482
02/15/2021, 7:11 PMnews/src/BUILD and /common/src/BUILDhappy-kitchen-89482
02/15/2021, 7:12 PMdelightful-lizard-12586
02/16/2021, 7:20 AM./pants test ::
Also to run test for single project I need to run ./pants news/src:news_testdelightful-lizard-12586
02/16/2021, 7:20 AMnews, common instead of news/src, common/src?happy-kitchen-89482
02/16/2021, 8:58 PM./pants test ::happy-kitchen-89482
02/16/2021, 8:58 PM:: just means all targets under the roothappy-kitchen-89482
02/16/2021, 8:59 PM./pants test news/src/tests:: for example. But that was true before - this is unrelated to source roots.happy-kitchen-89482
02/16/2021, 8:59 PM