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 PMnews/src/BUILD
and /common/src/BUILD
delightful-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_test
news
, common
instead of news/src
, common/src
?happy-kitchen-89482
02/16/2021, 8:58 PM./pants test ::
::
just means all targets under the root
./pants test news/src/tests::
for example. But that was true before - this is unrelated to source roots.