adventurous-rain-63973
09/09/2024, 10:46 AMlibs
(shared code across projects)
- projects
(independent projects that may rely on libs
)
I would like to enable each project to be independent while inheriting all the dependencies from libs
.
What I've done so far:
Isolate libs
dependencies:
- Identified and locked dependencies for libs
in the python-default
resolve, and created a requirements.txt
with libs
dependencies.
- Generated the python-default.lock
file.
- Generated the constraints.txt
with fixed versions.
Enabled `projects/a`:
- To test, I disabled all projects but one projects/a
.
- Defined a new resolve for projects/a
defined in `pants.toml`:
[python.resolves]
projects-a = "pants-utils/3rdparty/python/projects/projects-a.lock"
- Applied the constraints:
[python.resolves_to_constraints_file]
projects-a = "pants-utils/3rdparty/python/constraints.txt"
- Defined a pants-utils/3rdparty/python/projects/requirements.txt
with:
- Specific requirements for projects/a
.
- Requirements from libs
(python-default
).
- Requirements for pytest
(I found out that otherwise it's unable to pick them when testing).
- Generated the lockfiles and verified that projects-a.lock
includes all necessary dependencies from libs
.
- Associate the resolve in `projects/a/BUILD`:
__defaults__(all=dict(resolve="projects-a"))
- Associate the resolves in `libs/BUILD`:
__defaults__(all=dict(resolve=parametrize("python-default", "projects-a")))
The issues
I could test basic goals like list
. There is a lot of redundancy to be applied, and I noticed that target python_distribution
need me to specify a single resolve when in libs
.
However, the real problems start when I try dependencies
which is apparently not working. I found out that there was a manual dependency to a python requirement in python-default
path, not specializing when using projects-a
. I tried to play with **parametrize
, but it doesn't play well in this case.
The other thing I tried was to have one single path for these two resolves, so that the parametrize
might work; however, I'm struggling as well.
I wonder, is there a more efficient or smarter approach to achieve the mentioned setup? Thank you all for your help! Pleased to give more details if need be.broad-processor-92400
09/11/2024, 3:38 AMadventurous-rain-63973
09/11/2024, 8:19 AMadventurous-rain-63973
09/19/2024, 4:33 PMpython_distribution
does not have a field resolve
? I noticed that I have to manaully specify targets with @resolve=
in dependencies
. However, this does not work properly with multi-resolves...