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

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

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/1935.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix format conversion error from Poetry when `tool.poetry.build` doesn't exist.
21 changes: 13 additions & 8 deletions src/pdm/formats/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,21 @@ def dev_dependencies(self, value: dict) -> None:

@convert_from()
def includes(self, source: dict[str, list[str] | str]) -> list[str]:
result: list[str] = []
includes: list[str] = []
source_includes: list[str] = []
for item in source.pop("packages", []):
assert isinstance(item, dict)
include = item["include"]
if item.get("from"):
include = f"{item.get('from')}/{include}"
result.append(include)
result.extend(source.pop("include", []))
self.settings.setdefault("build", {})["includes"] = result
includes.append(include)
for item in source.pop("include", []):
if not isinstance(item, dict):
includes.append(item)
else:
dest = source_includes if "sdist" in item.get("format", "") else includes
dest.append(item["path"])
self.settings.setdefault("build", {})["includes"] = includes
raise Unset()

@convert_from("exclude")
Expand All @@ -168,12 +174,11 @@ def excludes(self, value: list[str]) -> None:

@convert_from("build")
def build(self, value: str | dict) -> None:
run_setuptools = True
value = {}
if isinstance(value, dict):
if "generate-setup-file" in value:
run_setuptools = cast(bool, value["generate-setup-file"])
value = value["script"]
self.settings.setdefault("build", {}).update({"setup-script": value, "run-setuptools": run_setuptools})
value["run-setuptools"] = cast(bool, value["generate-setup-file"])
self.settings.setdefault("build", {}).update(value)
raise Unset()

@convert_from("source")
Expand Down