添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
怕老婆的瀑布  ·  Leadership·  昨天    · 
小眼睛的脆皮肠  ·  Espresso 閒置資源  |  ...·  10 小时前    · 
没人理的路灯  ·  c++条件变量超时-掘金·  1 年前    · 
谦虚好学的罐头  ·  android bluetooth ...·  2 年前    · 

2.16.0 regression - KeyError: 'Requires-Python' crash when running pdm add in github actions on python 3.8 #2974

Closed
@DetachHead

Description

  • I have searched the issue tracker and believe that this is not a duplicate.
  • when running the pdm add command on python 3.8 in github actions, it crashes with the following error:

    KeyError: 'Requires-Python'
    

    i can't reproduce this locally, but it happens in github actions (windows-latest, ubuntu-latest and macos-latest) on python 3.8 but not 3.12. this bug seems to have been introduced in pdm 2.16.0

    Make sure you run commands with -v flag before pasting the output.

    Steps to reproduce

  • clone https://github.com/DetachHead/test/tree/0b2d5a592e30f2bfc76d8fddedf73b0ef17d6a4b
  • run the following commands in github actions on python 3.8:
    ./pw pdm install -v
    ./pw pdm add pytest==3.8 -v
    

    Actual behavior

    see github actions for the full output: https://github.com/DetachHead/test/actions/runs/9671949594/job/26683445102

     Traceback (most recent call last):
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/bin/pdm", line 8, in <module>
        sys.exit(main())
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/core.py", line 363, in main
        return core.main(args or sys.argv[1:])
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/core.py", line 281, in main
        raise cast(Exception, err).with_traceback(traceback) from None
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/core.py", line 276, in main
        self.handle(project, options)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/core.py", line 212, in handle
        command.handle(project, options)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/cli/commands/add.py", line 69, in handle
        self.do_add(
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/cli/commands/add.py", line 162, in do_add
        resolved = do_lock(
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/cli/actions.py", line 101, in do_lock
        mapping, dependencies = resolve(
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/resolver/core.py", line 39, in resolve
        result = resolver.resolve(requirements, max_rounds)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/resolvelib/resolvers.py", line 546, in resolve
        state = resolution.resolve(requirements, max_rounds=max_rounds)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/resolvelib/resolvers.py", line 426, in resolve
        name = min(unsatisfied_names, key=self._get_preference)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/resolvelib/resolvers.py", line 203, in _get_preference
        return self._p.get_preference(
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/resolver/providers.py", line 135, in get_preference
        deps = self.get_dependencies(candidate)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/resolver/providers.py", line 272, in get_dependencies
        deps, requires_python, _ = self.repository.get_dependencies(candidate)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/models/repositories.py", line 90, in get_dependencies
        requirements, requires_python, summary = getter(candidate)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/models/repositories.py", line 48, in wrapper
        result = func(self, candidate)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/models/repositories.py", line 270, in _get_dependencies_from_metadata
        deps = prepared.get_dependencies_from_metadata()
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/models/candidates.py", line 625, in get_dependencies_from_metadata
        return filter_requirements_with_extras(self.metadata.requires or [], extras)
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/pdm/models/candidates.py", line 618, in metadata
        self.candidate.requires_python = cast(str, result.metadata["Requires-Python"] or "")
      File "/home/runner/work/test/test/.pyprojectx/venvs/pdm-2ad7fbee887cffa1265ac100532e45d2-py3.8/lib/python3.8/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
        raise KeyError(item)
    KeyError: 'Requires-Python'
    

    Expected behavior

    no error

    Environment Information

    "implementation_name": "cpython", "implementation_version": "3.8.18", "os_name": "posix", "platform_machine": "x86_64", "platform_release": "6.5.0-1022-azure", "platform_system": "Linux", "platform_version": "#23~22.04.1-Ubuntu SMP Thu May 9 17:59:24 UTC 2024", "python_full_version": "3.8.18", "platform_python_implementation": "CPython", "python_version": "3.8", "sys_platform": "linux" }