testing-cabal / mock

The Python mock library

Home Page:https://docs.python.org/dev/library/unittest.mock.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove universal wheel tag and hide 4.0.0b1 and 4.0.0 releases to stop tools finding them.

lucky499 opened this issue · comments

Hi ,
I am using python2.7 code as my test codebase.
from 5th Feb on when the mock module released it's latest version all my test cases are failing with below error.

File "/usr/lib/python2.7/site-packages/mock/mock.py", line 575
def reset_mock(self, visited=None,*, return_value=False, side_effect=False):
^
SyntaxError: invalid syntax

image

Seems like a duplicate of #478. Mock 4.0.0 is python 3.6+ only and drops support for python 2.7.

Mock is no longer compatible with Python 2.

Please see the documentation and the release metadata.

I'd suggest upgrading your installation tools so that they respect the metadata in pypi, and get off Python 2 as soon as possible.

Totally understand that you are dropping Python 2. However, the 4.0.0 wheel package is published for mock-py2.py3-none-any.whl. I think you should publish that for py3 only. Again, going forward with py3 only, totally understandable. But by publishing v4 like this you also cause a lot of unnecessary breakage... Can you reconsider this ticket please? I'd suggest unpublishing 4.0.0 for py2/py3, and then republishing as 4.0.1 for py3 only.

Yep, that's fair.

I've pulled the bad .whl's from pypi and #485 should fix things going forwards.

Thanks!

The absence of a py2 wheel will just cause the source tarball to be downloaded, no? and then it will fail later on; the key metadata is the python-requires field.

I would direct my honourable(s) colleague to the release metadata I link to above ;-)

python-requires is correct, and has been for all releases I've done, but having a universal wheel up there is wrong, and I'm sure some tools would erroneously download it.

If tooling downloads the source tarball and ignores the python-requires, well, that's on the tool...

Well, what I was referring to was the near-exact same discussion on the PR on testtools from earlier in the week :0. In that the py3 tag doesn't declare python3 compatibility for all python3, python-requires has to be consulted to determine which releases are relevant, and similarly py2 tag; and really the universal wheel semantics are about deterministic builds.

But shrug :). Ce la vie, I accept your point about broken tools, and mock has a much larger user base than testtools.

This issue broke production-related task in our case. As we are still on py2 and did not pin mock, after installation it just broke. I guess that pip should not just find the incompatible version.
Just IMO, but things should not break like this even if support is ended for py2.

@sshishov - I removed the problematic wheels a month ago. What problem(s) are you still seeing?

@cjw296 on our server I can see this still:

(venv)root@1aaf6a2862c7:/home/user# python -V
Python 2.7.6

(venv)root@1aaf6a2862c7:/home/user# pip -V
pip 1.5.4 from /home/user/venv/local/lib/python2.7/site-packages (python 2.7)

(venv)root@1aaf6a2862c7:/home/user# pip install mock==0
Downloading/unpacking mock==0
  Could not find a version that satisfies the requirement mock==0 (from versions: 0.5.0, 0.6.0, 0.6.0, 0.7.0b1, 0.7.0b1, 0.7.0b2, 0.7.0b2, 0.7.0b3, 0.7.0b3, 0.7.0b4, 0.7.0b4, 0.7.0rc1, 0.7.0rc1, 0.7.0, 0.7.0, 0.7.1, 0.7.1, 0.7.2, 0.7.2, 0.8.0, 0.8.0, 1.0b1, 1.0b1, 1.0.0, 1.0.0, 1.0.1, 1.0.1, 1.1.0, 1.1.0, 1.1.1, 1.1.2, 1.1.2, 1.1.3, 1.1.3, 1.1.4, 1.1.4, 1.2.0, 1.2.0, 1.3.0, 1.3.0, 2.0.0, 2.0.0, 3.0.0, 3.0.0, 3.0.1, 3.0.1, 3.0.2, 3.0.2, 3.0.3, 3.0.3, 3.0.4, 3.0.4, 3.0.5, 3.0.5, 4.0.0b1, 4.0.0, 4.0.1)
Cleaning up...
No distributions matching the version for mock==0

As you can see, for python2 versions 4.x.x are available and therefore they are installed in case of not pinned versions.

What can be the reason? Outdated pip, outdated something else?

UPDATE: after updating pip version, the package disappeared. Sorry for disturbing.

(venv)root@1aaf6a2862c7:/home/user# pip -V
pip 20.0.2 from /home/user/venv/local/lib/python2.7/site-packages/pip (python 2.7)

(venv)root@1aaf6a2862c7:/home/user# pip install moc
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: Could not find a version that satisfies the requirement mock==0 (from versions: 0.5.0, 0.6.0, 0.7.0b1, 0.7.0b2, 0.7.0b3, 0.7.0b4, 0.7.0rc1, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 1.0b1, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.2.0, 1.3.0, 2.0.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5)
ERROR: No matching distribution found for mock==0

pip 1.5.4 is really ancient, so yeah, that'll be your problem ;-)