I'm trying to set up lockfiles for tools, for inst...
# general
b
I'm trying to set up lockfiles for tools, for instance black. I'm trying to do this in the new way, essentially following the docs but I'm getting an error on interpreter constraints not being a subset of those used to generate the lockfile. In pants.toml I have
Copy code
[python]
interpreter_constraints = ["==3.9.*"]

[python.resolves_to_interpreter_constraints]
black = ["==3.9.*"]
valid_for_interpreter_constraints
in the lockfile is set to
CPython==3.9.*
, yet inputs use
CPython<4, >=3.7
according to the error. Using the deprecated way (i.e. lockfile in the [black] section works fine. Am I missing something? Where else should I be looking for potential mistakes? 🙏
nvm, found a relevant thread
h
Hmm, I wonder if this means that the docs are not informative enough?
b
this issue is specific to black (i.e., needs interpreter_constraints in its section to work), all other tools seem to work fine with the default in python section. So I'd rather say it's a confusing bug
h
Well, it works in the Pants repo itself, for example, so something about your specific setup requires specific interpreter constraints
Can you share your full pants.toml?
b
Copy code
[GLOBAL]
pants_version = "2.16.0"

backend_packages = [
 "pants.backend.build_files.fmt.black",
 "pants.backend.python",
 "pants.backend.python.lint.black",
 "pants.backend.python.lint.isort",
 "pants.backend.python.lint.bandit",
 "pants.backend.python.typecheck.mypy",
 "pants.backend.shell",
 "pants.backend.shell.lint.shfmt",
 "pants.backend.shell.lint.shellcheck",
 "pants.backend.experimental.terraform",
 "pants.backend.docker",
 "pants.backend.docker.lint.hadolint",
]

[environments-preview.names]
linux = "//:docker_x86_64"
local = "//:local_macos"

[python]
interpreter_constraints = ["==3.9.*"]
enable_resolves = true

[python.resolves]
python-default = "3rdparty/python/user_reqs.lock"
black = "3rdparty/python/black.lock"
bandit = "3rdparty/python/bandit.lock"

[python.resolves_to_interpreter_constraints]
python-default = ["==3.9.*"]

[python-bootstrap]
search_path = ["<PYENV>"]

[pytest]
install_from_resolve="python-default"

[black]
interpreter_constraints = ["==3.9.*"]
install_from_resolve="black"
requirements = ["//3rdparty/python:black"]

[bandit]
config = "pyproject.toml"
install_from_resolve="bandit"
requirements = ["//3rdparty/python:bandit"]

[mypy]
args = ["--explicit-package-bases"]
install_from_resolve="python-default"
here it is
I'm more than willing to accept I've screwed up somewhere as well 😄
h
Oh, and what are the inputs from which you generated the
black
resolve?
b
I have this BUILD file if that's what you mean
Copy code
python_requirements(
    name="black",
    source="black-requirements.txt",
    resolve="black",
)

python_requirements(
    name="bandit",
    source="bandit-requirements.txt",
    resolve="bandit",
)
h
That is what I mean, thanks
This does seem like a bug
Are you able to create a toy repo on github that reproduces this?
b
I'll give it a try 👍