Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into webworker-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking13 committed Aug 3, 2024
2 parents ebe9bb8 + 381c50d commit f4b4d2c
Show file tree
Hide file tree
Showing 22 changed files with 22,504 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:

- name: Compress build artifacts
run: |
tar -czvf packages.tar.gz repodata
tar -czvf packages.tar.gz -C repodata .
- name: Release
uses: softprops/action-gh-release@v1
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
- name: Install test dependencies
run: |
pip install pytest pytest-pyodide pytest-httpserver auditwheel-emscripten pytest-asyncio
pip install -r requirements.txt
- name: Run tests
shell: bash -l {0}
Expand Down
57 changes: 57 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""
Various common utilities for testing.
"""

import re

import pytest
from pytest_pyodide import get_global_config
from pytest_pyodide.utils import package_is_built as _package_is_built


Expand Down Expand Up @@ -80,6 +82,61 @@ def package_is_built(package_name):
return _package_is_built(package_name, pytest.pyodide_dist_dir)


def set_configs():
pytest_pyodide_config = get_global_config()

pytest_pyodide_config.set_flags(
"chrome",
pytest_pyodide_config.get_flags("chrome")
+ [
"--enable-features=WebAssemblyExperimentalJSPI",
"--enable-experimental-webassembly-features",
],
)

pytest_pyodide_config.set_flags(
"node",
pytest_pyodide_config.get_flags("node")
+ ["--experimental-wasm-stack-switching"],
)

pytest_pyodide_config.set_load_pyodide_script(
"chrome",
"""
let pyodide = await loadPyodide({
fullStdLib: false,
jsglobals : self,
enableRunUntilComplete: true,
});
""",
)

pytest_pyodide_config.set_load_pyodide_script(
"node",
"""
const {readFileSync} = require("fs");
let snap = readFileSync("snapshot.bin");
snap = new Uint8Array(snap.buffer);
let pyodide = await loadPyodide({
fullStdLib: false,
jsglobals: self,
_loadSnapshot: snap,
enableRunUntilComplete: true,
});
""",
)


set_configs()


only_node = pytest.mark.xfail_browsers(
chrome="node only", firefox="node only", safari="node only"
)
only_chrome = pytest.mark.xfail_browsers(
node="chrome only", firefox="chrome only", safari="chrome only"
)

requires_jspi = pytest.mark.xfail_browsers(
firefox="requires jspi", safari="requires jspi"
)
4 changes: 0 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ dependencies:
- wget
- setuptools
- gfortran
- pip:
- pytest
- pytest-pyodide==0.58.1
- pytest-httpserver
2 changes: 1 addition & 1 deletion packages/matplotlib/test_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_font_manager(selenium):
# get fontlist from build
fontlist_built = json.loads(json.dumps(fm.FontManager(), cls=fm._JSONEncoder))

# reodering list to compare
# reordering list to compare
for list in ("afmlist", "ttflist"):
for fontlist in (fontlist_vendor, fontlist_built):
fontlist[list].sort(key=lambda x: x["fname"])
Expand Down
4 changes: 2 additions & 2 deletions packages/opencv-python/extras/detect_ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ elseif(OPENCL_INCLUDE_DIR)
else()
set(__opencl_dirs "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2")
endif()
# extra dependencies for buildin code (OpenCL dir is required for extensions like cl_d3d11.h)
# buildin HAVE_OPENCL is already defined through cvconfig.h
# extra dependencies for building code (OpenCL dir is required for extensions like cl_d3d11.h)
# building HAVE_OPENCL is already defined through cvconfig.h
list(APPEND __builtin_include_dirs "${__opencl_dirs}")

# extra dependencies for
Expand Down
8 changes: 7 additions & 1 deletion packages/pygame-ce/test_pygame.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest
from pytest_pyodide import run_in_pyodide

from conftest import package_is_built


@pytest.fixture(scope="function")
def selenium_sdl(selenium_standalone):
Expand Down Expand Up @@ -34,11 +36,15 @@ def test_keyboard_input():
See: https://github.com/pyodide/pyodide/issues/4805#issuecomment-2169077347
TODO: find a better way to test keyboard input
"""

if not package_is_built("pygame-ce"):
pytest.skip("pygame-ce is not built")

from pathlib import Path

from auditwheel_emscripten import get_imports

dist_dir = pytest.pyodide_dist_dir
dist_dir = Path(pytest.pyodide_dist_dir) # type: ignore[attr-defined]
wheel_path = next(dist_dir.glob("pygame_ce-*.whl"))
assert wheel_path.exists()
all_libs = get_imports(wheel_path)
Expand Down
16 changes: 16 additions & 0 deletions packages/pyodide-unix-timezones/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package:
name: pyodide-unix-timezones
version: 1.0.0
top-level:
- unix_timezones
source:
url: https://files.pythonhosted.org/packages/f8/ab/637ae2629dc3e9ed7c192fb80f7fdefe311677138a5a5032872a115eb918/pyodide_unix_timezones-1.0.0-py3-none-any.whl
sha256: 9146c0eda703728571d8e3859043b0bb819c9ef45b9f32680234fade2e57b424
about:
home: https://github.com/joemarshall/pyodide-unix-timezones
PyPI: https://pypi.org/project/pyodide-unix-timezones
summary: Helper package to install unix timezone data on Pyodide
license: MIT
extra:
recipe-maintainers:
- joemarshall
52 changes: 37 additions & 15 deletions packages/pytest/test_pytest.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
def test_pytest(selenium):
# TODO: don't use numpy in this test as it's not necessarily installed.
selenium.load_package(["pytest", "numpy"])
from pytest_pyodide import run_in_pyodide


