Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test test_debug__library_versions fails when versions have leading zeros, but vendor.txt omits them #9461

Closed
pfmoore opened this issue Jan 16, 2021 · 0 comments · Fixed by #9464
Labels
C: debug The debug command C: tests Testing and related things

Comments

@pfmoore
Copy link
Member

pfmoore commented Jan 16, 2021

Environment

  • pip version: 201.0 (pre-release from master)
  • Python version: 3.8
  • OS: Windows

Description
The certifi package includes a leading zero in its published version, 2020.12.05. When vendoring that version without including the leading zero (which is the output pip freeze gives for that version), the test test_debug__library_versions fails with a version conflict.

Expected behavior
The test should pass, as versions 2020.12.05 and 2020.12.5 are equivalent, according to PEP 440.

How to Reproduce
Modify the vendor.txt file on master to have a version of 2020.12.5 for certifi. Run the test test_debug__library_versions. It fails.

Output

====================================================== FAILURES =======================================================
____________________________________________ test_debug__library_versions _____________________________________________

script = <tests.lib.PipTestEnvironment object at 0x0000016ACDCBDCD0>

    def test_debug__library_versions(script):
        """
        Check the library versions normal output.
        """
        args = ['debug']
        result = script.pip(*args, allow_stderr_warning=True)
        print(result.stdout)

        vendored_versions = create_vendor_txt_map()
        for name, value in vendored_versions.items():
>           assert f'{name}=={value}' in result.stdout
E           AssertionError: assert 'certifi==2020.12.5' in 'pip version: pip 21.0.dev0 from c:\\users\\gustav\\appdata\\local\\temp\\pytest-of-gustav\\pytest-4\\pip0\\pip\\src\\...win_amd64\n  cp32-abi3-win_amd64\n  py38-none-win_amd64\n  ...\n  [First 10 tags shown. Pass --verbose to show all.]\n'
E            +  where 'pip version: pip 21.0.dev0 from c:\\users\\gustav\\appdata\\local\\temp\\pytest-of-gustav\\pytest-4\\pip0\\pip\\src\\...win_amd64\n  cp32-abi3-win_amd64\n  py38-none-win_amd64\n  ...\n  [First 10 tags shown. Pass --verbose to show all.]\n' = <tests.lib.TestPipResult object at 0x0000016ACDDB6E20>.stdout

tests\functional\test_debug.py:43: AssertionError
------------------------------------------------ Captured stderr setup ------------------------------------------------
warning: no files found matching 'docs\docutils.conf'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.readthedocs.yml'
warning: no previously-included files found matching '.pre-commit-config.yaml'
warning: no previously-included files found matching '.pre-commit-config-slow.yaml'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'noxfile.py'
warning: no files found matching '*.css' under directory 'docs'
warning: no files found matching '*.rst' under directory 'docs'
warning: no files found matching '*.py' under directory 'docs'
warning: no previously-included files found matching 'src\pip\_vendor\six'
warning: no previously-included files found matching 'src\pip\_vendor\six\moves'
warning: no previously-included files matching '*.pyi' found under directory 'src\pip\_vendor'
no previously-included directories found matching '.github'
no previously-included directories found matching '.azure-pipelines'
no previously-included directories found matching 'docs\build'
no previously-included directories found matching 'news'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
no previously-included directories found matching 'tools'
------------------------------------------------ Captured stdout call -------------------------------------------------
pip version: pip 21.0.dev0 from c:\users\gustav\appdata\local\temp\pytest-of-gustav\pytest-4\pip0\pip\src\pip (python 3.8)
sys.version: 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
sys.executable: C:\Users\Gustav\AppData\Local\Temp\pytest-of-Gustav\pytest-4\test_debug__library_versions0\workspace\venv\Scripts\python.exe
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: cp1252
sys.platform: win32
sys.implementation:
  name: cpython
'cert' config value: global
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): c:\users\gustav\appdata\local\temp\pytest-of-gustav\pytest-4\pip0\pip\src\pip\_vendor\certifi\cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
  appdirs==1.4.4
  CacheControl==0.12.6
  colorama==0.4.4
  contextlib2==0.6.0.post1 (Unable to locate actual module version, using vendor.txt specified version)
  distlib==0.3.1
  distro==1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
  html5lib==1.1
  msgpack==1.0.2 (Unable to locate actual module version, using vendor.txt specified version)
  packaging==20.8
  pep517==0.9.1
  progress==1.5
  pyparsing==2.4.7
  requests==2.25.1
  certifi==2020.12.05 (CONFLICT: vendor.txt suggests version should be 2020.12.5)
  chardet==4.0.0
  idna==2.10
  urllib3==1.26.2
  resolvelib==0.5.4
  retrying==1.3.3 (Unable to locate actual module version, using vendor.txt specified version)
  setuptools==44.0.0 (Unable to locate actual module version, using vendor.txt specified version)
  six==1.15.0
  toml==0.10.2
  webencodings==0.5.1 (Unable to locate actual module version, using vendor.txt specified version)
Compatible tags: 30
  cp38-cp38-win_amd64
  cp38-abi3-win_amd64
  cp38-none-win_amd64
  cp37-abi3-win_amd64
  cp36-abi3-win_amd64
  cp35-abi3-win_amd64
  cp34-abi3-win_amd64
  cp33-abi3-win_amd64
  cp32-abi3-win_amd64
  py38-none-win_amd64
  ...
  [First 10 tags shown. Pass --verbose to show all.]

Note the line "certifi==2020.12.05 (CONFLICT: vendor.txt suggests version should be 2020.12.5)". This can also be seen in the pip debug output.

