Hi all, I’m seeking advice on setting up a specifi...
# general
a
Hi all, I’m seeking advice on setting up a specific multi-resolve configuration in our monorepo. Our monorepo has the following structure: -
libs
(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`:
Copy code
[python.resolves]
projects-a = "pants-utils/3rdparty/python/projects/projects-a.lock"
- Applied the constraints:
Copy code
[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`:
Copy code
__defaults__(all=dict(resolve="projects-a"))
- Associate the resolves in `libs/BUILD`:
Copy code
__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.
b
Heya, sorry for the trouble. Not exactly answering the questions, but... I think generally Pants/monorepos work best when code that depends on each other is all in a single "resolve" (even if not by that name in other tools), or else one ends up with inconsistent/confusing third-party dependencies pinning. For helping with your specific issue, is it possible to create a reduced reproducer demonstrating your problem? It's hard to debug remotely 🙂
a
Thank you, @broad-processor-92400! I'm organizing the ideas better and working on a small-scale repo indeed. I will share when ready. Thanks!
As connected to my previous thread, but also as a general question, why does
python_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...