brainy-kitchen-23098
05/27/2024, 9:38 AMpoetry_requirements()
capable of getting a local dependency from pyproject.toml into the lockfile generated by poetry generate-lockfiles
?
# BUILD
poetry_requirements(
name="poetry",
resolve="my_resolve"
)
# pyproject.toml
[tool.poetry.dependencies]
local-shared-lib = {path = "../local-shared-lib", develop=true}
What I experiences is that 3rd party dependencies are added fine but the one with the local path is completely ignored with no warning or error.
I would really appreciate some pointers. Thank you.square-psychiatrist-19087
05/27/2024, 11:17 AMpoetry_requirements
target do is generate a bunch of python_requirement
targets. First party code in your repo needs to be defined in python_sources
target, it doesn't need python_requirement
, that's whydazzling-elephant-33766
05/27/2024, 12:25 PMbrainy-kitchen-23098
05/27/2024, 1:15 PMlibs/lib_b/my_namespace/lib_b/src/main.py
has an import from my_namespace.lib_a.src import whatever
The apps use the same format. apps/app1/app1/src/main.py
has an import from my_namespace.lib_a.src import whatever
For now I have placed BUILD files at the same level with pyproject.toml and defined targets for poetry_requirements, sources and tests.
I am not clear yet how to define lib_a
as a dependency for lib_b
and app1
considering the import format is from my_namespace.lib_a.src import whatever
square-psychiatrist-19087
05/27/2024, 1:16 PMdazzling-elephant-33766
05/27/2024, 1:22 PMlocal-shared-lib = {path = "../local-shared-lib", develop=true}
My own repo had this exact same setup. I'm guessing this is why you have the x2 duplicate namespaces like lib_a/my_namespace/lib_a
so that when you install something you can just importing it with my_namespace.lib_a
Instead of thinking about how you can get pants to mimick what poetry is doing here I'd really consider just completely flattening your namespace completely (because what poetry is doing is pretty weird).
So instead your repo structure would look like
shared_libs/lib_a/__init__.py
shared_libs/lib_b/__init__.py
apps/app1/__init__.py
etc.
But this might not be possible.
In my own experience the migration/flattening the repo structure was worth it. The imports then directly reflect the structure of your repo (instead of some weird shimmed poetry path).square-psychiatrist-19087
05/27/2024, 1:25 PMsource_roots
in your pants.toml
[source]
root_patterns = ["shared-libs/*/", "apps/*/"]
dazzling-elephant-33766
05/27/2024, 1:26 PMbrainy-kitchen-23098
05/27/2024, 1:31 PMroot_patterns = ["shared-libs/*/", "apps/*/"]
instead of
marker_filenames = ["pyproject.toml"]