jaraco / keyring

MIT License
1.24k stars 152 forks source link

keyring version requirements on pywin32-ctypes cause install failure #612

Closed andy-maier closed 1 year ago

andy-maier commented 1 year ago

Describe the bug

With the new dependency resolver, pip sometimes gets into the mode of trying multiple versions of packages before choosing one. We now have the situation where pip gets into this mode and tries version 0.1.2 of pywin32-ctypes. This version fails to install together with setuptools>=58.0.0 because pywin32-ctypes uses "use_2to3" and setuptools removed that support in its version 58.0.0. Version 0.2.0 of pywin32-ctypes (which is the latest version) has solved this issue by no longer using "use_2to3". So when pip just installs the latest version of pywin32-ctypes, it works, but when it decides to go hunting around for the right version, it fails when trying version 0.1.2.

What does that have to do with keyring? keyring specifies a requirement of pywin32-ctypes!=0.1.0,!=0.1.1; sys_platform=="win32", which permits 0.1.2 to be installed and thus permits the error to happen when pip gets into this mode.

For us, this fails in Github Actions on "windows-latest" with Python 3.8, 3.9, 3.10 (we do not test 3.11 yet), with:

INFO: pip is looking at multiple versions of pywin32-ctypes to determine which version is compatible with other requirements. This could take a while.
Collecting pywin32-ctypes!=0.1.0,!=0.1.1
  Downloading pywin32-ctypes-0.1.2.tar.gz (24 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  python setup.py egg_info did not run successfully.
  exit code: 1

  [1 lines of output]
  error in pywin32-ctypes setup command: use_2to3 is invalid.
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

This was from today's test run on Python 3.8: https://github.com/zhmcclient/python-zhmcclient/actions/runs/3666135441/jobs/6197669174

I did not analyze why it started failing just this week. The week before, the same test run succeeded on Python 3.8:

Collecting pywin32-ctypes!=0.1.0,!=0.1.1
  Downloading pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB)

Test run: https://github.com/zhmcclient/python-zhmcclient/actions/runs/3610424073/jobs/6084221588

To Reproduce

Steps to reproduce the behavior:

  1. Set up a virtual Python environment on Windows with Python 3.8, 3.9 or 3.10 (we do not test 3.11 yet)
  2. Clone https://github.com/zhmcclient/python-zhmcclient/
  3. In the repo directory, execute make develop

Expected behavior

keyring and its pywin32-ctypes package should install successfully on Windows with Python 3.8, 3.9, 3.10.

This can be achieved by having keyring exclude pywin32-ctypes 0.1.2 in its dependencies. Since you probably don't want to use its initial version 0.0.1 from 2014, this boils down to pywin32-ctypes>=0.2.0, i.e. in setup.cfg:

install_requires =
    pywin32-ctypes>=0.2.0; sys_platform=="win32"
        . . .

Environment

Additional context

None

andy-maier commented 1 year ago

I created PR #613 with a fix.

andy-maier commented 1 year ago

I think we can circumvent the issue by requiring pywin32-ctypes>=0.2.0 in our own dependencies.