Hi all, another question regarding my python2 jour...
# general
l
Hi all, another question regarding my python2 journey, I have a package that I need to be py2/py3 compatible, but I’m getting this error when generating the lockfiles:
Copy code
./pants generate-lockfiles
19:13:42.49 [INFO] Completed: Generate lockfile for py2-py3
19:13:45.85 [INFO] Completed: Generate lockfile for pytest
19:13:45.85 [ERROR] 1 Exception encountered:

Engine traceback:
  in `generate-lockfiles` goal
  in Generate Python lockfile

ProcessExecutionFailure: Process 'Generate lockfile for pytest' failed with exit code 1.
stdout:

stderr:
pid 73099 -> /Users/anler/.cache/pants/named_caches/pex_root/venvs/41379f21c5956cff0d35ab1ef014bb72e1fe14dc/336e97e279ba29b2edc4ace827e24d29cc9b0af8/bin/python -sE /Users/anler/.cache/pants/named_caches/pex_root/venvs/41379f21c5956cff0d35ab1ef014bb72e1fe14dc/336e97e279ba29b2edc4ace827e24d29cc9b0af8/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /Users/anler/.cache/pants/named_caches/pex_root/pip_cache --log /private/var/folders/z6/y9s0fw1s0k1fmn_9cxyfllrm0000gn/T/pants-sandbox-GCDvla/.tmp/pex-pip-log.lij6zsvc/pip.log download --dest /private/var/folders/z6/y9s0fw1s0k1fmn_9cxyfllrm0000gn/T/pants-sandbox-GCDvla/.tmp/tmp8_cj67j2/Users.anler..pyenv.versions.3.10.9.bin.python3.10 pytest==7.0.1 pytest-cov>=2.12,!=2.12.1,<3.1 pytest-xdist>=2.5,<3 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
ERROR: Could not find a version that satisfies the requirement pytest==7.0.1
ERROR: No matching distribution found for pytest==7.0.1
My
pants.toml
looks like this:
Copy code
[python.resolves]
python-default = "resolves/python-default.lock"
py2-py3 = "resolves/py2-py3.lock"

[pytest]
lockfile = "resolves/pytest.lock"
and the test target for my package like this:
Copy code
python_tests(
    name="tests",
    resolve="py2-py3",
    interpreter_constraints=parametrize(py2=["==2.7.*"], py3=[">3.6"]),
)
e
Aha. So Pants support multiple resolves for your code, but not so tools.
I think Benjy is getting us there...
h
Pytest 4.6.x is the last version to support Python 2.7
So you'll have to downgrade
Yeah, I am chiseling away at the distinction between tool lockfiles and user lockfiles, so we can have just one concept
l
oh I see, darn, that python2 code keeps giving me headaches ¬¬
thanks @happy-kitchen-89482 maybe I’ll try to hack things a bit and use a downgraded pytest when testing those python2 packages