* Fix a typo: pyoodide ➡️ pyodide * Add `pyodide_build_version` attribute * Add version to xbuildenv log step * Add version to Emscripten log step * Use `pyodide-build`'s version for updating constraints * Bump Pyodide constraints by updating `pyodide-build` * Add a schema for `pyodide-version` * Update Pyodide constraints * Bump `pyodide-build` to new 0.29.0 * Test out another Pyodide identifier * Update outdated Pyodide constraints * Add Pyodide version to temp directory name * Remove Pyodide 0.26.1 from build configurations * Retrieve + validate + install specific xbuildenvs * Test wheel builds with Pyodide 0.26.2 * Add correct Pyodide version to identifier temp dir * Don't pre-call Pyodide xbuildenv search * Fetch just the stable Pyodide versions * Refactor search + validation + install into one step * Move all of it under a lock * Reorder xbuildenv installation * Add env and cwd to xbuildenv search call * Temporarily lower to 0.26.2 target * Separate out search, validate, install; again * Run xbuildenv search in `CIBW_CACHE_PATH` * Remove prior `PYODIDE_ROOT` env vars, copy envs * Validate doesn't need to depend on searching * Add file lock when searching xbuildenvs * Test the original version: 0.26.1 * Update Pyodide constraints * Update constraints for `pyodide-build` 0.29.0 again * Bump Pyodide from version 0.26.1 ➡️ version 0.26.4 * Add note on compatibility for macOS + other archs * Note Pyodide version for Pyodide identifier * Docs about `CIBW_PYODIDE_VERSION` * Don't fetch just the stable versions * Discard a variable that's not used later * Rename `search_xbuildenv` ➡️ `get_xbuildenv_versions` * `validate_xbuildenv` ➡️ `validate_xbuildenv_version` * Replace ordered comment, add newline * Replace sentence on macOS support Co-Authored-By: Hood Chatham <roberthoodchatham@gmail.com> * Capitalise: "pyodide" ➡️ "Pyodide" Co-Authored-By: Hood Chatham <roberthoodchatham@gmail.com> * "work" ➡️ "may succeed" Co-Authored-By: Hood Chatham <roberthoodchatham@gmail.com> * Add another job to test a custom Pyodide version * Handle "v"-prefixed + non-prefixed versions * Convert to a proper toml-able option, and remove some hardcoded versions This removes the enscripten and pyodide-build version specs from pyproject.toml - pyodide-build is spec'd in the constraints file, and the emscripten version can be read from the pyodide-build output. * Add a schema entry * Add docs for CIBW_PYODIDE_VERSION * Rephrase * Add tests for pyodide-version * Apply suggestions from code review * Add python_build_standalone util * Hook up to python-build-standalone, removing dependency on host python * Remove python hard-code in action.yml * Add log step * Add workaround for https://github.com/pyodide/pyodide-build/issues/143 * Add emscripten pytest test * Remove unneeded checks * Fix a pytest invoke for emscripten * Generate pyodide-build constraints from the pinned pyodide version * Remove pyodide python-build-standalone workaround * Fixup paths from newer version of pyodide-build * Fix/skip some failing tests * Use `python -m pytest` on pyodide, even on Linux * Docs fixes * Don't call the github API at runtime, cache the release assets instead * Ignore pylint false positive * Add version auto-updating for pyodide * Add support for pyodide 3.13. * Fix tests for multiple pyodide wheels * Remove workaround for unreleased pyodide-build * Rename to "test_pyodide" * Fix pathname confusion * Remove extra github actions job * Fix expectation for test_abi_none * Fix the custom_repair_wheel test to actually have clashing names * Fix pinned version test * Document test-command limitation * Remove pyodide 0.28.0a1 for now * Update constraints files * Docs/test fixes post removing pyodide cp313 * Fix ABI test expectation * Docs improvements * Improve some comments * Remove logic duplication * remove pyodide special casing * Refactor constraints code to use a utility script, circumventing import issues * chore: nicer nox env Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: typo in variable name found by copilot Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Apply suggestions from code review * Some more Pyodide version updates in the docs section * We haven't released Pyodide v0.27.6 yet * Back to the Github URL for cross-build-environments * `pyodide-build`, not `emsdk` for Windows skips Co-Authored-By: Hood Chatham <roberthoodchatham@gmail.com> * Move to a separate `_json_request` function Co-Authored-By: Hood Chatham <roberthoodchatham@gmail.com> * Rename "retries" ➡️ "retry_count" * Add some type hints * Copy env vars before `UV_CUSTOM_COMPILE_COMMAND` * Use `HTTPError.headers.get` instead * Remove extra end quote * Change download tests URL to `https://badssl.com/` Co-Authored-By: Joe Rickerby <1244307+joerick@users.noreply.github.com> * Download size changes, too * Use jsdelivr for Github asset mirroring * Bump to Pyodide v0.27.6 * Fix unit tests * Move to pyodide v0.27.6 again * Bump to pyodide-build 0.30.4 * Use new URL for cross-build environments metadata Co-authored-by: Joe Rickerby <joerick@mac.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com> Co-authored-by: Joe Rickerby <joerick@mac.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Joe Rickerby <1244307+joerick@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
178 lines
5.7 KiB
Python
178 lines
5.7 KiB
Python
import platform
|
|
import re
|
|
import textwrap
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from cibuildwheel.util import resources
|
|
|
|
from . import test_projects, utils
|
|
|
|
project_with_expected_version_checks = test_projects.new_c_project(
|
|
setup_py_add=textwrap.dedent(
|
|
r"""
|
|
import subprocess
|
|
import os
|
|
import sys
|
|
|
|
versions_output_text = subprocess.check_output(
|
|
[sys.executable, '-m', 'pip', 'freeze', '--all', '-qq'],
|
|
universal_newlines=True,
|
|
)
|
|
versions = versions_output_text.strip().splitlines()
|
|
|
|
# `versions` now looks like:
|
|
# ['pip==x.x.x', 'setuptools==x.x.x', 'wheel==x.x.x']
|
|
|
|
print('Gathered versions', versions)
|
|
|
|
expected_version = os.environ['EXPECTED_PIP_VERSION']
|
|
|
|
assert f'pip=={expected_version}' in versions, (
|
|
f'error: pip version should equal {expected_version}'
|
|
)
|
|
"""
|
|
)
|
|
)
|
|
|
|
project_with_expected_version_checks.files["pyproject.toml"] = r"""
|
|
[build-system]
|
|
requires = ["setuptools", "pip"]
|
|
build-backend = "setuptools.build_meta"
|
|
"""
|
|
|
|
VERSION_REGEX = r"([\w-]+)==([^\s]+)"
|
|
|
|
|
|
def get_versions_from_constraint_file(constraint_file: Path) -> dict[str, str]:
|
|
constraint_file_text = constraint_file.read_text(encoding="utf-8")
|
|
|
|
return dict(re.findall(VERSION_REGEX, constraint_file_text))
|
|
|
|
|
|
@pytest.mark.parametrize("python_version", ["3.8", "3.12"])
|
|
def test_pinned_versions(tmp_path, python_version, build_frontend_env_nouv):
|
|
if utils.get_platform() == "linux":
|
|
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
|
|
if python_version != "3.12" and utils.get_platform() == "pyodide":
|
|
pytest.skip(f"pyodide does not support Python {python_version}")
|
|
if (
|
|
python_version == "3.8"
|
|
and utils.get_platform() == "windows"
|
|
and platform.machine() == "ARM64"
|
|
):
|
|
pytest.skip(f"Windows ARM64 does not support Python {python_version}")
|
|
|
|
project_dir = tmp_path / "project"
|
|
project_with_expected_version_checks.generate(project_dir)
|
|
|
|
version_no_dot = python_version.replace(".", "")
|
|
build_environment = {}
|
|
build_pattern = f"[cp]p{version_no_dot}-*"
|
|
if utils.get_platform() == "pyodide":
|
|
constraint_filename = f"constraints-pyodide{version_no_dot}.txt"
|
|
else:
|
|
constraint_filename = f"constraints-python{version_no_dot}.txt"
|
|
constraint_file = resources.PATH / constraint_filename
|
|
constraint_versions = get_versions_from_constraint_file(constraint_file)
|
|
|
|
build_environment["EXPECTED_PIP_VERSION"] = constraint_versions["pip"]
|
|
|
|
cibw_environment_option = " ".join(f"{k}={v}" for k, v in build_environment.items())
|
|
|
|
# build and test the wheels
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
project_dir,
|
|
add_env={
|
|
"CIBW_BUILD": build_pattern,
|
|
"CIBW_ENVIRONMENT": cibw_environment_option,
|
|
**build_frontend_env_nouv,
|
|
},
|
|
)
|
|
|
|
# also check that we got the right wheels
|
|
expected_wheels = [
|
|
w
|
|
for w in utils.expected_wheels("spam", "0.1.0")
|
|
if f"-cp{version_no_dot}" in w or f"-pp{version_no_dot}" in w
|
|
]
|
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|
|
|
|
|
|
@pytest.mark.parametrize("method", ["inline", "file"])
|
|
def test_dependency_constraints(method, tmp_path, build_frontend_env_nouv):
|
|
if utils.get_platform() == "linux":
|
|
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
|
|
|
|
project_dir = tmp_path / "project"
|
|
project_with_expected_version_checks.generate(project_dir)
|
|
|
|
tool_versions = {
|
|
"pip": "23.1.2",
|
|
"delocate": "0.10.3",
|
|
}
|
|
|
|
if method == "file":
|
|
constraints_file = tmp_path / "constraints file.txt"
|
|
constraints_file.write_text(
|
|
textwrap.dedent(
|
|
"""
|
|
pip=={pip}
|
|
delocate=={delocate}
|
|
""".format(**tool_versions)
|
|
)
|
|
)
|
|
dependency_version_option = str(constraints_file)
|
|
elif method == "inline":
|
|
dependency_version_option = "packages: " + " ".join(
|
|
f"{k}=={v}" for k, v in tool_versions.items()
|
|
)
|
|
else:
|
|
msg = f"Unknown method: {method}"
|
|
raise ValueError(msg)
|
|
|
|
build_environment = {}
|
|
|
|
if (
|
|
utils.get_platform() == "windows"
|
|
and method == "file"
|
|
and build_frontend_env_nouv["CIBW_BUILD_FRONTEND"] == "build"
|
|
):
|
|
# GraalPy fails to discover its standard library when a venv is created
|
|
# from a virtualenv seeded executable. See
|
|
# https://github.com/oracle/graalpython/issues/491 and remove this once
|
|
# fixed upstream.
|
|
build_frontend_env_nouv["CIBW_SKIP"] = "gp*"
|
|
|
|
for package_name, version in tool_versions.items():
|
|
env_name = f"EXPECTED_{package_name.upper()}_VERSION"
|
|
build_environment[env_name] = version
|
|
|
|
cibw_environment_option = " ".join(f"{k}={v}" for k, v in build_environment.items())
|
|
|
|
# build and test the wheels
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
project_dir,
|
|
add_env={
|
|
"CIBW_ENVIRONMENT": cibw_environment_option,
|
|
"CIBW_DEPENDENCY_VERSIONS": dependency_version_option,
|
|
**build_frontend_env_nouv,
|
|
},
|
|
)
|
|
|
|
# also check that we got the right wheels
|
|
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
|
|
|
if (
|
|
utils.get_platform() == "windows"
|
|
and method == "file"
|
|
and build_frontend_env_nouv["CIBW_BUILD_FRONTEND"] == "build"
|
|
):
|
|
# See reference to https://github.com/oracle/graalpython/issues/491
|
|
# above
|
|
expected_wheels = [w for w in expected_wheels if "graalpy" not in w]
|
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|