From 87a3fae560950bb07b6c143ba0778a7b68c34214 Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Thu, 22 Jan 2026 18:53:12 +0200 Subject: [PATCH 1/5] Add CI for Pyodide --- .github/workflows/pyodide.yml | 82 ++++++++++ pyodide-recipes/packages/.gitignore | 4 + pyodide-recipes/packages/libsleef/meta.yaml | 84 ++++++++++ .../libsleef/patches/0001-no-x86intrin.patch | 153 ++++++++++++++++++ .../libsleef/patches/0002-no-mfpmatch.patch | 19 +++ .../0003-fix-purecfma-scalar-x86.patch | 101 ++++++++++++ .../libsleef/patches/0004-no-cpuid.patch | 82 ++++++++++ .../packages/numpy-quaddtype/.gitignore | 1 + .../packages/numpy-quaddtype/meta.yaml | 20 +++ pyodide-recipes/packages/numpy/meta.yaml | 38 +++++ 10 files changed, 584 insertions(+) create mode 100644 .github/workflows/pyodide.yml create mode 100644 pyodide-recipes/packages/.gitignore create mode 100644 pyodide-recipes/packages/libsleef/meta.yaml create mode 100644 pyodide-recipes/packages/libsleef/patches/0001-no-x86intrin.patch create mode 100644 pyodide-recipes/packages/libsleef/patches/0002-no-mfpmatch.patch create mode 100644 pyodide-recipes/packages/libsleef/patches/0003-fix-purecfma-scalar-x86.patch create mode 100644 pyodide-recipes/packages/libsleef/patches/0004-no-cpuid.patch create mode 100644 pyodide-recipes/packages/numpy-quaddtype/.gitignore create mode 100644 pyodide-recipes/packages/numpy-quaddtype/meta.yaml create mode 100644 pyodide-recipes/packages/numpy/meta.yaml diff --git a/.github/workflows/pyodide.yml b/.github/workflows/pyodide.yml new file mode 100644 index 0000000..78d0cef --- /dev/null +++ b/.github/workflows/pyodide.yml @@ -0,0 +1,82 @@ +name: Pyodide Tests + +on: + pull_request: + branches: + - main + workflow_dispatch: + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + pyodide_tests: + name: Test on Pyodide + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: 3.13.2 + + - name: Setup Emscripten + uses: mymindstorm/setup-emsdk@v14 + with: + version: 4.0.9 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: 22 + + - name: Install build dependencies for sdist + run: | + python -m pip install --upgrade pip build + + - name: Build sdist and unpack for Pyodide + run: | + python -m build --sdist --outdir dist + mkdir -p pyodide-recipes/packages/numpy-quaddtype + tar -xvzf "$(ls dist/*.tar.gz)" -C pyodide-recipes/packages/numpy-quaddtype + rm -rf dist + + - name: Install pyodide-build + run: python -m pip install pyodide-build + + - name: Install the Pyodide build env + run: pyodide xbuildenv install 0.29.2 + + - name: Build compiled dependencies for Pyodide + run: | + pyodide build-recipes \ + --recipe-dir tools/ci/pyodide-recipes/packages \ + --install \ + numpy numpy-quaddtype + + - name: Clean the Pyodide dist + run: find dist/ -type f ! -name '*.whl' -delete + + - name: Create the Pyodide venv + run: | + # Set up Pyodide venv + pyodide venv .venv-pyodide + source .venv-pyodide/bin/activate + # Install numpy + python -m pip install $(ls dist/numpy-*.whl) + # Install numpy-quaddtype with test dependencies + python -m pip install "$(ls dist/numpy_quaddtype-*.whl)"[test] + + - name: Run tests + run: | + source .venv-pyodide/bin/activate + python -m pytest -s tests diff --git a/pyodide-recipes/packages/.gitignore b/pyodide-recipes/packages/.gitignore new file mode 100644 index 0000000..04ddb16 --- /dev/null +++ b/pyodide-recipes/packages/.gitignore @@ -0,0 +1,4 @@ +/.libs/ +/*/build/ +/*/build.log +/*/dist/ diff --git a/pyodide-recipes/packages/libsleef/meta.yaml b/pyodide-recipes/packages/libsleef/meta.yaml new file mode 100644 index 0000000..c34da46 --- /dev/null +++ b/pyodide-recipes/packages/libsleef/meta.yaml @@ -0,0 +1,84 @@ +package: + name: libsleef + version: 3.9.0 + tag: + - library + - static_library +source: + sha256: af60856abac08a3b5e72a8d156dd71fec1f7ac23de8ee67793f45f9edcdf0908 + url: https://github.com/shibatch/sleef/archive/refs/tags/3.9.0.tar.gz + patches: + - patches/0001-no-x86intrin.patch + - patches/0002-no-mfpmatch.patch + - patches/0003-fix-purecfma-scalar-x86.patch + - patches/0004-no-cpuid.patch +build: + type: static_library + script: | + mkdir build-native + cd build-native + + mkdir my-install + + export NATIVE_BUILD_DIR=`pwd` + + BACKUP_TOOLCHAIN=${CMAKE_TOOLCHAIN_FILE} + unset CMAKE_TOOLCHAIN_FILE + + cmake \ + -DCMAKE_INSTALL_PREFIX=$(pwd)/my-install \ + -DCMAKE_BUILD_TYPE=Release \ + -DSLEEF_BUILD_QUAD=ON \ + -DSLEEF_BUILD_SHARED_LIBS=OFF \ + -DSLEEF_BUILD_TESTS=OFF \ + -DSLEEF_BUILD_INLINE_HEADERS=OFF \ + -DSLEEF_BUILD_GNUABI_LIBS=OFF \ + -DSLEEF_ENABLE_TLFLOAT=OFF \ + -DSLEEF_ENABLE_TESTER4=OFF \ + -DSLEEF_DISABLE_FFTW=ON \ + -DSLEEF_DISABLE_MPFR=ON \ + -DSLEEF_DISABLE_SSL=ON \ + -DSLEEF_DISABLE_OPENMP=ON \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + ../ + + make -j ${PYODIDE_JOBS:-3} + + export CMAKE_TOOLCHAIN_FILE=${BACKUP_TOOLCHAIN} + + cd .. + mkdir build + cd build + + emcmake cmake \ + -DCMAKE_INSTALL_PREFIX=${WASM_LIBRARY_DIR} \ + -DCMAKE_BUILD_TYPE=Release \ + -DSLEEF_BUILD_QUAD=ON \ + -DSLEEF_BUILD_SHARED_LIBS=OFF \ + -DSLEEF_BUILD_TESTS=OFF \ + -DSLEEF_BUILD_INLINE_HEADERS=OFF \ + -DSLEEF_BUILD_GNUABI_LIBS=OFF \ + -DSLEEF_ENABLE_TLFLOAT=OFF \ + -DSLEEF_ENABLE_TESTER4=OFF \ + -DSLEEF_DISABLE_FFTW=ON \ + -DSLEEF_DISABLE_MPFR=ON \ + -DSLEEF_DISABLE_SSL=ON \ + -DSLEEF_DISABLE_OPENMP=ON \ + -DSLEEF_DISABLE_SSE2=OFF \ + -DSLEEF_DISABLE_AVX2=ON \ + -DSLEEF_DISABLE_AVX512F=ON \ + -DSLEEF_DISABLE_PURECFMA_SCALAR=ON \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DNATIVE_BUILD_DIR=${NATIVE_BUILD_DIR} \ + -DCMAKE_C_FLAGS="-msimd128 -msse2" \ + -DCMAKE_CXX_FLAGS="-msimd128 -msse2" \ + ../ + + emmake make -j ${PYODIDE_JOBS:-3} + emmake make install + + mkdir -p dist + cp ${WASM_LIBRARY_DIR}/lib/libsleef* dist/ +about: + home: https://github.com/shibatch/sleef + license: Boost Software License - Version 1.0 diff --git a/pyodide-recipes/packages/libsleef/patches/0001-no-x86intrin.patch b/pyodide-recipes/packages/libsleef/patches/0001-no-x86intrin.patch new file mode 100644 index 0000000..e017fa2 --- /dev/null +++ b/pyodide-recipes/packages/libsleef/patches/0001-no-x86intrin.patch @@ -0,0 +1,153 @@ +diff --git a/Configure.cmake b/Configure.cmake +index e23f577..6741a6e 100644 +--- a/Configure.cmake ++++ b/Configure.cmake +@@ -495,7 +495,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE2) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + int main() { + __m128d r = _mm_mul_pd(_mm_set1_pd(1), _mm_set1_pd(2)); }" +@@ -514,7 +514,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE4) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + int main() { + __m128d r = _mm_floor_sd(_mm_set1_pd(1), _mm_set1_pd(2)); }" +@@ -533,7 +533,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + int main() { + __m256d r = _mm256_add_pd(_mm256_set1_pd(1), _mm256_set1_pd(2)); +@@ -552,7 +552,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_FMA4) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + int main() { + __m256d r = _mm256_macc_pd(_mm256_set1_pd(1), _mm256_set1_pd(2), _mm256_set1_pd(3)); }" +@@ -571,7 +571,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX2) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + int main() { + __m256i r = _mm256_abs_epi32(_mm256_set1_epi32(1)); }" +@@ -595,7 +595,7 @@ if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX512F) + #if defined(_MSC_VER) + #include + #else +- #include ++ #include + #endif + __m512 addConstant(__m512 arg) { + return _mm512_add_ps(arg, _mm512_set1_ps(1.f)); +diff --git a/src/arch/helperavx.h b/src/arch/helperavx.h +index 08b81b0..5596498 100644 +--- a/src/arch/helperavx.h ++++ b/src/arch/helperavx.h +@@ -42,7 +42,7 @@ + #if defined(_MSC_VER) + #include + #else +-#include ++#include + #endif + + #include +diff --git a/src/arch/helperavx2.h b/src/arch/helperavx2.h +index 8e71de3..2872cd9 100644 +--- a/src/arch/helperavx2.h ++++ b/src/arch/helperavx2.h +@@ -40,7 +40,7 @@ + #if defined(_MSC_VER) + #include + #else +-#include ++#include + #endif + + #include +diff --git a/src/arch/helperavx2_128.h b/src/arch/helperavx2_128.h +index 2d1142b..4fa0f8f 100644 +--- a/src/arch/helperavx2_128.h ++++ b/src/arch/helperavx2_128.h +@@ -40,7 +40,7 @@ + #if defined(_MSC_VER) + #include + #else +-#include ++#include + #endif + + #include +diff --git a/src/arch/helperavx512f.h b/src/arch/helperavx512f.h +index 20c5118..2b3da9a 100644 +--- a/src/arch/helperavx512f.h ++++ b/src/arch/helperavx512f.h +@@ -43,7 +43,7 @@ + #if defined(_MSC_VER) + #include + #else +-#include ++#include + #endif + + #include +diff --git a/src/arch/helpersse2.h b/src/arch/helpersse2.h +index 349f06e..d6bee48 100644 +--- a/src/arch/helpersse2.h ++++ b/src/arch/helpersse2.h +@@ -46,7 +46,7 @@ + #if defined(_MSC_VER) + #include + #else +-#include ++#include + #endif + + #include +diff --git a/src/common/misc.h b/src/common/misc.h +index fadcd1a..c0a2bcf 100644 +--- a/src/common/misc.h ++++ b/src/common/misc.h +@@ -281,9 +281,7 @@ typedef struct { + #define LIKELY(condition) (condition) + #define UNLIKELY(condition) (condition) + +-#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) && !defined(SLEEF_GENHEADER) +-#include +-#endif ++#include + + #define SLEEF_INFINITY (1e+300 * 1e+300) + #define SLEEF_NAN (SLEEF_INFINITY - SLEEF_INFINITY) +diff --git a/src/libm/sleeflibm_header.h.org.in b/src/libm/sleeflibm_header.h.org.in +index abf1d0a..b9ebf33 100644 +--- a/src/libm/sleeflibm_header.h.org.in ++++ b/src/libm/sleeflibm_header.h.org.in +@@ -55,9 +55,7 @@ extern "C" + #define SLEEF_IMPORT + #endif // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) + +-#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) +-#include +-#endif ++#include + + #if (defined(_MSC_VER)) + #include diff --git a/pyodide-recipes/packages/libsleef/patches/0002-no-mfpmatch.patch b/pyodide-recipes/packages/libsleef/patches/0002-no-mfpmatch.patch new file mode 100644 index 0000000..c7c7963 --- /dev/null +++ b/pyodide-recipes/packages/libsleef/patches/0002-no-mfpmatch.patch @@ -0,0 +1,19 @@ +diff --git a/Configure.cmake b/Configure.cmake +index 6741a6e..e029751 100644 +--- a/Configure.cmake ++++ b/Configure.cmake +@@ -276,10 +276,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|QCC)") + set(FLAGS_FASTMATH "-ffast-math") + set(FLAGS_NOSTRICTALIASING "-fno-strict-aliasing") + +- if (SLEEF_ARCH_X86 AND SLEEF_ARCH_32BIT) +- string(CONCAT FLAGS_STRICTMATH ${FLAGS_STRICTMATH} " -msse2 -mfpmath=sse") +- string(CONCAT FLAGS_FASTMATH ${FLAGS_FASTMATH} " -msse2 -mfpmath=sse") +- endif() ++ # if (SLEEF_ARCH_X86 AND SLEEF_ARCH_32BIT) ++ # string(CONCAT FLAGS_STRICTMATH ${FLAGS_STRICTMATH} " -msse2 -mfpmath=sse") ++ # string(CONCAT FLAGS_FASTMATH ${FLAGS_FASTMATH} " -msse2 -mfpmath=sse") ++ # endif() + + # Without the options below, gcc generates calls to libm + string(CONCAT FLAGS_OTHERS "-fno-math-errno -fno-trapping-math") diff --git a/pyodide-recipes/packages/libsleef/patches/0003-fix-purecfma-scalar-x86.patch b/pyodide-recipes/packages/libsleef/patches/0003-fix-purecfma-scalar-x86.patch new file mode 100644 index 0000000..abae853 --- /dev/null +++ b/pyodide-recipes/packages/libsleef/patches/0003-fix-purecfma-scalar-x86.patch @@ -0,0 +1,101 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8510913..817af3a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -91,6 +91,10 @@ option(SLEEF_ENFORCE_CUDA "Build fails if CUDA is not supported" OFF) + option(SLEEF_DISABLE_OPENMP "Disable OPENMP" OFF) + option(SLEEF_ENFORCE_OPENMP "Build fails if OPENMP is not supported by the compiler" OFF) + ++# Option to disable PURECFMA scalar code path on x86 for x86-64-v2 compatibility ++# When ON, PURECFMA scalar dispatch is disabled (useful for Sandy Bridge support) ++# This can be set dynamically by the build system based on target CPU detection ++option(SLEEF_DISABLE_PURECFMA_SCALAR "Disable PURECFMA scalar code path (for x86-64-v2 compatibility)" OFF) + # + + if ((NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}") OR +diff --git a/Configure.cmake b/Configure.cmake +index e029751..8764b60 100644 +--- a/Configure.cmake ++++ b/Configure.cmake +@@ -193,7 +193,12 @@ endif() + if(SLEEF_TARGET_PROCESSOR MATCHES "(x86|AMD64|amd64|^i.86$)") + set(SLEEF_ARCH_X86 ON CACHE INTERNAL "True for x86 architecture.") + +- set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mavx2;-mfma") ++ # Only set PURECFMA_SCALAR flags if not explicitly disabled ++ if(NOT SLEEF_DISABLE_PURECFMA_SCALAR) ++ set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mavx2;-mfma") ++ else() ++ message(STATUS "PURECFMA_SCALAR disabled for x86-64-v2 compatibility") ++ endif() + elseif(SLEEF_TARGET_PROCESSOR MATCHES "aarch64|arm64") + set(SLEEF_ARCH_AARCH64 ON CACHE INTERNAL "True for Aarch64 architecture.") + # Aarch64 requires support for advsimdfma4 +@@ -220,7 +225,12 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") + endif() + + set(COMPILER_SUPPORTS_PUREC_SCALAR 1) +-set(COMPILER_SUPPORTS_PURECFMA_SCALAR 1) ++# Conditionally enable PURECFMA_SCALAR based on option ++if(SLEEF_DISABLE_PURECFMA_SCALAR) ++ set(COMPILER_SUPPORTS_PURECFMA_SCALAR 0) ++else() ++ set(COMPILER_SUPPORTS_PURECFMA_SCALAR 1) ++endif() + + # Compiler feature detection + +diff --git a/src/quad/CMakeLists.txt b/src/quad/CMakeLists.txt +index 8e4e261..fd41d28 100644 +--- a/src/quad/CMakeLists.txt ++++ b/src/quad/CMakeLists.txt +@@ -398,9 +398,17 @@ set_target_properties(qmkdisp PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Target qdispscalar.c + ++# Set scalar dispatch backends based on PURECFMA support ++# When SLEEF_DISABLE_PURECFMA_SCALAR is ON, use purec for both slots ++if(COMPILER_SUPPORTS_PURECFMA_SCALAR) ++ set(SCALAR_DISPATCH_BACKENDS "purec" "purecfma") ++else() ++ set(SCALAR_DISPATCH_BACKENDS "purec" "purec") ++endif() ++ + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body +- COMMAND $ 1 Sleef_quad double int32_t int64_t uint64_t purec purecfma > ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body ++ COMMAND $ 1 Sleef_quad double int32_t int64_t uint64_t ${SCALAR_DISPATCH_BACKENDS} > ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body + DEPENDS qmkdisp + ) + sleef_concat_files( +@@ -426,6 +434,11 @@ target_compile_definitions(qdispscalar_obj PRIVATE ${COMMON_TARGET_DEFINITIONS}) + target_include_directories(qdispscalar_obj PRIVATE ${sleef_BINARY_DIR}/include) + add_dependencies(qdispscalar_obj qdispscalar.c_generated qrenamedspscalar.h_generated + sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) ++# Define ENABLE_PURECFMA when PURECFMA is supported, so qdispscalar.c.org ++# can conditionally include the tryFMA() function and SUBST_IF_EXT1 macro ++if(COMPILER_SUPPORTS_PURECFMA_SCALAR) ++ target_compile_definitions(qdispscalar_obj PRIVATE ENABLE_PURECFMA=1) ++endif() + target_sources(sleefquad PRIVATE $) + + if(DEFINED QMKDISP_PARAMS_X2) +diff --git a/src/quad/qdispscalar.c.org b/src/quad/qdispscalar.c.org +index c4c1292..48f309c 100644 +--- a/src/quad/qdispscalar.c.org ++++ b/src/quad/qdispscalar.c.org +@@ -15,10 +15,14 @@ + + #include "qdispatcher.h" + ++#ifdef ENABLE_PURECFMA + NOEXPORT Sleef_quad sleef_cpuid_QUADFMA_0; + static void tryFMA() { sleef_cpuid_QUADFMA_0 = Sleef_sinq1_u10purecfma(sleef_cpuid_QUADFMA_0); } + + #define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryFMA)) p = funcExt1; ++#else ++#define SUBST_IF_EXT1(funcExt1) ++#endif + + // + diff --git a/pyodide-recipes/packages/libsleef/patches/0004-no-cpuid.patch b/pyodide-recipes/packages/libsleef/patches/0004-no-cpuid.patch new file mode 100644 index 0000000..75c0955 --- /dev/null +++ b/pyodide-recipes/packages/libsleef/patches/0004-no-cpuid.patch @@ -0,0 +1,82 @@ +diff --git a/src/libm/dispavx.c.org b/src/libm/dispavx.c.org +index 86a0148..e309af7 100644 +--- a/src/libm/dispavx.c.org ++++ b/src/libm/dispavx.c.org +@@ -14,33 +14,15 @@ + #include "sleef.h" + + static int cpuSupportsAVX2() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 7, 0); +- ret = (reg[1] & (1 << 5)) != 0; +- } +- return ret; ++ return 0; + } + + static int cpuSupportsFMA() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 1, 0); +- ret = (reg[2] & (1 << 12)) != 0; +- } +- return ret; ++ return 0; + } + + static int cpuSupportsFMA4() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 0x80000001, 0); +- ret = (reg[2] & (1 << 16)) != 0; +- } +- return ret; ++ return 0; + } + + #ifdef ENABLE_FMA4 +diff --git a/src/libm/dispsse.c.org b/src/libm/dispsse.c.org +index 4e0d09b..1e9a875 100644 +--- a/src/libm/dispsse.c.org ++++ b/src/libm/dispsse.c.org +@@ -14,33 +14,15 @@ + #include "sleef.h" + + static int cpuSupportsSSE4_1() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 1, 0); +- ret = (reg[2] & (1 << 19)) != 0; +- } +- return ret; ++ return 0; + } + + static int cpuSupportsAVX2() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 7, 0); +- ret = (reg[1] & (1 << 5)) != 0; +- } +- return ret; ++ return 0; + } + + static int cpuSupportsFMA() { +- static int ret = -1; +- if (ret == -1) { +- int32_t reg[4]; +- Sleef_x86CpuID(reg, 1, 0); +- ret = (reg[2] & (1 << 12)) != 0; +- } +- return ret; ++ return 0; + } + + #define SUBST_IF_EXT1(funcsse4) if (cpuSupportsSSE4_1()) p = funcsse4; diff --git a/pyodide-recipes/packages/numpy-quaddtype/.gitignore b/pyodide-recipes/packages/numpy-quaddtype/.gitignore new file mode 100644 index 0000000..7e87f75 --- /dev/null +++ b/pyodide-recipes/packages/numpy-quaddtype/.gitignore @@ -0,0 +1 @@ +/numpy_quaddtype-*.*.* diff --git a/pyodide-recipes/packages/numpy-quaddtype/meta.yaml b/pyodide-recipes/packages/numpy-quaddtype/meta.yaml new file mode 100644 index 0000000..c7f107d --- /dev/null +++ b/pyodide-recipes/packages/numpy-quaddtype/meta.yaml @@ -0,0 +1,20 @@ +package: + name: numpy-quaddtype + version: 1.0.0 + top-level: + - numpy_quaddtype +source: + path: numpy_quaddtype-1.0.0 +requirements: + host: + - numpy + - libsleef +build: + script: | + export CXXFLAGS="${CXXFLAGS} -I${WASM_LIBRARY_DIR}/include -sRELOCATABLE=1"; + export LDFLAGS="${CFLAGS} -L${WASM_LIBRARY_DIR}/lib"; +about: + home: https://github.com/numpy/numpy-user-dtypes/tree/main/quaddtype + PyPI: https://pypi.org/project/numpy-quaddtype + summary: Quad (128-bit) float dtype for numpy + license: BSD-3-Clause diff --git a/pyodide-recipes/packages/numpy/meta.yaml b/pyodide-recipes/packages/numpy/meta.yaml new file mode 100644 index 0000000..57f6a14 --- /dev/null +++ b/pyodide-recipes/packages/numpy/meta.yaml @@ -0,0 +1,38 @@ +package: + name: numpy + version: 2.4.1 + tag: + - min-scipy-stack + top-level: + - numpy +source: + url: https://files.pythonhosted.org/packages/source/n/numpy/numpy-2.4.1.tar.gz + sha256: a1ceafc5042451a858231588a104093474c6a5c57dcc724841f5c888d237d690 + +build: + unvendor-tests: false # we do this on our own using Meson's install tags + # numpy uses vendored meson, so we need to pass the cross file manually + backend-flags: | + setup-args=-Dallow-noblas=true + setup-args=--cross-file=${MESON_CROSS_FILE} + install-args=--tags=runtime,python-runtime,devel + # numpy creates numpy/distutils/__pycache__ directory during the build. + # It breaks our test because there is a .pyc in the directory. + post: | + rm -rf numpy/distutils/__pycache__ + cflags: | + -Wno-return-type + cross-build-env: true + cross-build-files: + - numpy/_core/include/numpy/numpyconfig.h + - numpy/_core/include/numpy/_numpyconfig.h + - numpy/_core/lib/libnpymath.a + - numpy/random/lib/libnpyrandom.a +about: + home: https://www.numpy.org + PyPI: https://pypi.org/project/numpy + summary: NumPy is the fundamental package for array computing with Python. + license: BSD-3-Clause +extra: + recipe-maintainers: + - agriyakhetarpal From 4ed9b360210d651f3c9f1932eb0e04aef8b37b01 Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Thu, 22 Jan 2026 18:56:16 +0200 Subject: [PATCH 2/5] fix recipe dir --- .github/workflows/pyodide.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyodide.yml b/.github/workflows/pyodide.yml index 78d0cef..7f69a5f 100644 --- a/.github/workflows/pyodide.yml +++ b/.github/workflows/pyodide.yml @@ -59,7 +59,7 @@ jobs: - name: Build compiled dependencies for Pyodide run: | pyodide build-recipes \ - --recipe-dir tools/ci/pyodide-recipes/packages \ + --recipe-dir pyodide-recipes/packages \ --install \ numpy numpy-quaddtype From 0385e3a0012cf7a734480ffa2e5e5078e3aab49a Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Thu, 22 Jan 2026 19:07:02 +0200 Subject: [PATCH 3/5] remove unused import --- tests/test_multithreading.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_multithreading.py b/tests/test_multithreading.py index 90eb257..3a813be 100644 --- a/tests/test_multithreading.py +++ b/tests/test_multithreading.py @@ -4,9 +4,7 @@ import pytest import numpy as np -from numpy._core import _rational_tests -from numpy._core.tests.test_stringdtype import random_unicode_string_list -from numpy.testing import IS_64BIT, IS_WASM +from numpy.testing import IS_WASM from numpy.testing._private.utils import run_threaded if IS_WASM: From 177289962616dc1e0a551451c6cdf485469a4b7f Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Thu, 22 Jan 2026 20:33:20 +0200 Subject: [PATCH 4/5] skip nm test on pyodide --- tests/test_quaddtype.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_quaddtype.py b/tests/test_quaddtype.py index f62f636..d8798c3 100644 --- a/tests/test_quaddtype.py +++ b/tests/test_quaddtype.py @@ -6,6 +6,7 @@ from mpmath import mp import numpy_quaddtype +from numpy.testing import IS_WASM from numpy_quaddtype import QuadPrecDType, QuadPrecision from numpy_quaddtype import pi as quad_pi @@ -5891,7 +5892,10 @@ def test_sleef_purecfma_symbols(): import subprocess import shutil import pathlib - + + if IS_WASM: + pytest.skip("no subprocess in wasm") + # Skip if nm is not available nm_path = shutil.which('nm') if nm_path is None: From ff2ef25fa71a7adc3219e2267bcb1ee600fd4552 Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Thu, 22 Jan 2026 20:49:40 +0200 Subject: [PATCH 5/5] fix repo URL --- pyodide-recipes/packages/numpy-quaddtype/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyodide-recipes/packages/numpy-quaddtype/meta.yaml b/pyodide-recipes/packages/numpy-quaddtype/meta.yaml index c7f107d..d0a98cd 100644 --- a/pyodide-recipes/packages/numpy-quaddtype/meta.yaml +++ b/pyodide-recipes/packages/numpy-quaddtype/meta.yaml @@ -14,7 +14,7 @@ build: export CXXFLAGS="${CXXFLAGS} -I${WASM_LIBRARY_DIR}/include -sRELOCATABLE=1"; export LDFLAGS="${CFLAGS} -L${WASM_LIBRARY_DIR}/lib"; about: - home: https://github.com/numpy/numpy-user-dtypes/tree/main/quaddtype + home: https://github.com/numpy/numpy-quaddtype PyPI: https://pypi.org/project/numpy-quaddtype summary: Quad (128-bit) float dtype for numpy license: BSD-3-Clause