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

powerful-eye-58407

04/13/2023, 4:30 PM
Maybe someone will find this useful - I've spent some time trying to figure out the cause of this error:
Copy code
$ pants update-build-files --check ::
18:29:33.87 [ERROR] 1 Exception encountered:

Engine traceback:
  in Update all BUILD files

InvalidLockfileError: You are using the `python-default` lockfile at lockfiles/default.lock with incompatible inputs.



- The inputs use interpreter constraints (`CPython<4,>=3.7`) that are not a subset of those used to generate the lockfile (`CPython==3.8.*`).- The input interpreter constraints are specified by your code, using the `[python].interpreter_constraints` option and the `interpreter_constraints` target field.

- To create a lockfile with new interpreter constraints, update the option `[python].resolves_to_interpreter_constraints`, and then generate the lockfile (see below).

See <https://www.pantsbuild.org/v2.16/docs/python-interpreter-compatibility> for details.

To regenerate your lockfile, run `pants generate-lockfiles --resolve=python-default`.

See <https://www.pantsbuild.org/v2.16/docs/python-third-party-dependencies> for details.
👍 1
Some relevant parts of my pants.toml file:
Copy code
[GLOBAL]
pants_version = "2.16.0rc0"

backend_packages = [
  "pants.backend.python",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.flake8",
  "pants.backend.python.typecheck.mypy",
  "pants.backend.docker",
]


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

[python.resolves]
python-default = "lockfiles/default.lock" 

[black]
version = "22.12.0"
install_from_resolve = "python-default"

[pytest]
version = "pytest==7.3.0"
install_from_resolve = "python-default"
requirements=[
  # to use latest possible versions
  "pytest>=7.3.0",
  "pytest-cov>=4.0.0",
  "pytest-xdist>=3.2.1",
  "pytest-pudb",
  "pytest-dotenv",
]
nowhere in the BUILD files interpreter constraints are specified, meaning that all files should use 3.8
turns out this is caused by black...
Copy code
interpreter_constraints = ["==3.8.*"]
adding this in the black section solves it...
👌 1
r

refined-addition-53644

04/13/2023, 5:17 PM
This is because there are default values of interpreter_constraints for these tools but has been removed recently. I suppose this would be fixed in next releases https://github.com/pantsbuild/pants/pull/18714/files
❤️ 2
r

rhythmic-morning-87313

04/16/2023, 5:01 AM
I'm also seeing this error, and having another error when I try to override the pytest version to 7.3.
Copy code
> ./pants test tests/common/test_argparse.py
05:43:11.14 [INFO] Initializing scheduler...
05:43:12.34 [INFO] Scheduler initialized.
05:43:14.28 [INFO] Canceled: Building 17 requirements for requirements.pex from the python.lock resolve: PyJWT~=2.0, aiohttp~=3.8.1, attrs>=20.3, coloredlogs~=15.0, etcetra==0.1.15, multidict>=6.0, packaging>=21.3, pytest>=7.3.1
,... (155 characters truncated)
05:43:14.91 [INFO] Completed: Building 3 requirements for pytest.pex from the tools/pytest.lock resolve: pytest-cov>=2.12,!=2.12.1,<3.1, pytest-xdist>=2.5,<3, pytest==7.0.1
05:43:14.92 [ERROR] 1 Exception encountered:

Engine traceback:
  in `test` goal

ProcessExecutionFailure: Process 'Building 3 requirements for pytest.pex from the tools/pytest.lock resolve: pytest-cov>=2.12,!=2.12.1,<3.1, pytest-xdist>=2.5,<3, pytest==7.0.1' failed with exit code 1.
stdout:

stderr:
Failed to resolve compatible artifacts from lock tools/pytest.lock for 1 target:
1. /home/ubuntu/.pyenv/versions/3.11.3/bin/python3.11:
    Failed to resolve all requirements for cp311-cp311-manylinux_2_35_aarch64 interpreter at /home/ubuntu/.pyenv/versions/3.11.3/bin/python3.11 from tools/pytest.lock:

Configured with:
    build: True
    use_wheel: True

Dependency on pytest-cov not satisfied, 1 incompatible candidate found:
1.) pytest-cov 4 does not satisfy the following requirements:
    !=2.12.1,<3.1,>=2.12 (via: pytest-cov!=2.12.1,<3.1,>=2.12)

Dependency on pytest-xdist not satisfied, 1 incompatible candidate found:
1.) pytest-xdist 3.2.1 does not satisfy the following requirements:
    <3,>=2.5 (via: pytest-xdist<3,>=2.5)

Dependency on pytest not satisfied, 1 incompatible candidate found:
1.) pytest 7.3.1 does not satisfy the following requirements:
    ==7.0.1 (via: pytest==7.0.1)
There seems to be conflicts between the tool's default resolve and my own custom resolve (i've applied
install_from_resolve
along with
pytest-requirements.txt
and
pytest.lock
as instructed in the latest 2.16.0rc0)...