Analysis

The test was introduced in #7887 by @NoahGorny, and matches versions using string comparison. I believe it should use proper PEP 440 version comparison to confirm that the versions are the same.

@pfmoore pfmoore added C: debug The debug command C: tests Testing and related things labels Jan 16, 2021
bors bot referenced this issue in duckinator/emanate Jan 31, 2021
215: Update pip to 21.0.1 r=duckinator a=pyup-bot


This PR updates [pip](https://pypi.org/project/pip) from **20.3.3** to **21.0.1**.



<details>
  <summary>Changelog</summary>
  
  
   ### 21.0.1
   ```
   ===================

Bug Fixes
---------

- commands: debug: Use packaging.version.parse to compare between versions. (`9461 &lt;https://github.com/pypa/pip/issues/9461&gt;`_)
- New resolver: Download and prepare a distribution only at the last possible
  moment to avoid unnecessary network access when the same version is already
  installed locally. (`9516 &lt;https://github.com/pypa/pip/issues/9516&gt;`_)

Vendored Libraries
------------------

- Upgrade packaging to 20.9
   ```
   
  
  
   ### 21.0
   ```
   =================

Deprecations and Removals
-------------------------

- Drop support for Python 2. (`6148 &lt;https://github.com/pypa/pip/issues/6148&gt;`_)
- Remove support for legacy wheel cache entries that were created with pip
  versions older than 20.0. (`7502 &lt;https://github.com/pypa/pip/issues/7502&gt;`_)
- Remove support for VCS pseudo URLs editable requirements. It was emitting
  deprecation warning since version 20.0. (`7554 &lt;https://github.com/pypa/pip/issues/7554&gt;`_)
- Modernise the codebase after Python 2. (`8802 &lt;https://github.com/pypa/pip/issues/8802&gt;`_)
- Drop support for Python 3.5. (`9189 &lt;https://github.com/pypa/pip/issues/9189&gt;`_)
- Remove the VCS export feature that was used only with editable VCS
  requirements and had correctness issues. (`9338 &lt;https://github.com/pypa/pip/issues/9338&gt;`_)

Features
--------

- Add ``--ignore-requires-python`` support to pip download. (`1884 &lt;https://github.com/pypa/pip/issues/1884&gt;`_)
- New resolver: Error message shown when a wheel contains inconsistent metadata
  is made more helpful by including both values from the file name and internal
  metadata. (`9186 &lt;https://github.com/pypa/pip/issues/9186&gt;`_)

Bug Fixes
---------

- Fix a regression that made ``pip wheel`` do a VCS export instead of a VCS clone
  for editable requirements. This broke VCS requirements that need the VCS
  information to build correctly. (`9273 &lt;https://github.com/pypa/pip/issues/9273&gt;`_)
- Fix ``pip download`` of editable VCS requirements that need VCS information
  to build correctly. (`9337 &lt;https://github.com/pypa/pip/issues/9337&gt;`_)

Vendored Libraries
------------------

- Upgrade msgpack to 1.0.2.
- Upgrade requests to 2.25.1.

Improved Documentation
----------------------

- Render the unreleased pip version change notes on the news page in docs. (`9172 &lt;https://github.com/pypa/pip/issues/9172&gt;`_)
- Fix broken email link in docs feedback banners. (`9343 &lt;https://github.com/pypa/pip/issues/9343&gt;`_)


.. note

    You should *NOT* be adding new change log entries to this file, this
    file is managed by towncrier. You *may* edit previous change logs to
    fix problems like typo corrections or such.

    To add a new change log entry, please see
        https://pip.pypa.io/en/latest/development/contributing/#news-entries

.. towncrier release notes start
   ```
   
  
  
   ### 20.3.4
   ```
   ===================

Features
--------

- ``pip wheel`` now verifies the built wheel contains valid metadata, and can be
  installed by a subsequent ``pip install``. This can be disabled with
  ``--no-verify``. (`9206 &lt;https://github.com/pypa/pip/issues/9206&gt;`_)
- Improve presentation of XMLRPC errors in pip search. (`9315 &lt;https://github.com/pypa/pip/issues/9315&gt;`_)

Bug Fixes
---------

- Fixed hanging VCS subprocess calls when the VCS outputs a large amount of data
  on stderr. Restored logging of VCS errors that was inadvertently removed in pip
  20.2. (`8876 &lt;https://github.com/pypa/pip/issues/8876&gt;`_)
- Fix error when an existing incompatibility is unable to be applied to a backtracked state. (`9180 &lt;https://github.com/pypa/pip/issues/9180&gt;`_)
- New resolver: Discard a faulty distribution, instead of quitting outright.
  This implementation is taken from 20.2.2, with a fix that always makes the
  resolver iterate through candidates from indexes lazily, to avoid downloading
  candidates we do not need. (`9203 &lt;https://github.com/pypa/pip/issues/9203&gt;`_)
- New resolver: Discard a source distribution if it fails to generate metadata,
  instead of quitting outright. This implementation is taken from 20.2.2, with a
  fix that always makes the resolver iterate through candidates from indexes
  lazily, to avoid downloading candidates we do not need. (`9246 &lt;https://github.com/pypa/pip/issues/9246&gt;`_)

Vendored Libraries
------------------

- Upgrade resolvelib to 0.5.4.
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pip
  - Changelog: https://pyup.io/changelogs/pip/
  - Homepage: https://pip.pypa.io/
</details>



Co-authored-by: pyup-bot <github-bot@pyup.io>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: debug The debug command C: tests Testing and related things
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant