great-art-3505
06/06/2024, 8:19 PMinterpreter_constraints
in combination of parametrize
for resolvers?
This is not valid syntax, but it illustrates the point:
__defaults__(
all=dict(
resolve=parametrize(
"service-a",
"service-b",
"service-c",
"service-d",
),
# is it possible to say:
interpreter_constraints={
"service-a": [
"CPython == 3.9.*"
]
"default": [
"CPython == 3.9.*",
"CPython == 3.10.*",
]
}
)
)
Like if I want to have a specific constraint for a specific resolver, because for example service-a
ONLY works on python3.9, and in that context the resolves for service-a
does not need to solve for 3.10
because is never used. But the same library also works in 3.10
and the 3.10
version does gets used by the other services.
This is the type of error that I’m getting, and I understand the suggesting, but from the context of service-a
it should not try to solve for 3.10
14:02:08.86 [ERROR] 1 Exception encountered:
Engine traceback:
in `test` goal
InvalidLockfileError: You are consuming `assertpy~=1.0`, `msgpack`, and 2 other requirements from the `service-a` lockfile at 3rdparty/python/resolvers/service-a.lock with incompatible inputs.
- The inputs use interpreter constraints (`CPython==3.10.* OR CPython==3.9.*`) that are not a subset of those used to generate the lockfile (`CPython==3.9.*`).
- The input interpreter constraints are specified by your code, using the `[python].interpreter_constraints` option and the `interpreter_constraints` target field.
- To create a lockfile with new interpreter constraints, update the option `[python].resolves_to_interpreter_constraints`, and then generate the lockfile (see below).
See <https://www.pantsbuild.org/2.20/docs/python/overview/interpreter-compatibility> for details.
To regenerate your lockfile, run `pants generate-lockfiles --resolve=service-a`.
See <https://www.pantsbuild.org/2.20/docs/python/overview/third-party-dependencies> for details
great-art-3505
06/06/2024, 8:32 PMgreat-art-3505
06/06/2024, 8:51 PM__defaults__(
all=dict(
**parametrize(
"py310-compat",
resolve="service-a",
interpreter_constraints=[
"CPython == 3.9.*",
"CPython == 3.10.*",
]
),
**parametrize(
"py39-compat",
resolve=parametrize(
"service-b",
"service-c",
"service-d",
),
interpreter_constraints=[
"CPython == 3.9.*",
]
)
)
)
I suppose the alternative is to unpack N parametrize calls with the duplicates of interpreter constraints but different resolve.broad-processor-92400
06/06/2024, 10:48 PMparametrize
expert and thus might have insight on this casecurved-television-6568
06/07/2024, 5:37 AM**parametrize()
is currently not supported.curved-television-6568
06/07/2024, 6:12 AMgreat-art-3505
06/07/2024, 6:35 AMgreat-art-3505
06/07/2024, 9:12 PMgreat-art-3505
06/07/2024, 9:33 PM__defaults__(
all={
**parametrize(
"py310-compat",
resolve="service-a",
interpreter_constraints=[
"CPython == 3.10.*",
]
),
**parametrize(
"py39-compat",
resolve=parametrize(
"service-b",
"service-c",
"service-d",
"service-e",
),
interpreter_constraints=[
"CPython == 3.9.*",
]
)
},
)
I get the following error:
15:23:08.92 [ERROR] 1 Exception encountered:
Engine traceback:
in `list` goal
in Find targets from input specs
InvalidTargetException: libraries/clients/foo-client-x: Unrecognized field `interpreter_constraints=('CPython == 3.9.*',)` in target libraries/clients/foo-client-x:reqs#numpy@parametrize=py39-compat,resolve=service-d. Valid fields for the target type `python_requirement`: ['_find_links', 'dependencies', 'description', 'entry_point', 'modules', 'requirements', 'resolve', 'tags', 'type_stub_modules'].
I can make the error go aways if I do this more _verbose_/_specific_ alternative (and this works!):
__defaults__(
{ (python_sources, python_tests): dict(
**parametrize(
"py310-compat",
resolve="service-a",
interpreter_constraints=[
"CPython == 3.10.*",
]
),
**parametrize(
"py39-compat",
resolve=parametrize(
"service-b",
"service-c",
"service-d",
"service-e",
),
interpreter_constraints=[
"CPython == 3.9.*",
]
)
),
(python_requirement, ): dict(
resolve=parametrize(
"service-a",
"service-b",
"service-c",
"service-d",
"service-e",
),
)
}
)
I was under the impression that the all
keyword should take care of this type of situations, is it failing because of the new parametrize functionality? Or am I missing something? (BTW I can also follow up in the PR if preferred)curved-television-6568
06/08/2024, 7:57 AMcurved-television-6568
06/08/2024, 7:58 AM