mammoth-dawn-85816
10/27/2025, 9:25 AMpants test ::. The structure of the dependency isn’t flattened, so the references to it fail (when pytest works correctly, outside of pants).
What am I missing?
• src/libs/package_1 depends on src/libs/package_2,
◦ declared with a line like package_2 = { path = "../package_2", develop = true } in the [tool.poetry.dependencies] section of my pyproject.toml
◦ Code for package 2 lives in src/libs/package_2/src/package_2/*.py
◦ both have a single BUILD file in the package root, with python_sources, python_tests and poetry_requirements (sources depends on poetry, tests on both)
• pytest, run outside of pants, executes tests in src/libs/package_1/tests/test_*.py
◦ It correctly loads package_2 source files and tests succeed
◦ I believe this is because of the line packages = [{ include = "package_2", from = "src" }] inside [tool.poetry] of my package_2 pyproject.toml.
• pants test src/libs/package_1:: fails with ModuleNotFoundError: No module named 'package_2'
◦ When I keep & inspect the sandbox, the src/libs/package_2/ dir is empty except for src/package_2/*.py
◦ I believe package_1 is unable to read the source in ../package_2/*.py because it’s actually in ../package_2/src/package_2/*.py but there’s no pyproject.toml there to include that — does this seem correct?
• pants run tools/whatever:: (which depends on package_1) successfully runs using package_1 (and its dependency on package_2)
I’ve tried including a resources(name="pyproject", sources=["pyproject.toml"]) in package_2, (with both the package_2 python_sources depending on it, and package_1's python_tests) — with no change in the outcome, despite the package_2 pyproject.toml being present in the sandbox.
I think I’m either missing something stupid; or the approach I’m taking with using poetry for dependency management is confusing matters. Can anyone suggest debug steps?gray-apple-58935
10/27/2025, 10:19 AMresources(name=reqs, sources="pyproject.toml") - raw string instead of an array
• check echo $PYTHONPATH
• check `pants.toml`: source root_patterns, python-bootstrapmammoth-dawn-85816
10/27/2025, 10:20 AMmammoth-dawn-85816
10/27/2025, 3:37 PM