Skip to content

Commit

Permalink
chore: vendor updates (#918)
Browse files Browse the repository at this point in the history
From #917. Also fixing the docs job to use the correct scikit-build-core
(local) version.

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Sep 28, 2024
1 parent f0ae319 commit 7636e7b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: yezz123/setup-uv@v4

Expand Down
40 changes: 26 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from __future__ import annotations

import argparse
import json
import shutil
import sys
import urllib.request
from pathlib import Path
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -206,16 +208,18 @@ def build(session: nox.Session) -> None:
@nox.parametrize("example", EXAMPLES, ids=EXAMPLES)
def test_doc_examples(session: nox.Session, example: str) -> None:
_prepare_cmake_ninja(session)
session.install("-e.")
session.install("-e.", "pip")
session.chdir(f"docs/examples/{example}")
reqs = nox.project.load_toml("pyproject.toml")["build-system"]["requires"]
session.install(*reqs, "pytest")
freqs = (r for r in reqs if "scikit-build-core" not in r.replace("_", "-"))
session.install(*freqs, "pytest")
session.install(
".",
"--no-build-isolation",
"--config-settings=cmake.verbose=true",
env={"PYTHONWARNINGS": "error"},
)
session.run("pip", "list")
if Path("../test.py").is_file():
session.run("python", "../test.py")
else:
Expand Down Expand Up @@ -312,15 +316,23 @@ def vendor_pyproject_metadata(session: nox.Session) -> None:
parser.add_argument("version", help="A tag or ref to vendor")
args = parser.parse_args(session.posargs)

session.run(
"curl",
"-o",
"src/scikit_build_core/_vendor/pyproject_metadata/__init__.py",
f"https://raw.githubusercontent.com/pypa/pyproject-metadata/{args.version}/pyproject_metadata/__init__.py",
)
session.run(
"curl",
"-o",
"src/scikit_build_core/_vendor/pyproject_metadata/LICENSE",
f"https://raw.githubusercontent.com/pypa/pyproject-metadata/{args.version}/LICENSE",
)
repo = "pypa/pyproject-metadata"
branch = args.version

with urllib.request.urlopen(
f"https://api.github.com/repos/{repo}/git/trees/{branch}?recursive=1"
) as response:
info = json.loads(response.read().decode("utf-8"))

files = {
y: y for x in info["tree"] if (y := x["path"]).startswith("pyproject_metadata/")
}
files["pyproject_metadata/LICENSE"] = "LICENSE"
for tgt_path, remote_path in files.items():
local_path = Path("src/scikit_build_core/_vendor").joinpath(tgt_path)
print(f"Vendoring: {remote_path} -> {local_path}")
with urllib.request.urlopen(
f"https://raw.githubusercontent.com/{repo}/{branch}/{remote_path}"
) as response:
txt = response.read()
local_path.write_bytes(txt)

0 comments on commit 7636e7b

Please sign in to comment.