|
7 | 7 | from __future__ import annotations
|
8 | 8 |
|
9 | 9 | import argparse
|
| 10 | +import json |
10 | 11 | import shutil
|
11 | 12 | import sys
|
| 13 | +import urllib.request |
12 | 14 | from pathlib import Path
|
13 | 15 | from typing import TYPE_CHECKING
|
14 | 16 |
|
@@ -206,16 +208,18 @@ def build(session: nox.Session) -> None:
|
206 | 208 | @nox.parametrize("example", EXAMPLES, ids=EXAMPLES)
|
207 | 209 | def test_doc_examples(session: nox.Session, example: str) -> None:
|
208 | 210 | _prepare_cmake_ninja(session)
|
209 |
| - session.install("-e.") |
| 211 | + session.install("-e.", "pip") |
210 | 212 | session.chdir(f"docs/examples/{example}")
|
211 | 213 | reqs = nox.project.load_toml("pyproject.toml")["build-system"]["requires"]
|
212 |
| - session.install(*reqs, "pytest") |
| 214 | + freqs = (r for r in reqs if "scikit-build-core" not in r.replace("_", "-")) |
| 215 | + session.install(*freqs, "pytest") |
213 | 216 | session.install(
|
214 | 217 | ".",
|
215 | 218 | "--no-build-isolation",
|
216 | 219 | "--config-settings=cmake.verbose=true",
|
217 | 220 | env={"PYTHONWARNINGS": "error"},
|
218 | 221 | )
|
| 222 | + session.run("pip", "list") |
219 | 223 | if Path("../test.py").is_file():
|
220 | 224 | session.run("python", "../test.py")
|
221 | 225 | else:
|
@@ -312,15 +316,23 @@ def vendor_pyproject_metadata(session: nox.Session) -> None:
|
312 | 316 | parser.add_argument("version", help="A tag or ref to vendor")
|
313 | 317 | args = parser.parse_args(session.posargs)
|
314 | 318 |
|
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 |
| - ) |
| 319 | + repo = "pypa/pyproject-metadata" |
| 320 | + branch = args.version |
| 321 | + |
| 322 | + with urllib.request.urlopen( |
| 323 | + f"https://api.github.com/repos/{repo}/git/trees/{branch}?recursive=1" |
| 324 | + ) as response: |
| 325 | + info = json.loads(response.read().decode("utf-8")) |
| 326 | + |
| 327 | + files = { |
| 328 | + y: y for x in info["tree"] if (y := x["path"]).startswith("pyproject_metadata/") |
| 329 | + } |
| 330 | + files["pyproject_metadata/LICENSE"] = "LICENSE" |
| 331 | + for tgt_path, remote_path in files.items(): |
| 332 | + local_path = Path("src/scikit_build_core/_vendor").joinpath(tgt_path) |
| 333 | + print(f"Vendoring: {remote_path} -> {local_path}") |
| 334 | + with urllib.request.urlopen( |
| 335 | + f"https://raw.githubusercontent.com/{repo}/{branch}/{remote_path}" |
| 336 | + ) as response: |
| 337 | + txt = response.read() |
| 338 | + local_path.write_bytes(txt) |
0 commit comments