Skip to content

Commit

Permalink
Merge pull request #3199 from regro/grayskull-github-src
Browse files Browse the repository at this point in the history
fix: allow grayskull to run on github urls
  • Loading branch information
beckermr authored Nov 24, 2024
2 parents 842a0d7 + c8e8f9f commit 7b8bd12
Show file tree
Hide file tree
Showing 3 changed files with 1,813 additions and 1 deletion.
45 changes: 44 additions & 1 deletion conda_forge_tick/update_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,50 @@ def make_grayskull_recipe(attrs, version_key="version"):
pkg_version = attrs.get("version_pr_info", {}).get(version_key)
else:
pkg_version = attrs[version_key]
pkg_name = attrs["name"]

src = attrs["meta_yaml"].get("source", {}) or {}
if isinstance(src, dict):
src = [src]
is_pypi = False
is_github = False
for s in src:
if "url" in s:
if any(
pypi_slug in s["url"]
for pypi_slug in [
"/pypi.io/",
"/pypi.org/",
"/pypi.python.org/",
"/files.pythonhosted.org/",
]
):
is_pypi = True
break

if not is_pypi:
for s in src:
if "url" in s:
if "github.com/" in s["url"]:
is_github = True
github_url = s["url"]
break
# we don't know so assume pypi
if not is_pypi and not is_github:
is_pypi = True

if is_pypi:
pkg_name = attrs["name"]
elif is_github:
url_parts = github_url.split("/")
if len(url_parts) < 5:
logger.warning(
"github url %s for grayskull dep update is too short! assuming pypi...",
github_url,
)
pkg_name = attrs["name"]
else:
pkg_name = "/".join(url_parts[:5])

is_noarch = "noarch: python" in attrs["raw_meta_yaml"]
logger.info(
"making grayskull recipe for pkg %s w/ version %s",
Expand Down
13 changes: 13 additions & 0 deletions tests/test_update_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,20 @@ def test_make_grayskull_recipe():
) as f:
attrs = load(f)
recipe = make_grayskull_recipe(attrs)
print(recipe, flush=True)
assert recipe != ""
assert attrs["version"] in recipe


def test_make_grayskull_recipe_github_url():
with open(
os.path.join(os.path.dirname(__file__), "test_yaml", "ngmix.json"),
) as f:
attrs = load(f)
recipe = make_grayskull_recipe(attrs)
print(recipe, flush=True)
assert recipe != ""
assert attrs["version"] in recipe


def test_get_grayskull_comparison():
Expand Down
Loading

0 comments on commit 7b8bd12

Please sign in to comment.