diff --git a/news/1935.bugfix.md b/news/1935.bugfix.md new file mode 100644 index 0000000000..afd607cd67 --- /dev/null +++ b/news/1935.bugfix.md @@ -0,0 +1 @@ +Fix format conversion error from Poetry when `tool.poetry.build` doesn't exist. diff --git a/src/pdm/formats/poetry.py b/src/pdm/formats/poetry.py index 7613844759..28a8c7a958 100644 --- a/src/pdm/formats/poetry.py +++ b/src/pdm/formats/poetry.py @@ -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") @@ -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")