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

Some commands trigger KeyError after each change/commit #1536

Closed
1 task done
pawamoy opened this issue Nov 30, 2022 · 2 comments
Closed
1 task done

Some commands trigger KeyError after each change/commit #1536

pawamoy opened this issue Nov 30, 2022 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Nov 30, 2022

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

Exporting requirements Commands like pdm export or pdm install fail each time I commit something, or then change something, since it results in a different version for my current project (e.g. 0.24.2.dev7+g0ed9c36.d20221130). To fix the error, I have to lock again.

This issue is similar to #1288. However note that I don't depend directly on the current project, but rather indirectly. For example: current project is griffe, I specify mkdocstrings[python] in the docs deps, which depends on griffe.

Steps to reproduce

git clone https://github.com/mkdocstrings/griffe
cd griffe

export PYTHON_VERSIONS=3.10
make setup

make check-dependencies  # OK

echo >> README.md
make check-dependencies  # NOT OK

make lock
make check-dependencies  # OK AGAIN

Same thing with pdm install command:

rm pdm.lock
pdm install  # OK
echo >> README.md
pdm install  # NOT OK
pdm lock
pdm install  # OK AGAIN

Actual behavior

% pdm export -f requirements --without-hashes -v
The exported requirements file is no longer cross-platform. Using it on other platforms may cause unexpected result.
Traceback (most recent call last):
  File "/home/pawamoy/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/core.py", line 258, in main
    return Core().main(args)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/core.py", line 190, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/core.py", line 185, in main
    f(project, options)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/cli/commands/export.py", line 71, in handle
    candidates = resolve_candidates_from_lockfile(
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/cli/actions.py", line 144, in resolve_candidates_from_lockfile
    mapping, *_ = resolve(
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/resolver/core.py", line 30, in resolve
    result = resolver.resolve(requirements, max_rounds)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/resolvelib/resolvers.py", line 373, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/resolvelib/resolvers.py", line 213, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/resolvelib/resolvers.py", line 203, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/resolver/providers.py", line 187, in get_dependencies
    deps, requires_python, _ = self.repository.get_dependencies(candidate)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/models/repositories.py", line 78, in get_dependencies
    requirements, requires_python, summary = getter(candidate)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.10/site-packages/pdm/models/repositories.py", line 437, in _get_dependencies_from_lockfile
    return self.candidate_info[self._identify_candidate(candidate)]
KeyError: ('griffe', '0.24.2.dev7+g0ed9c36.d20221130', None, False)

Expected behavior

No key error 😄

Environment Information

% pdm info && pdm info --env 
PDM version:
  2.2.1
Python Interpreter:
  /home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.11.0/bin/python3.11 (3.11)
Project Root:
  /media/data/dev/pdm-repro-griffe
Project Packages:
  /media/data/dev/pdm-repro-griffe/__pypackages__/3.11
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.0",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.0.10-arch2-1",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Sat, 26 Nov 2022 16:51:18 +0000",
  "python_full_version": "3.11.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}
@pawamoy pawamoy added the 🐛 bug Something isn't working label Nov 30, 2022
@pawamoy pawamoy changed the title Export requirements: KeyError after each change/commit Some commands trigger KeyError after each change/commit Nov 30, 2022
@frostming
Copy link
Collaborator

Similar problem solved by #1481 , please try the main branch.

@pawamoy
Copy link
Contributor Author

pawamoy commented Dec 2, 2022

Didn't have the chance to try master, but you released 2.3.0 in the meantime and it seems to be fixed. Thanks a lot!

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

No branches or pull requests

2 participants