Skip to content

Commit

Permalink
fix: can't format requirements when converting to setup.py
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Sep 20, 2024
1 parent 6853a13 commit 856d849
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pdm/backend/hooks/setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,15 @@ def format_setup_py(self, context: Context) -> str:
)

if meta.dependencies:
before.append(f"INSTALL_REQUIRES = {_format_list(meta.dependencies)}\n")
extra.append(" 'install_requires': INSTALL_REQUIRES,\n")
if meta.optional_dependencies:
before.append(
f"EXTRAS_REQUIRE = {_format_dict_list(meta.optional_dependencies)}\n"
f"INSTALL_REQUIRES = {_format_list([str(d) for d in meta.dependencies])}\n"
)
extra.append(" 'install_requires': INSTALL_REQUIRES,\n")
if meta.optional_dependencies:
extras_require = {
k: [str(d) for d in v] for k, v in meta.optional_dependencies.items()
}
before.append(f"EXTRAS_REQUIRE = {_format_dict_list(extras_require)}\n")
extra.append(" 'extras_require': EXTRAS_REQUIRE,\n")
if meta.requires_python is not None:
extra.append(f" 'python_requires': '{meta.requires_python}',\n")
Expand Down

0 comments on commit 856d849

Please sign in to comment.