Skip to content

Commit b74bcae

Browse files
committed
chore: update vendored pyproject-metadata
Signed-off-by: Henry Schreiner <[email protected]>
1 parent f0ae319 commit b74bcae

File tree

8 files changed

+1102
-411
lines changed

8 files changed

+1102
-411
lines changed

noxfile.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from __future__ import annotations
88

99
import argparse
10+
import json
1011
import shutil
1112
import sys
13+
import urllib.request
1214
from pathlib import Path
1315
from typing import TYPE_CHECKING
1416

@@ -312,15 +314,23 @@ def vendor_pyproject_metadata(session: nox.Session) -> None:
312314
parser.add_argument("version", help="A tag or ref to vendor")
313315
args = parser.parse_args(session.posargs)
314316

315-
session.run(
316-
"curl",
317-
"-o",
318-
"src/scikit_build_core/_vendor/pyproject_metadata/__init__.py",
319-
f"https://raw.githubusercontent.com/pypa/pyproject-metadata/{args.version}/pyproject_metadata/__init__.py",
320-
)
321-
session.run(
322-
"curl",
323-
"-o",
324-
"src/scikit_build_core/_vendor/pyproject_metadata/LICENSE",
325-
f"https://raw.githubusercontent.com/pypa/pyproject-metadata/{args.version}/LICENSE",
326-
)
317+
repo = "pypa/pyproject-metadata"
318+
branch = args.version
319+
320+
with urllib.request.urlopen(
321+
f"https://api.github.com/repos/{repo}/git/trees/{branch}?recursive=1"
322+
) as response:
323+
info = json.loads(response.read().decode("utf-8"))
324+
325+
files = {
326+
y: y for x in info["tree"] if (y := x["path"]).startswith("pyproject_metadata/")
327+
}
328+
files["pyproject_metadata/LICENSE"] = "LICENSE"
329+
for tgt_path, remote_path in files.items():
330+
local_path = Path("src/scikit_build_core/_vendor").joinpath(tgt_path)
331+
print(f"Vendoring: {remote_path} -> {local_path}")
332+
with urllib.request.urlopen(
333+
f"https://raw.githubusercontent.com/{repo}/{branch}/{remote_path}"
334+
) as response:
335+
txt = response.read()
336+
local_path.write_bytes(txt)

0 commit comments

Comments
 (0)