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

Cannot resolve dynamic version in pyproject.toml #3077

Closed
1 task done
amolenaar opened this issue Aug 5, 2024 · 0 comments
Closed
1 task done

Cannot resolve dynamic version in pyproject.toml #3077

amolenaar opened this issue Aug 5, 2024 · 0 comments
Labels
🐛 bug Something isn't working

Comments

@amolenaar
Copy link

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

Steps to reproduce

  1. Check out the project https://github.com/amolenaar/meson-python-pdm-example
  2. Run pdm install
  3. See the error: [KeyError]: 'Version'

NB. This works fine with PDM 2.17.2.

Debug log
$ pdm install -v
STATUS: Resolving packages from lockfile...
unearth.preparer: The file . is a local directory, use it directly
pdm.termui: Running PEP 517 backend to get metadata for <Link file:///home/arjan/Development/meson-python-pdm-example (from None)>
pdm.termui: Preparing environment(Non-isolated mode) for PEP 517 build...
pdm.termui: Failed to build package, try parsing project files.
Traceback (most recent call last):
  File "/home/arjan/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/core.py", line 346, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/core.py", line 264, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/core.py", line 259, in main
    self.handle(project, options)
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/core.py", line 195, in handle
    command.handle(project, options)
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/cli/commands/install.py", line 103, in handle
    actions.do_sync(
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/cli/actions.py", line 330, in do_sync
    synchronizer.synchronize()
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/installers/synchronizers.py", line 341, in synchronize
    to_add, to_update, to_remove = self.compare_with_working_set()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/installers/synchronizers.py", line 167, in compare_with_working_set
    candidates = self.candidates.copy()
                 ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/functools.py", line 995, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/installers/synchronizers.py", line 100, in candidates
    if self.should_install_editables():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/installers/synchronizers.py", line 119, in should_install_editables
    metadata = self.self_candidate.prepare(self.environment).metadata
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/functools.py", line 995, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/installers/synchronizers.py", line 88, in self_candidate
    return self.environment.project.make_self_candidate(not self.no_editable)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/project/core.py", line 543, in make_self_candidate
    can.prepare(self.environment).metadata
  File "/home/arjan/.local/pipx/venvs/pdm/lib64/python3.12/site-packages/pdm/models/candidates.py", line 602, in metadata
    self.candidate.version = result.version
                             ^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 467, in version
    return self.metadata['Version']
           ~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'Version'

Actual behavior

An error. This looks like a regression, as it works fine with PDM 2.17.2.

Expected behavior

It should install the package, as it does with 2.17.2.

Environment Information

PDM version:
  2.17.3
Python Interpreter:
  .../meson-python-pdm-example/.venv/bin/python (3.12)
Project Root:
  .../meson-python-pdm-example
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.4",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.9.11-200.fc40.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu Jul 25 18:17:34 UTC 2024",
  "python_full_version": "3.12.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}
@amolenaar amolenaar added the 🐛 bug Something isn't working label Aug 5, 2024
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

1 participant