Skip to content

Commit

Permalink
Merge pull request #179 from nehaljwani/fix-178
Browse files Browse the repository at this point in the history
fix_list_requirements to ensure it is a list to iterate over
  • Loading branch information
marcelotrevisani authored Aug 16, 2020
2 parents 7c657b0 + 8f70ae1 commit f8ca49c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions grayskull/pypi/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ def __fake_distutils_setup(*args, **kwargs):

def _fix_list_requirements(key_deps: str) -> List:
"""Fix when dependencies have lists inside of another sequence"""
if not kwargs.get(key_deps):
return kwargs.get(key_deps)
val_deps = kwargs.get(key_deps)
if not val_deps:
return val_deps
list_req = []
for val in kwargs.get(key_deps):
if isinstance(val_deps, str):
val_deps = [val_deps]
for val in val_deps:
if isinstance(val, (tuple, list)):
list_req.extend(list(map(str, val)))
else:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ def test_injection_distutils_compiler_gsw():
assert data["packages"] == ["gsw"]


def test_injection_distutils_setup_reqs_ensure_list():
pkg_name, pkg_ver = "pyinstaller-hooks-contrib", "2020.7"
recipe = PyPi(name=pkg_name, version=pkg_ver)
data = recipe._get_sdist_metadata(
f"https://pypi.io/packages/source/p/{pkg_name}/{pkg_name}-{pkg_ver}.tar.gz",
pkg_name,
)
assert data.get("setup_requires") == ["setuptools >= 30.3.0"]


def test_merge_pypi_sdist_metadata():
recipe = PyPi(name="gsw", version="3.3.1")
pypi_metadata = recipe._get_pypi_metadata(name="gsw", version="3.3.1")
Expand Down

0 comments on commit f8ca49c

Please sign in to comment.