* 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>
75 lines
2.7 KiB
Python
75 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
from . import test_projects, utils
|
|
|
|
before_test_project = test_projects.new_c_project()
|
|
before_test_project.files["test/spam_test.py"] = r"""
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
from unittest import TestCase
|
|
|
|
PROJECT_DIR = Path(__file__).joinpath("..", "..").resolve()
|
|
|
|
|
|
class TestBeforeTest(TestCase):
|
|
def test_version(self):
|
|
# assert that the Python version as written to pythonversion_bt.txt in the CIBW_BEFORE_TEST step
|
|
# is the same one as is currently running.
|
|
# because of use symlinks in MacOS run this test is also need
|
|
stored_version = PROJECT_DIR.joinpath('pythonversion_bt.txt').read_text()
|
|
print('stored_version', stored_version)
|
|
print('sys.version', sys.version)
|
|
assert stored_version == sys.version
|
|
|
|
def test_prefix(self):
|
|
# check that the prefix also was written
|
|
stored_prefix = PROJECT_DIR.joinpath('pythonprefix_bt.txt').read_text()
|
|
print('stored_prefix', stored_prefix)
|
|
print('sys.prefix', sys.prefix)
|
|
# Works around path-comparison bugs caused by short-paths on Windows e.g.
|
|
# vssadm~1 instead of vssadministrator
|
|
|
|
assert os.path.samefile(stored_prefix, sys.prefix)
|
|
"""
|
|
|
|
|
|
def test(tmp_path):
|
|
project_dir = tmp_path / "project"
|
|
before_test_project.generate(project_dir)
|
|
test_project_dir = project_dir / "dependency"
|
|
test_projects.new_c_project().generate(test_project_dir)
|
|
|
|
before_test_steps = [
|
|
'''python -c "import os, sys; open('{project}/pythonversion_bt.txt', 'w').write(sys.version)"''',
|
|
'''python -c "import os, sys; open('{project}/pythonprefix_bt.txt', 'w').write(sys.prefix)"''',
|
|
]
|
|
|
|
if utils.platform == "pyodide":
|
|
before_test_steps.extend(
|
|
["pyodide build {project}/dependency", "pip install --find-links dist/ spam"]
|
|
)
|
|
else:
|
|
before_test_steps.append("python -m pip install {project}/dependency")
|
|
|
|
before_test = " && ".join(before_test_steps)
|
|
|
|
# build the wheels
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
project_dir,
|
|
add_env={
|
|
# write python version information to a temporary file, this is
|
|
# checked in setup.py
|
|
"CIBW_BEFORE_TEST": before_test,
|
|
"CIBW_TEST_REQUIRES": "pytest",
|
|
# the 'false ||' bit is to ensure this command runs in a shell on
|
|
# mac/linux.
|
|
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
|
|
"CIBW_TEST_COMMAND_WINDOWS": "pytest {project}/test",
|
|
},
|
|
)
|
|
|
|
# also check that we got the right wheels
|
|
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
|
assert set(actual_wheels) == set(expected_wheels)
|