Skip to content

Commit 5532ca2

Browse files
committed
rebuild-index
1 parent 11ee138 commit 5532ca2

File tree

3 files changed

+64
-97
lines changed

3 files changed

+64
-97
lines changed

.github/workflows/backfill_metadata.yml renamed to .github/workflows/rebuild-index.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: backfill metadata
1+
name: rebuild index
22

33
on:
44
workflow_dispatch:
55

66
jobs:
7-
backfill-metadata:
7+
rebuild-index:
88
runs-on: ubuntu-latest
99
permissions:
1010
id-token: write
@@ -18,4 +18,4 @@ jobs:
1818
with:
1919
workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
2020
service_account: [email protected]
21-
- run: python3 -uS bin/backfill-core-metadata --pypi-url https://pypi.devinfra.sentry.io
21+
- run: python3 -uS bin/rebuild-index --pypi-url https://pypi.devinfra.sentry.io

bin/backfill-core-metadata

Lines changed: 0 additions & 94 deletions
This file was deleted.

bin/rebuild-index

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
from __future__ import annotations
3+
4+
import argparse
5+
import os.path
6+
import shutil
7+
import subprocess
8+
import sys
9+
import tempfile
10+
import urllib.parse
11+
import urllib.request
12+
from collections.abc import Sequence
13+
14+
15+
def main(argv: Sequence[str] | None = None) -> int:
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument("--pypi-url", required=True)
18+
args = parser.parse_args(argv)
19+
20+
url = urllib.parse.urljoin(args.pypi_url, "packages.json")
21+
22+
with tempfile.TemporaryDirectory() as tmpdir:
23+
packages_json = f"{tmpdir}/packages.json"
24+
with urllib.request.urlopen(url) as resp, open(packages_json, "wb") as f:
25+
shutil.copyfileobj(resp, f)
26+
27+
index = f"{tmpdir}/index"
28+
os.makedirs(index)
29+
30+
subprocess.check_call(
31+
(
32+
sys.executable,
33+
"-mdumb_pypi.main",
34+
f"--package-list-json={packages_json}",
35+
f"--output-dir={index}",
36+
f'--packages-url={urllib.parse.urljoin(args.pypi_url, "wheels")}',
37+
"--title=sentry pypi",
38+
"--logo=https://avatars.githubusercontent.com/u/1396951?s=24",
39+
"--logo-width=36",
40+
)
41+
)
42+
43+
subprocess.check_call(
44+
(
45+
"gcloud",
46+
"storage",
47+
"cp",
48+
# clobber, no caching
49+
"--cache-control",
50+
"no-store",
51+
"-r",
52+
*(os.path.join(index, name) for name in os.listdir(index)),
53+
"gs://pypi.devinfra.sentry.io",
54+
)
55+
)
56+
57+
return 0
58+
59+
60+
if __name__ == "__main__":
61+
raise SystemExit(main())

0 commit comments

Comments
 (0)