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

add pakcage without peotry config [tool.poetry.build] script would raise keyError #1935

Closed
1 task done
zsluedem opened this issue May 19, 2023 · 1 comment · Fixed by #1938
Closed
1 task done

add pakcage without peotry config [tool.poetry.build] script would raise keyError #1935

zsluedem opened this issue May 19, 2023 · 1 comment · Fixed by #1938
Assignees
Labels
🐛 bug Something isn't working

Comments

@zsluedem
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

pdm add starknet-py

Actual behavior

Adding group default to lockfile
Adding packages to default dependencies: starknet-py
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   starknet-py
pdm.termui:   python>=3.10
pdm.termui:   Adding requirement starknet-py
pdm.termui:   Adding requirement python>=3.10
pdm.termui: ======== Starting round 0 ========
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/cb/98/9c5b8a9ea84614d8d2c26ba815d955f207e8b60a4e15f128c634ef3d5ec7/starknet_py-0.15.2.tar.gz (from https://pypi.org/simple/starknet-py/)>
Traceback (most recent call last):
  File "/home/will/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/core.py", line 268, in main
    return Core().main(args)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/core.py", line 192, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/core.py", line 187, in main
    self.handle(project, options)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/core.py", line 153, in handle
    command.handle(project, options)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/cli/commands/add.py", line 60, in handle
    actions.do_add(
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/cli/actions.py", line 285, in do_add
    resolved = do_lock(
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/cli/actions.py", line 104, in do_lock
    mapping, dependencies = resolve(
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/resolver/core.py", line 35, in resolve
    result = resolver.resolve(requirements, max_rounds)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 426, in resolve
    name = min(unsatisfied_names, key=self._get_preference)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 203, in _get_preference
    return self._p.get_preference(
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/resolver/providers.py", line 85, in get_preference
    is_backtrack_cause = any(dep.identify() in backtrack_identifiers for dep in self.get_dependencies(candidate))
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/resolver/providers.py", line 182, in get_dependencies
    deps, requires_python, _ = self.repository.get_dependencies(candidate)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/repositories.py", line 82, in get_dependencies
    requirements, requires_python, summary = getter(candidate)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/repositories.py", line 41, in wrapper
    result = func(self, candidate)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/repositories.py", line 213, in _get_dependencies_from_metadata
    deps = prepared.get_dependencies_from_metadata()
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/candidates.py", line 510, in get_dependencies_from_metadata
    self.req.project_name, self.metadata.requires or [], extras  # type: ignore[arg-type]
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/candidates.py", line 496, in metadata
    result = self.prepare_metadata()
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/models/candidates.py", line 436, in prepare_metadata
    pyproject = PyProject(pyproject_toml, ui=self.environment.project.core.ui)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/project/toml_file.py", line 18, in __init__
    self._data = self.read()
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/project/project_file.py", line 32, in read
    metadata, settings = converter.convert(None, self._path, None)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/formats/poetry.py", line 199, in convert
    return converter.convert()
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/formats/base.py", line 55, in convert
    self._data[key] = func(self, value)
  File "/home/will/.local/share/pdm/venv/lib/python3.10/site-packages/pdm/formats/poetry.py", line 175, in build
    value = value["script"]
KeyError: 'script'

Expected behavior

Denpendency starknet-py should be added normally.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.6.1
Python Interpreter:
  /chain/zk/test/.venv/bin/python (3.10)
Project Root:
  /chain/zk/test
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.10",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.0-72-generic",
  "platform_system": "Linux",
  "platform_version": "#79-Ubuntu SMP Wed Apr 19 08:22:18 UTC 2023",
  "python_full_version": "3.10.10",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
@zsluedem zsluedem added the 🐛 bug Something isn't working label May 19, 2023
@zsluedem
Copy link
Author

The the pyproject.toml in starknet-py .

[tool.poetry.build]
generate-setup-file = true

doesn't contains script value. I am not sure whether this should be a bug in pdm or a bug in starknet-py

@frostming frostming self-assigned this May 19, 2023
frostming added a commit that referenced this issue May 19, 2023
…ld raise keyError

Fixes #1935

Signed-off-by: Frost Ming <me@frostming.com>
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
2 participants