Skip to content

Commit 856d849

Browse files
committed
fix: can't format requirements when converting to setup.py
Signed-off-by: Frost Ming <me@frostming.com>
1 parent 6853a13 commit 856d849

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/pdm/backend/hooks/setuptools.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,15 @@ def format_setup_py(self, context: Context) -> str:
161161
)
162162

163163
if meta.dependencies:
164-
before.append(f"INSTALL_REQUIRES = {_format_list(meta.dependencies)}\n")
165-
extra.append(" 'install_requires': INSTALL_REQUIRES,\n")
166-
if meta.optional_dependencies:
167164
before.append(
168-
f"EXTRAS_REQUIRE = {_format_dict_list(meta.optional_dependencies)}\n"
165+
f"INSTALL_REQUIRES = {_format_list([str(d) for d in meta.dependencies])}\n"
169166
)
167+
extra.append(" 'install_requires': INSTALL_REQUIRES,\n")
168+
if meta.optional_dependencies:
169+
extras_require = {
170+
k: [str(d) for d in v] for k, v in meta.optional_dependencies.items()
171+
}
172+
before.append(f"EXTRAS_REQUIRE = {_format_dict_list(extras_require)}\n")
170173
extra.append(" 'extras_require': EXTRAS_REQUIRE,\n")
171174
if meta.requires_python is not None:
172175
extra.append(f" 'python_requires': '{meta.requires_python}',\n")

0 commit comments

Comments
 (0)