Skip to content

Commit 1ee2b11

Browse files
authored
Allow fetching CDTs too (#103)
1 parent 9af99d8 commit 1ee2b11

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.github/workflows/website.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ jobs:
1717
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v5
1818
with:
1919
python-version: '3.10'
20+
21+
- run: python -m pip install -U requests
2022

2123
- name: update JSON payload
2224
run: |
23-
python scripts/all_json.py outputs/ site/feedstock-outputs.json
25+
python scripts/all_json.py outputs/ site/feedstock-outputs.json --with-cdts
2426
2527
- name: deploy
2628
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v3

scripts/all_json.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import argparse
22
import json
3+
import re
34
import sys
5+
from base64 import b64decode
46
from concurrent.futures import ThreadPoolExecutor
57
from pathlib import Path
68

@@ -11,12 +13,31 @@ def read_json(path):
1113
return path.stem, data["feedstocks"]
1214

1315

14-
def main(sources_dir, output_json):
16+
def fetch_cdts():
17+
import requests
18+
19+
r = requests.get("https://api.github.com/repos/conda-forge/cdt-builds/contents/README.md")
20+
r.raise_for_status()
21+
data = r.json()
22+
text = b64decode(data["content"]).decode()
23+
seen = set()
24+
for result in re.finditer(r"\(https://anaconda\.org/conda-forge/([a-z0-9_\-\.\+]+)\)", text):
25+
if result and result.group(1) not in seen:
26+
seen.add(result.group(1))
27+
yield result.group(1)
28+
29+
30+
def main(sources_dir, output_json, with_cdts=False):
1531
jsons = Path(sources_dir).glob("**/*.json")
1632

1733
with ThreadPoolExecutor(4) as executor:
1834
all_packages = {pkg: repos for (pkg, repos) in executor.map(read_json, jsons)}
1935
print(f"Processed {len(all_packages)} packages.")
36+
37+
if with_cdts:
38+
for cdt in fetch_cdts():
39+
all_packages.setdefault(cdt, []).append("cdt-builds")
40+
2041
output_json = Path(output_json)
2142
output_json.parent.mkdir(exist_ok=True, parents=True)
2243
with open(output_json, "w") as f:
@@ -27,6 +48,7 @@ def main(sources_dir, output_json):
2748
parser = argparse.ArgumentParser()
2849
parser.add_argument("sources_dir")
2950
parser.add_argument("output_json")
51+
parser.add_argument("--with-cdts", action="store_true")
3052
args = parser.parse_args()
3153

32-
sys.exit(main(args.sources_dir, args.output_json))
54+
sys.exit(main(args.sources_dir, args.output_json, with_cdts=args.with_cdts))

0 commit comments

Comments
 (0)