Hi, I was upgrading pants all the way from `1.17.0...
# general
f
Hi, I was upgrading pants all the way from
1.17.0
. Now I am at
1.23.0
, and I ran into this error when running
./pants test
, which I have encountered before and solved by specifying the version of
coverage
under
[pytest]
in
pants.ini
.
Copy code
No cached artifacts for 254 targets.
                   Invalidated 254 targets.06:44:34 [WARN] /home/cedriczheng/.cache/pants/setup/bootstrap-Linux-x86_64/1.23.0_py36/lib/python3.6/site-packages/pants/backend/python/tasks/pytest_prep.py:92: DeprecationWarning: DEPRECATED: Pants defaulting to a Python 2-compatible Pytest version will be removed in version 1.25.0.dev2.
  Pants will soon start defaulting to Pytest 5.x, which no longer supports running tests with Python 2. In preparation for this change, you should explicitly set what version of Pytest to use in your `pants.ini` under the section `pytest`.

If you need to keep running tests with Python 2, set `version` to `pytest>=4.6.6,<4.7` (the current default). If you don't have any tests with Python 2 and want the newest Pytest, set `version` to `pytest>=5.2.4`.
  return PyTest.global_instance().get_requirement_strings()

06:44:34 [WARN] /home/cedriczheng/.cache/pants/setup/bootstrap-Linux-x86_64/1.23.0_py36/lib/python3.6/site-packages/pants/backend/python/tasks/pytest_prep.py:92: DeprecationWarning: DEPRECATED: Pants defaulting to a Python 2-compatible Pytest version will be removed in version 1.25.0.dev2.
  Pants will soon start defaulting to Pytest 5.x, which no longer supports running tests with Python 2. In preparation for this change, you should explicitly set what version of Pytest to use in your `pants.ini` under the section `pytest`.

If you need to keep running tests with Python 2, set `version` to `pytest>=4.6.6,<4.7` (the current default). If you don't have any tests with Python 2 and want the newest Pytest, set `version` to `pytest>=5.2.4`.
  return PyTest.global_instance().get_requirement_strings()

**** Failed to install coverage-6.3.2 (caused by: NonZeroExit("received exit code 1 during execution of `['/usr/bin/python2.7', '-s', '-', 'bdist_wheel', '--dist-dir=/tmp/tmp8zl5tznp']` while trying to execute `['/usr/bin/python2.7', '-s', '-', 'bdist_wheel', '--dist-dir=/tmp/tmp8zl5tznp']`",)
):
stdout:

stderr:
Traceback (most recent call last):
  File "<stdin>", line 14, in <module>
  File "<string>", line 80
    classifier_list.append(f"Development Status :: {devstat}")
                                                            ^
SyntaxError: invalid syntax



               Waiting for background workers to finish.
23:44:37 00:47   [complete]
               FAILURE

ERROR: Package SourcePackage('file:///home/cedriczheng/myrepo/.pants.d/python-setup/resolved_requirements/CPython-2.7.12/coverage-6.3.2.tar.gz') is not translateable by ChainedTranslator(WheelTranslator, EggTranslator, SourceTranslator)

(Use --print-exception-stacktrace to see more error details.)
But in previous version (1.22 or 1.21), the instructions suggested me to remove those settings. If I put them back, I will get this error instead:
Copy code
23:51:52 00:04   [complete]
               FAILURE

ERROR: Could not satisfy all requirements for coverage==5.0.3:
    coverage==5.0.3, coverage>=5.2.1(from: pytest-cov<3,>=2.8.1)
I don’t know what to do now…
h
OK, so that error is because
coverage-6.3.2
uses f-strings in its setup.py, so it cannot run on python 2.7.
👍 1
So you're right that you need to pin to an earlier version of coverage
as you're doing with
coverage==5.0.3
it looks like
But this is conflicting with the
coverage>=5.2.1
requirement of the version of
pytest-cov
you're using
It looks like
coverage==5.2.1
still works on Python 2.7, so you can try pinning to that instead of to 5.0.3
f
ok~ thx~
❤️ 1
Now I got this error. It seems that I should pin the version of importlib-metadata?
Copy code
No cached artifacts for 254 targets.
                   Invalidated 254 targets.14:03:36 [WARN] /home/cedriczheng/.cache/pants/setup/bootstrap-Linux-x86_64/1.23.0_py36/lib/python3.6/site-packages/pex/pep425tags.py:274: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

**** Failed to install importlib_metadata-4.11.3 (caused by: NonZeroExit("received exit code 1 during execution of `['/usr/bin/python2.7', '-s', '-', 'bdist_wheel', '--dist-dir=/tmp/tmpwfro9psz']` while trying to execute `['/usr/bin/python2.7', '-s', '-', 'bdist_wheel', '--dist-dir=/tmp/tmpwfro9psz']`",)
):
stdout:

stderr:
Traceback (most recent call last):
  File "<stdin>", line 13, in <module>
IOError: [Errno 2] No such file or directory: 'setup.py'



               Waiting for background workers to finish.
07:03:38 00:04   [complete]
               FAILURE
h
Yes, importlib_metadata-4.11.3 requires Python 3, as you can see here: https://pypi.org/project/importlib-metadata/4.11.3/
Looks like 2.1.3 is the last version that supports Python 2.7
❤️ 1
f
Ok. I found there is this warning related to this. How do I fix this?
Copy code
No cached artifacts for 71 targets.
                   Invalidated 71 targets.14:25:12 [WARN] /home/cedriczheng/.cache/pants/setup/bootstrap-Linux-x86_64/1.23.0_py36/lib/python3.6/site-packages/pex/pep425tags.py:274: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
And how do I pin its version? Is it like this:
Copy code
python_requirement_library(
    name='importlib',
    dependencies=[
        ':importlib-metadata',
    ],
)
@happy-kitchen-89482 I have added
importlib-metadata==2.1.3
in requirement.txt but it still failed. Not sure what’s the correct way to pin the version.