I need to introduce a project into my monorepo tha...
# general
a
I need to introduce a project into my monorepo that uses Python 3.9.2, whereas all other projects use Python 3.11.3. I'm having an issue where the generated lockfile for the 3.9.2 project says:
Copy code
//   "valid_for_interpreter_constraints": [
//     "CPython>=3.11.3"
//   ],`
I have set up the config file as such:
Copy code
[python]
pip_version = "23.0.1"
interpreter_constraints = ['>=3.11.3']
enable_resolves = true
default_resolve = "poetry"

[python.resolves]
poetry = "pants-poetry.lock"
tickets = "tickets-poetry.lock"
And in my build files for the 3.9.2 project:
Copy code
python_sources(interpreter_constraints=['>=3.9.2'], resolve="tickets")
Additionally for the
poetry_requirements
in the 3.9.2 project:
Copy code
poetry_requirements(
    name="poetry",
    resolve="tickets",
)
This results in the following error:
The inputs use interpreter constraints ('CPython>=3.9.2') that are not a subset of those used to generate the lockfile ('CPython>=3.11.3')
when attempting to build a PEX binary using the project files.
g
It sounds like you need this option to have more fine-grained constraints: https://www.pantsbuild.org/docs/reference-python#resolves_to_interpreter_constraints
a
I don't understand how to specify this option. It seems like it's supposed to be provided as an object, but AFAIK that's not possible in TOML directly? Or is this something that must be provided at runtime?
g
It's in toml!
Copy code
[python.resolves_to_interpreter_constraints]
black = [">=3.9,<3.10"]
asterix = ["==3.10.*"]
It's just the docs showing to provide it as a command-line argument... you can translate all of those to the equivalent toml
👍 1
(Filed this now too; we should document the configuration format that users use! https://github.com/pantsbuild/pants/issues/19705)
❤️ 3
a
Oh, that makes sense! Thanks a lot :-)