https://pantsbuild.org/ logo
#general
Title
# general
b

brash-baker-91190

05/24/2022, 3:36 PM
I have a question about Python interpreter constraints. I'm moving us from 3.7 to 3.8. In
pants.toml
, I have:
Copy code
[python]
interpreter_constraints = [">=3.8,<4"]

[python-bootstrap]
search_path = ["<PYENV_LOCAL>", "<PYENV>", "<PATH>"]
My
.python-version
file has
3.8.13
. My
black
configuration is:
Copy code
[black]
lockfile = "3rdparty/python/black.lockfile"
version = "black>=22.3.0"
config = "pyproject.toml"
and
black.lockfile
contains the following metadata:
Copy code
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
// {
//   "version": 2,
//   "valid_for_interpreter_constraints": [
//     "CPython<4,>=3.8"
//   ],
//   "generated_with_requirements": [
//     "black>=22.3.0",
//     "typing-extensions>=3.10.0.0; python_version < \"3.10\""
//   ]
// }
// --- END PANTS LOCKFILE METADATA ---
When I run
./pants fmt ::
,
black
runs fine. However, when I run
./pants update-build-files
, I get the following error:
Copy code
11:33:26.58 [ERROR] 1 Exception encountered:

  InvalidLockfileError: You are using the lockfile at 3rdparty/python/black.lockfile to install the tool `black`, but it is not compatible with your configuration: 

- You have set interpreter constraints (`CPython<4,>=3.7`) that are not compatible with those used to generate the lockfile (`CPython<4,>=3.8`). You can fix this by not setting `[black].interpreter_constraints`, or by using a new custom lockfile. 

To regenerate your lockfile based on your current configuration, run `./pants generate-lockfiles --resolve=black`.
Why would
black
work in one instance but not the other, and where might that
>=3.7
constraint be coming from? Thanks in advance!
h

hundreds-father-404

05/24/2022, 3:39 PM
This is https://github.com/pantsbuild/pants/issues/14912, which indeed is very confusing. I don't know how to fix it but it keeps tripping people up
b

brash-baker-91190

05/24/2022, 3:44 PM
Whoa, spooky. The workaround seems to work, though, so thanks for the pointer 👍
👍 1
h

hundreds-father-404

05/24/2022, 3:58 PM
K Stu's suggestion will work I think. Gonna see if I can knock this out today 🤞
🎉 1
Sweet this thread also prompted me to refresh proposal from last week to merge
update-build-files
with either
tailor
or
fmt
(likely soon-to-be-called
fix
) 🙂 https://docs.google.com/document/d/1lpW2qGmhhT4Um6uGHRcpxwsseA7oxH86FE2L2gfBYWU/edit#heading=h.dfo4k0ltaody
It works! Just need tests
2 Views