Skip to content

Commit

Permalink
Merge pull request #121 from marcelotrevisani/fix-empty-entry-points
Browse files Browse the repository at this point in the history
Fix empty entry points
  • Loading branch information
marcelotrevisani authored Apr 24, 2020
2 parents cd2d206 + c05bdfe commit 0a4238b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
17 changes: 13 additions & 4 deletions grayskull/pypi/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,24 @@ def _get_entry_points_from_sdist(sdist_metadata: dict) -> List:
:param sdist_metadata: sdist metadata
:return: list with all entry points
"""
all_entry_points = sdist_metadata.get("entry_points", None)
all_entry_points = sdist_metadata.get("entry_points", {})
if isinstance(all_entry_points, str) or not all_entry_points:
return []
if all_entry_points.get("console_scripts") or all_entry_points.get(
"gui_scripts"
):
return all_entry_points.get("console_scripts", []) + all_entry_points.get(
"gui_scripts", []
)
console_scripts = all_entry_points.get("console_scripts", [])
gui_scripts = all_entry_points.get("gui_scripts", [])
entry_points_result = []
if console_scripts:
if isinstance(console_scripts, str):
console_scripts = [console_scripts]
entry_points_result += console_scripts
if gui_scripts:
if isinstance(gui_scripts, str):
gui_scripts = [gui_scripts]
entry_points_result += gui_scripts
return entry_points_result
return []

@staticmethod
Expand Down
20 changes: 20 additions & 0 deletions tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,26 @@ def test_get_entry_points_from_sdist():
}
)
) == sorted(["gui_scripts=entrypoints", "console_scripts=entrypoints"])
assert sorted(
PyPi._get_entry_points_from_sdist(
{
"entry_points": {
"gui_scripts": None,
"console_scripts": "console_scripts=entrypoints",
}
}
)
) == sorted(["console_scripts=entrypoints"])
assert sorted(
PyPi._get_entry_points_from_sdist(
{
"entry_points": {
"gui_scripts": "gui_scripts=entrypoints",
"console_scripts": None,
}
}
)
) == sorted(["gui_scripts=entrypoints"])


def test_build_noarch_skip():
Expand Down

0 comments on commit 0a4238b

Please sign in to comment.