* feat: add Pyodide support Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com> Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com> tests: fix two merge issues Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> fix: include schema Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Try to fix xbuildenv path [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Try to install pyodide-build from main branch Try again Try again Update constraints file Try again Remove unused variable Drop constraints Remove --download option Fix xbuildenv install Try again Try again [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: remove pinning on pyodide Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update for Pyodide 0.26.0a5 * Install pyodide-build from pypi * Update docs/options.md Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> * Unxfail things that look like they were just a version mismatch * refactor: add constraints for pyodide Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * chore: minor cleanup Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Apply suggestions from code review * Apply suggestion from code review * refactor: minor touchup Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * ci: xfail the pyodide test Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * review: use a pinned version of node * fix tests * review: error out on Windows * test: check node & test on macos arm64 * chore: minor cleanup * Add reference to emscripten libc issue * Apply suggestion from code review * review: use a pinned pip in test virtual environment * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore: rework test virtual environment seed packages * chore: workaround direct invocation of pytest This allows to still test direct invocation of `pytest` on most platforms (including pyodide on Linux) but falls back to `python -m pytest` when running pyodide on macOS. * Use release version of pyodide * fix: tests for 0.26.0 & parallel initialization of xbuildenv * Debug CI * fix: test/test_build_frontend_args.py * Revert "Debug CI" This reverts commit 917646cffc96dbfc619c47d1c03a828f447bcdb7. --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
189 lines
5.2 KiB
Python
189 lines
5.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
import nox
|
|
|
|
nox.needs_version = ">=2024.4.15"
|
|
nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"]
|
|
nox.options.default_venv_backend = "uv|virtualenv"
|
|
|
|
DIR = Path(__file__).parent.resolve()
|
|
|
|
|
|
def install_and_run(session: nox.Session, script: str, *args: str, **kwargs: Any) -> str | None:
|
|
deps = nox.project.load_toml(script)["dependencies"]
|
|
session.install(*deps)
|
|
return session.run("python", script, *args, **kwargs)
|
|
|
|
|
|
@nox.session
|
|
def tests(session: nox.Session) -> None:
|
|
"""
|
|
Run the unit and regular tests.
|
|
"""
|
|
session.install("-e.[test]")
|
|
if session.posargs:
|
|
session.run("pytest", *session.posargs)
|
|
else:
|
|
unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else []
|
|
session.run("pytest", "unit_test", *unit_test_args)
|
|
session.run("pytest", "test", "-x", "--durations", "0", "--timeout=2400", "test")
|
|
|
|
|
|
@nox.session
|
|
def lint(session: nox.Session) -> None:
|
|
"""
|
|
Run the linter.
|
|
"""
|
|
session.install("pre-commit")
|
|
session.run("pre-commit", "run", "--all-files", *session.posargs)
|
|
|
|
|
|
@nox.session
|
|
def pylint(session: nox.Session) -> None:
|
|
"""
|
|
Run pylint.
|
|
"""
|
|
|
|
session.install("pylint>=3.2", "-e.")
|
|
session.run("pylint", "cibuildwheel", *session.posargs)
|
|
|
|
|
|
@nox.session
|
|
def check_manifest(session: nox.Session) -> None:
|
|
"""
|
|
Ensure all needed files are included in the manifest.
|
|
"""
|
|
|
|
session.install("check-manifest")
|
|
session.run("check-manifest", *session.posargs)
|
|
|
|
|
|
@nox.session
|
|
def update_constraints(session: nox.Session) -> None:
|
|
"""
|
|
Update the dependencies inplace.
|
|
"""
|
|
|
|
resources = Path("cibuildwheel/resources")
|
|
|
|
if session.venv_backend != "uv":
|
|
session.install("uv>=0.1.23")
|
|
|
|
for minor_version in range(7, 14):
|
|
python_version = f"3.{minor_version}"
|
|
env = os.environ.copy()
|
|
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
|
|
# regenerate the constraints files
|
|
env["UV_CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
|
|
output_file = resources / f"constraints-python{python_version.replace('.', '')}.txt"
|
|
session.run(
|
|
"uv",
|
|
"pip",
|
|
"compile",
|
|
f"--python-version={python_version}",
|
|
"--upgrade",
|
|
resources / "constraints.in",
|
|
f"--output-file={output_file}",
|
|
env=env,
|
|
)
|
|
|
|
shutil.copyfile(
|
|
resources / "constraints-python312.txt",
|
|
resources / "constraints.txt",
|
|
)
|
|
|
|
build_platforms = nox.project.load_toml(resources / "build-platforms.toml")
|
|
pyodides = build_platforms["pyodide"]["python_configurations"]
|
|
for pyodide in pyodides:
|
|
python_version = ".".join(pyodide["version"].split(".")[:2])
|
|
pyodide_version = pyodide["pyodide_version"]
|
|
output_file = resources / f"constraints-pyodide{python_version.replace('.', '')}.txt"
|
|
tmp_file = Path(session.create_tmp()) / "constraints-pyodide.in"
|
|
tmp_file.write_text(f"pip\nbuild[virtualenv]\npyodide-build=={pyodide_version}")
|
|
session.run(
|
|
"uv",
|
|
"pip",
|
|
"compile",
|
|
f"--python-version={python_version}",
|
|
"--upgrade",
|
|
tmp_file,
|
|
f"--output-file={output_file}",
|
|
env=env,
|
|
)
|
|
|
|
|
|
@nox.session
|
|
def update_pins(session: nox.Session) -> None:
|
|
"""
|
|
Update the python, docker and virtualenv pins version inplace.
|
|
"""
|
|
session.install("-e.[bin]")
|
|
session.run("python", "bin/update_pythons.py", "--force")
|
|
session.run("python", "bin/update_docker.py")
|
|
session.run("python", "bin/update_virtualenv.py", "--force")
|
|
session.run("python", "bin/update_nodejs.py", "--force")
|
|
|
|
|
|
@nox.session(reuse_venv=True)
|
|
def update_proj(session: nox.Session) -> None:
|
|
"""
|
|
Update the README inplace.
|
|
"""
|
|
install_and_run(
|
|
session,
|
|
"bin/projects.py",
|
|
"docs/data/projects.yml",
|
|
*session.posargs,
|
|
)
|
|
|
|
|
|
@nox.session(reuse_venv=True)
|
|
def generate_schema(session: nox.Session) -> None:
|
|
"""
|
|
Generate the cibuildwheel.schema.json file.
|
|
"""
|
|
output = install_and_run(session, "bin/generate_schema.py", silent=True)
|
|
assert isinstance(output, str)
|
|
DIR.joinpath("cibuildwheel/resources/cibuildwheel.schema.json").write_text(output)
|
|
|
|
|
|
@nox.session(reuse_venv=True)
|
|
def bump_version(session: nox.Session) -> None:
|
|
"""
|
|
Bump cibuildwheel's version. Interactive.
|
|
"""
|
|
install_and_run(session, "bin/bump_version.py")
|
|
|
|
|
|
@nox.session(python="3.12")
|
|
def docs(session: nox.Session) -> None:
|
|
"""
|
|
Build the docs. Will serve unless --non-interactive
|
|
"""
|
|
session.install("-e.[docs]")
|
|
session.run("mkdocs", "serve" if session.interactive else "build", "--strict", *session.posargs)
|
|
|
|
|
|
@nox.session
|
|
def build(session: nox.Session) -> None:
|
|
"""
|
|
Build an SDist and wheel.
|
|
"""
|
|
|
|
build_p = DIR.joinpath("build")
|
|
if build_p.exists():
|
|
shutil.rmtree(build_p)
|
|
|
|
dist_p = DIR.joinpath("dist")
|
|
if dist_p.exists():
|
|
shutil.rmtree(dist_p)
|
|
|
|
session.install("build")
|
|
session.run("python", "-m", "build")
|