quiet-army-59227
06/26/2024, 8:07 PMpython-default which has all the dependencies for my project and pants-plugins which has the pants dependencies for my custom pants plugins. When I run pants check ::, I get the following output:
I don't know why it is checking the python-default resolve when I have explicitly stated to use the pants-plugins resolve in the BUILD file in `pants-plugins/`:
pants_requirements(name="pants", resolve="pants-plugins")proud-dentist-22844
06/26/2024, 8:10 PMquiet-army-59227
06/26/2024, 8:14 PMregister.py and `rules.py`:proud-dentist-22844
06/26/2024, 8:17 PMpython_sources and pants_requirements targets. Either add resolve="pants-plugins" to all of those targets (both python_sources AND pants_requirements, not just pants_requirements), or use __defaults__(all=dict(resolve="pants-plugins")) in the pants-plugins/BUILD file to make sure everything under pants-plugins/ ends up in the correct resolve.quiet-army-59227
06/26/2024, 8:21 PMpants_requirements adds the resolve="pants-plugins" for all the python sources?proud-dentist-22844
06/26/2024, 8:21 PMquiet-army-59227
06/26/2024, 8:23 PMpants_requirements generates a python_requirement target for pants dependencies. Shouldn't that be enough?proud-dentist-22844
06/26/2024, 8:25 PMpython_requirement targets, yes. But that does not change the metadata on any of the python_source or python_sources targets. Since the python_source* targets don't specify a resolve, they default to the value of [python].default_resolve , which is python-default in your case: https://www.pantsbuild.org/2.21/reference/subsystems/python#default_resolveproud-dentist-22844
06/26/2024, 8:26 PM__defaults__ makes it much easier to adjust the metadata for many targets at once.proud-dentist-22844
06/26/2024, 8:26 PMquiet-army-59227
06/26/2024, 8:28 PMpython_requirement just defines what third party dependencies are being used (by pointing to a resolve) but python_source needs to also point to a resolve to understand this?proud-dentist-22844
06/26/2024, 8:28 PMquiet-army-59227
06/26/2024, 8:31 PMproud-dentist-22844
06/26/2024, 8:32 PMpython_requirement target in that resolve: https://www.pantsbuild.org/2.21/docs/python/overview/third-party-dependencies#teaching-pants-your-universes-of-dependencies
To use them, the sources have to be in the same resolve.
Hmm. I found an example in the docs of python_sources(resolve=..., but it is kind of buried: https://www.pantsbuild.org/2.21/docs/python/overview/lockfiles#multiple-lockfilesquiet-army-59227
06/26/2024, 8:34 PMproud-dentist-22844
06/26/2024, 8:38 PMpants.toml do something like:
[python.resolves]
pants-plugins = "path/to/lock"
[python.resolves_to_interpreter_constraints]
pants-plugins = ["CPython==3.9.*"]
like this:
https://github.com/StackStorm/st2/blob/master/pants.toml#L136-L141
And then you will probably also need to add interpreter_constraints=["CPython==3.9.*"] in pants-plugins/BUILD like this:
https://github.com/StackStorm/st2/blob/master/pants-plugins/BUILD#L5quiet-army-59227
06/26/2024, 8:44 PMpants-plugins. It is part of my project code. Also, according to the docs, it says that the resolves_to_interpreter_constraints is used to generate the lockfiles and "this does NOT impact the interpreter constraints used by targets within the resolve". Are there separate interpreter_constraints for each resolve? Do I need to make the one for pants-plugins 3.9.*?proud-dentist-22844
06/26/2024, 8:48 PMAlso, according to the docs, it says that theAh yes. I forgot about that being only for lockfile generation. I think it is a good idea to addis used to generate the lockfiles and "this does NOT impact the interpreter constraints used by targets within the resolve". Are there separateresolves_to_interpreter_constraintsfor each resolve?interpreter_constraints
__defaults__(all=dict(resolve="pants-plugins", interpreter_constraints=["CPython==3.9.*"])) in pants-plugins/BUILD. If you haven't experienced any issues without that, then go ahead and punt it till later.proud-dentist-22844
06/26/2024, 8:48 PM[python].interpreter_constraints in your pants.toml?quiet-army-59227
06/26/2024, 8:49 PM[python]
interpreter_constraints = ["==3.10.12"]proud-dentist-22844
06/26/2024, 8:52 PMif sys.version < (3, 9):
from importlib_resources import files # pants: no-infer-dep
from typing_extensions import Protocol, TypeAlias # pants: no-infer-depquiet-army-59227
06/26/2024, 8:53 PMquiet-army-59227
06/26/2024, 8:53 PM#pants: no-infer-depquiet-army-59227
06/26/2024, 8:54 PMproud-dentist-22844
06/26/2024, 8:55 PMimportlib-resources and typing_extensions.proud-dentist-22844
06/26/2024, 8:56 PM[python].interpreter_constraints is a list, the list should really only have one item in it. But, you can include a range of versions: >=3.8,<4.quiet-army-59227
06/26/2024, 8:58 PMproud-dentist-22844
06/26/2024, 9:00 PMimportlib-resources; python_version < '3.9'quiet-army-59227
06/26/2024, 9:11 PM