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

pdm export raises KeyError #1786

Closed
1 task done
he0119 opened this issue Mar 27, 2023 · 1 comment · Fixed by j178/pdm#1
Closed
1 task done

pdm export raises KeyError #1786

he0119 opened this issue Mar 27, 2023 · 1 comment · Fixed by j178/pdm#1
Labels
🐛 bug Something isn't working

Comments

@he0119
Copy link

he0119 commented Mar 27, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

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

Steps to reproduce

  1. checkout https://github.com/nonepkg/nonebot-plugin-all4one/tree/ci/docker
  2. pdm export

Actual behavior

❯ pdm export -v
The exported requirements file is no longer cross-platform. Using it on other platforms may cause unexpected result.
STATUS: Resolving packages from lockfile...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\hmy01\.local\bin\pdm.exe\__main__.py", line 7, in <module>
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 247, in main
    return Core().main(args)
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 181, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 176, in main
    f(project, options)
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\export.py", line 74, in handle
    candidates = resolve_candidates_from_lockfile(project, requirements.values())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\actions.py", line 136, in resolve_candidates_from_lockfile
    mapping, *_ = resolve(
                  ^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\resolver\core.py", line 35, in resolve
    result = resolver.resolve(requirements, max_rounds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\resolvelib\resolvers.py", line 521, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\resolvelib\resolvers.py", line 401, in resolve
    name = min(unsatisfied_names, key=self._get_preference)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\resolvelib\resolvers.py", line 202, in _get_preference
    return self._p.get_preference(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\resolver\providers.py", line 84, in get_preference
    is_backtrack_cause = any(dep.identify() in backtrack_identifiers for dep in self.get_dependencies(candidate))
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\resolver\providers.py", line 176, in get_dependencies
    deps, requires_python, _ = self.repository.get_dependencies(candidate)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\models\repositories.py", line 81, in get_dependencies
    requirements, requires_python, summary = getter(candidate)
                                             ^^^^^^^^^^^^^^^^^
  File "C:\Users\hmy01\.local\pipx\venvs\pdm\Lib\site-packages\pdm\models\repositories.py", line 411, in _get_dependencies_from_lockfile
    return self.candidate_info[self._identify_candidate(candidate)]
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: ('nonebot-adapter-onebot', '2.2.2', None, False)

Expected behavior

no error

Environment Information

❯ pdm info && pdm info --env
PDM version:
  2.4.9
Python Interpreter:
  C:\Users\hmy01\Works\Working\Bot\nonebot-plugin-all4one\.venv\Scripts\python.exe (3.11)
Project Root:
  C:/Users/hmy01/Works/Working/Bot/nonebot-plugin-all4one
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.2",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.22621",
  "python_full_version": "3.11.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@he0119 he0119 added the 🐛 bug Something isn't working label Mar 27, 2023
@he0119
Copy link
Author

he0119 commented Mar 28, 2023

when I use pdm export --no-default, it works.

it seems default group overrides the other groups.

if default:
groups_set.add("default")

for group in selection:
requirements.update(project.get_dependencies(group))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant