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 empty entry points #121

Merged
merged 1 commit into from
Apr 24, 2020
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
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