cool-easter-32542
07/23/2024, 11:42 PMpoetry lock for each service:
• `service1`: has all dependencies from libA, libB, and 3rd-party-lib==3.0 (latest version of 3rd-party-lib)
• `service2`: has all dependencies from libB and 3rd-party-lib==2.0
All the same concepts should apply to pythonrequirements from requirements.txt and pep-621 compliant pyproject.toml files, I'm just using poetry as an example
For the equivalent in Pants, I need to:
1. In pants.toml, define a resolve per service and library
2. Parametrize targets to add ALL libraries to ALL resolves
a. Pants struggles to infer dependencies when resolves are enabled, so it also requires a lot of manual dependencies
Solution
Resolves should (optionally) behave more like poetry per-module Virtual Environments.
• A "resolve" should just represent version constraints for 3rd party dependencies (including transitive)
• Don't impose restrictions on what 1st party code can run with a resolve
• Don't require a lockfile for every resolve
For example:
1. Define resolves:
# pants.toml
[python.resolves]
service1 = "Services/service1/pants.lock"
service2 = "Services/service2/pants.lock"
1. Set Services/service1/BUILD: poetry_requirements(resolve="service1") to add direct targets of this directory to @resolve=service1 (and repeat for service2)
2. Declare a dependency (same as vanilla poetry) services/service1/pyproject.toml: libA = {path = "../../Libraries/libA", develop = true}
3. pants generate-lockfile --resolve=service1 should create a lockfile which pins libA, libB, and 3rd-party-lib
4. pants test Libraries/libA:: should run without a resolve or lockfile
Describe alternatives you've considered
We may just go back to directly using poetry for all dependencies, and exporting lockfiles for services from poetry for pants to consume in tests. I think that will give us exactly what I'm describing.
pantsbuild/pants