@run_in_pyodide(packages=["pytest"])
def do_test(selenium, contents):
from contextlib import redirect_stdout
from io import StringIO
from pathlib import Path

import pytest

Path("test_pytest.py").write_text(contents)

selenium.run(
"""
from pathlib import Path
import os
import numpy
import pytest
out = StringIO()
with redirect_stdout(out):
result = pytest.main(["test_pytest.py"])

assert result == 1

out.seek(0)
output = out.read()
assert "2 passed" in output, output
assert "1 failed" in output, output
assert "1 warning" in output, output
assert "This is a warning" in output, output


def test_pytest(selenium):
contents = """
def test_success():
assert 1 == 1
base_dir = Path(numpy.__file__).parent / "core" / "tests"
"""
)
def test_warning():
import warnings
warnings.warn("This is a warning")
selenium.run("pytest.main([str(base_dir / 'test_api.py')])")
def test_fail():
assert 1 == 2
"""

logs = "\n".join(selenium.logs)
assert "INTERNALERROR" not in logs
do_test(selenium, contents)
9 changes: 8 additions & 1 deletion packages/scipy/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ source:
- patches/0005-Remove-test-modules-that-fails-to-build.patch
- patches/0006-Fix-fitpack.patch
- patches/0007-Fix-gees-calls.patch
- patches/0008-MAINT-linalg-Remove-id_dist-Fortran-files.patch
- patches/0009-Mark-mvndst-functions-recursive.patch
- patches/0001-Make-sreorth-recursive.patch

build:
cflags: |
Expand All @@ -50,6 +53,11 @@ build:
# pyodide-build/pyodide_build/_f2c_fixes.py.
script: |
set -x
git clone https://github.com/hoodmane/f2c.git --depth 1
(cd f2c/src && cp makefile.u makefile && sed -i "s/gram.c:/gram.c1:/" makefile && make)
export F2C_PATH=$(pwd)/f2c/src/f2c
echo F2C_PATH: $F2C_PATH
export NPY_BLAS_LIBS="-I$WASM_LIBRARY_DIR/include $WASM_LIBRARY_DIR/lib/libopenblas.so"
export NPY_LAPACK_LIBS="-I$WASM_LIBRARY_DIR/include $WASM_LIBRARY_DIR/lib/libopenblas.so"
Expand Down Expand Up @@ -106,7 +114,6 @@ requirements:
- openblas
executable:
- gfortran
- f2c

test:
imports:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 45a31145679c83f2719b6420f234d484b9459697 Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Fri, 18 Mar 2022 16:25:39 -0700
Subject: [PATCH 1/7] Fix dstevr in special/lapack_defs.h
Subject: [PATCH 1/9] Fix dstevr in special/lapack_defs.h

---
scipy/special/lapack_defs.h | 5 ++---
Expand Down
111 changes: 111 additions & 0 deletions packages/scipy/patches/0001-Make-sreorth-recursive.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
From e4d1a570fa8bd4c710e10400822f60232e6408eb Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Sat, 6 Jul 2024 22:33:51 +0200
Subject: [PATCH] Make sreorth recursive

---
complex16/zreorth.F | 6 +++---
complex8/creorth.F | 6 +++---
double/dreorth.F | 6 +++---
single/sreorth.F | 6 +++---
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/scipy/sparse/linalg/_propack/PROPACK/complex16/zreorth.F b/scipy/sparse/linalg/_propack/PROPACK/complex16/zreorth.F
index ca74f7a..c447a6a 100644
--- a/scipy/sparse/linalg/_propack/PROPACK/complex16/zreorth.F
+++ b/scipy/sparse/linalg/_propack/PROPACK/complex16/zreorth.F
@@ -2,8 +2,8 @@ c
c Rasmus Munk Larsen, Stanford University, 1999, 2004.
c

- subroutine zreorth(n,k,V,ldv,vnew,normvnew,index,alpha,work,
- c iflag)
+ recursive subroutine zreorth(n,k,V,ldv,vnew,normvnew,index,alpha,
+ c work, iflag)
c
c Orthogonalize the N-vector VNEW against a subset of the columns of
c the N-by-K matrix V(1:N,1:K) using iterated classical or modified
@@ -103,7 +103,7 @@ c
c****************************************************************************
c

- subroutine zcgs(n,k,V,ldv,vnew,index,work)
+ recursive subroutine zcgs(n,k,V,ldv,vnew,index,work)

c Block Gram-Schmidt orthogonalization:
c FOR i= 1:l
diff --git a/scipy/sparse/linalg/_propack/PROPACK/complex8/creorth.F b/scipy/sparse/linalg/_propack/PROPACK/complex8/creorth.F
index cd87247..e657a89 100644
--- a/scipy/sparse/linalg/_propack/PROPACK/complex8/creorth.F
+++ b/scipy/sparse/linalg/_propack/PROPACK/complex8/creorth.F
@@ -2,8 +2,8 @@ c
c Rasmus Munk Larsen, Stanford University, 1999, 2004.
c

- subroutine creorth(n,k,V,ldv,vnew,normvnew,index,alpha,work,
- c iflag)
+ recursive subroutine creorth(n,k,V,ldv,vnew,normvnew,index,alpha,
+ c work, iflag)
c
c Orthogonalize the N-vector VNEW against a subset of the columns of
c the N-by-K matrix V(1:N,1:K) using iterated classical or modified
@@ -103,7 +103,7 @@ c
c****************************************************************************
c

- subroutine ccgs(n,k,V,ldv,vnew,index,work)
+ recursive subroutine ccgs(n,k,V,ldv,vnew,index,work)

c Block Gram-Schmidt orthogonalization:
c FOR i= 1:l
diff --git a/scipy/sparse/linalg/_propack/PROPACK/double/dreorth.F b/scipy/sparse/linalg/_propack/PROPACK/double/dreorth.F
index 841208a..fec923e 100644
--- a/scipy/sparse/linalg/_propack/PROPACK/double/dreorth.F
+++ b/scipy/sparse/linalg/_propack/PROPACK/double/dreorth.F
@@ -2,8 +2,8 @@ c
c Rasmus Munk Larsen, Stanford University, 1999, 2004.
c

- subroutine dreorth(n,k,V,ldv,vnew,normvnew,index,alpha,work,
- c iflag)
+ recursive subroutine dreorth(n,k,V,ldv,vnew,normvnew,index,alpha,
+ c work, iflag)
c
c Orthogonalize the N-vector VNEW against a subset of the columns of
c the N-by-K matrix V(1:N,1:K) using iterated classical or modified
@@ -103,7 +103,7 @@ c
c****************************************************************************
c

- subroutine dcgs(n,k,V,ldv,vnew,index,work)
+ recursive subroutine dcgs(n,k,V,ldv,vnew,index,work)

c Block Gram-Schmidt orthogonalization:
c FOR i= 1:l
diff --git a/scipy/sparse/linalg/_propack/PROPACK/single/sreorth.F b/scipy/sparse/linalg/_propack/PROPACK/single/sreorth.F
index 644d404..61b6698 100644
--- a/scipy/sparse/linalg/_propack/PROPACK/single/sreorth.F
+++ b/scipy/sparse/linalg/_propack/PROPACK/single/sreorth.F
@@ -2,8 +2,8 @@ c
c Rasmus Munk Larsen, Stanford University, 1999, 2004.
c

- subroutine sreorth(n,k,V,ldv,vnew,normvnew,index,alpha,work,
- c iflag)
+ recursive subroutine sreorth(n,k,V,ldv,vnew,normvnew,index,alpha,
+ c work, iflag)
c
c Orthogonalize the N-vector VNEW against a subset of the columns of
c the N-by-K matrix V(1:N,1:K) using iterated classical or modified
@@ -103,7 +103,7 @@ c
c****************************************************************************
c

- subroutine scgs(n,k,V,ldv,vnew,index,work)
+ recursive subroutine scgs(n,k,V,ldv,vnew,index,work)

c Block Gram-Schmidt orthogonalization:
c FOR i= 1:l
--
2.34.1

2 changes: 1 addition & 1 deletion packages/scipy/patches/0002-int-to-string.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From d53ade3f03ba3557fd50fb38990d605f4ae7f8f1 Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Sat, 25 Dec 2021 18:04:18 -0800
Subject: [PATCH 2/7] int to string
Subject: [PATCH 2/9] int to string

f2c does not handle implicit casts of function arguments correctly. The msg
argument of `xerrwv` is defined to be an `int *`, and then implicitly cast
Expand Down
2 changes: 1 addition & 1 deletion packages/scipy/patches/0003-gemm_-no-const.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From e528227dd37c8b0512381992c222789a114e3169 Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH 3/7] gemm_ no const
Subject: [PATCH 3/9] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but
other places don't have the cosnt causing compile errors.
Expand Down
2 changes: 1 addition & 1 deletion packages/scipy/patches/0004-make-int-return-values.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From a86a2304fd925f815bbb0e0753e46a7b863e2de2 Mon Sep 17 00:00:00 2001
From: Joe Marshall <[email protected]>
Date: Wed, 6 Apr 2022 21:25:13 -0700
Subject: [PATCH 4/7] make int return values
Subject: [PATCH 4/9] make int return values

The return values of f2c functions are insignificant in most cases, so often it
is treated as returning void, when it really should return int (values are
Expand Down
Loading

0 comments on commit f4b4d2c

Please sign in to comment.