Working on a proof of concept for our Pants usage ...
# general
s
Working on a proof of concept for our Pants usage and have run into a problem: The current structure of the PoC repo is monorepo • core ◦ core ▪︎ <code> ◦ test ▪︎ <test_code> ◦ BUILD • foo ◦ foo ▪︎ <code> ◦ test ▪︎ <test_code> ◦ BUILD Now I know this is somewhat different than the recommended layout of a BUILD in each directory and tests off to the side at a top level in their own folder. But 1) We don't need that (yet) 2) It may be too much of an extreme change for some to swallow.
core
is working fine (it's tests run and it packages from what I can tell) and it's BUILD file looks like this:
Copy code
python_library(
    name = "core",
    sources = ["core/*.py"],
)

python_tests(
    name="test",
    sources = ["test/test_*.py"],
    dependencies=["core"],
)

python_distribution(
    name="dist",
    dependencies=["core"],
    setup_py_commands=["bdist_wheel", "sdist"],
    provides=setup_py(
        name='core',
        version="1.0.0",
        description='blah, blah, blah',
    ),
)
foo
which depends on core can not find core as per this error:
Copy code
________________ ERROR collecting foo/test/test_cherrypy.py _________________
ImportError while importing test module '/tmp/process-executionLlK5rO/foo/test/test_cherrypy.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/james/.pyenv/versions/3.8.12/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
foo/test/test_cherrypy.py:11: in <module>
    from core.test_utils import token
E   ModuleNotFoundError: No module named 'core.test_utils'
foo
's BUILD looks like this:
Copy code
python_library(
    name = "foo",
    sources = ["foo/jwtutils.py", "foo/jwthug.py", "foo/jwtcherry.py"],
    dependencies = ["core:core"]
)

python_tests(
    name="test",
    sources = ["test/test_*.py"],
    dependencies=[
        "core:core",
        "thirdparty/python:cherrypy"
    ],
)

python_distribution(
    name="dist",
    dependencies=["foo"],
    setup_py_commands=["bdist_wheel", "sdist"],
    provides=setup_py(
        name='foo',
        version="1.0.0",
        description='foo library',
    ),
)
My expectation is that the
dependencies
in
python_tests
make the
core
library available to foo, is this assumption incorrect?