Hi everyone, I have trouble making `pants` work. I...
# general
r
Hi everyone, I have trouble making
pants
work. I am getting the following error.
Copy code
15:49:05.79 [ERROR] 1 Exception encountered:

Engine traceback:
  in `lint` goal

ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython>=3.9' failed with exit code 1.
stdout:

stderr:
No supported version of Pip is compatible with the given targets:
cp311-cp311-macosx_14_0_arm64 interpreter at /Users/achrafmamdouh/.pyenv/versions/3.11.10/bin/python3.11
cp312-cp312-macosx_14_0_arm64 interpreter at /Users/achrafmamdouh/Desktop/studio/.venv/bin/python
I am on
MacOS M3
using
pyenv
, and here is my toml.
Copy code
[GLOBAL]
pants_version = "2.22.1"
backend_packages = [
  "pants.backend.build_files.fmt.black",
  "pants.backend.python",
  "pants.backend.python.lint.docformatter",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.flake8",
  "pants.backend.python.lint.isort",
  "pants.backend.python.typecheck.mypy",
]

[source]
root_patterns = ["/"]

[python]
interpreter_constraints = ["==3.12.*"]
enable_resolves = true
resolves = { python-default = "python-default.lock" }

[python-bootstrap]
search_path = ["<PYENV_LOCAL>"]
h
Huh, I’m not sure where that
CPython>=3.9
is coming from, but it’s a very bad idea to write an unbounded interpreter constraint. Your
"==3.12.*
is better, but even that could be trouble in some cases.
As an experiment, what happens when you pin to a specific patch version of 3.12, say
==3.12.2
or whatever you have installed?
r
It still fails.
Copy code
stderr:
No supported version of Pip is compatible with the given targets:
cp312-cp312-macosx_14_0_arm64 interpreter at /opt/homebrew/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/bin/python3.12
cp313-cp313-macosx_14_0_arm64 interpreter at /opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/bin/python3.13
Updated
pants.toml
Copy code
[python]
interpreter_constraints = ["==3.12.7"]

[python-bootstrap]
search_path = ["/opt/homebrew/bin"]
Same error for
3.13.0
. I was only able to make it work when I used version
3.9.*
and used the python system default in
/usr/bin
which is NOT ideal.
h
No this very much shouldn’t happen
Which linter are you running?
you may have to regenerate its lockfile
the built-in one may not work for your interpreter
r
Thanks @happy-kitchen-89482 for your help. I appreciate that. Ok so
pants test ::
and
pants check ::
all work, but
pants lint ::
still unfortunately still fails even after regenerating the lock file using
pants generate-lockfiles
.
Here are all the backends I am using:
Copy code
backend_packages = [
  "pants.backend.build_files.fmt.black",
  "pants.backend.codegen.protobuf.lint.buf",
  "pants.backend.codegen.protobuf.python",
  "pants.backend.python",
  "pants.backend.python.lint.docformatter",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.flake8",
  "pants.backend.python.lint.isort",
  "pants.backend.python.typecheck.mypy",
]
pants fmt ::
also fails.
I have tracked that the error comes from this linter:
pants.backend.build_files.fmt.black
.
h
And you regenerated the lockfile for
black
, to use your interpreter?
r
How can I find/(re)generate the lockfile for tools (e.g.,
black
)?
h
This is covered here
Pants ships with default lockfiles for various tools, but they may not be valid for your interpreter
So you have to set one up yourself, as described there
r
Great it works.
🎉 1