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 does not backfill source url for PyPI #3094

Closed
1 task done
NiklasRosenstein opened this issue Aug 12, 2024 · 0 comments · Fixed by #3098
Closed
1 task done

pdm export does not backfill source url for PyPI #3094

NiklasRosenstein opened this issue Aug 12, 2024 · 0 comments · Fixed by #3098
Assignees
Labels
🐛 bug Something isn't working

Comments

@NiklasRosenstein
Copy link

  • 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

# pyproject.toml
[project]
name = "myproject"
version = "0.0.0"
description = "Default template for PDM package"
authors = [
    {name = "Niklas Rosenstein", email = "[email protected]"},
]
dependencies = []
requires-python = ">=3.10"
license = {text = "MIT"}

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm]
distribution = true

[[tool.pdm.source]]
name = "pypi"
# pdm.toml
[pypi]
ignore_stored_index = true

Running pdm export -v gives

❯ pdm export -v
Traceback (most recent call last):
  File "/Users/niklas.rosenstein/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 346, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 264, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 259, in main
    self.handle(project, options)
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 195, in handle
    command.handle(project, options)
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/cli/commands/export.py", line 99, in handle
    content = FORMATS[options.format].export(project, packages, options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/formats/requirements.py", line 230, in export
    url = source["url"]
          ~~~~~~^^^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/tomlkit/items.py", line 1506, in __getitem__
    return cast(Item, self._value[key])
                      ~~~~~~~~~~~^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/tomlkit/container.py", line 624, in __getitem__
    item = self.item(key)
           ^^^^^^^^^^^^^^
  File "/Users/niklas.rosenstein/.local/pipx/venvs/pdm/lib/python3.12/site-packages/tomlkit/container.py", line 466, in item
    raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "url" does not exist.'

Actual behavior

PDM errors because of the missing url key in [[tool.pdm.source]]{name="pypi"}, but other commands fall back to the standard PyPI URL as expected (e.g. pdm install/pdm lock/etc.)

Expected behavior

pdm export understands name = "pypi" and assumes the default URL.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.17.3
Python Interpreter:
  /Users/niklas.rosenstein/myproject/.venv/bin/python (3.10)
Project Root:
  /Users/niklas.rosenstein/myproject
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.4",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "23.6.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 23.6.0: Fri Jul  5 17:56:39 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T8122",
  "python_full_version": "3.10.14",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "darwin"
}
@NiklasRosenstein NiklasRosenstein added the 🐛 bug Something isn't working label Aug 12, 2024
@frostming frostming self-assigned this Aug 13, 2024
frostming added a commit that referenced this issue Aug 13, 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

Successfully merging a pull request may close this issue.

2 participants