Hello, I am trying to set poetry's pyproject.toml ...
# general
p
Hello, I am trying to set poetry's pyproject.toml file as my python resolve for pants. pants.toml:
Copy code
[source]
marker_filenames = ["pyproject.toml"]

[python]
interpreter_constraints = ["==3.11.*"]
enable_resolves = true
default_resolve = "poetry"

[python.resolves]
poetry = "pyproject.toml"
pyproject.toml
Copy code
[project]
name = "abc"
version = "0.1.0"
description = ""
authors = []
readme = "README.md"
requires-python = ">=3.11"
When I run
Copy code
pants check ::
I get the error
Copy code
ValueError: Invalid requirement '[project]' in pyproject.toml at line 1: Parse error at "'[project'": Expected W:(0-9A-Za-z)
Which indicates that pants is unable to parse the pyproject.toml file poetry generated. Pants version is 2.24.0 and poetry version is 2.1.3. Thanks in advance for any help.
g
I'd suggest you re-read https://www.pantsbuild.org/stable/docs/python/overview/third-party-dependencies and compare your configuration. You shouldn't specify your
[python.resolves]
to point at the pyproject.toml, it should point at your lockfile. You then create a
python_requirements
or
poetry_requirements
to use the pyproject.toml for generating that lockfile.
p
Thank you @gorgeous-winter-99296. I've gone through the document again. Using Poetry's lockfile causes a similar parsing error, when I try to generate-lockfiles.
Copy code
ValueError: Invalid requirement '[[package]]' in poetry.lock at line 3: Parse error at "'[[packag'": Expected W:(0-9A-Za-z)
With this configuration in pants.toml
Copy code
[source]
marker_filenames = ["pyproject.toml"]

[python]
interpreter_constraints = ["==3.11.*"]
enable_resolves = true
default_resolve = "poetry"

[python.resolves]
poetry = "poetry.lock"
And poetry.lock
Copy code
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.

[[package]]
name = "aiohappyeyeballs"
version = "2.6.1"
description = "Happy Eyeballs for asyncio"
optional = false
python-versions = ">=3.9"
groups = ["main"]
files = [
    {file = "aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8"},
    {file = "aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558"},
]
g
Ah, sorry, should've been specific. A pants lock file. Pants does not understand the Poetry lockfile; only the pyproject parts. So you can point it at
pants.lock
instead, or just remove the poetry lock.