-
-
Notifications
You must be signed in to change notification settings - Fork 4
BUILD: Add Pyodide CI and build recipes #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
juntyr
wants to merge
5
commits into
numpy:main
Choose a base branch
from
juntyr:pyodide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use the cibuildwheel action with |
||
|
|
||
| - name: Build compiled dependencies for Pyodide | ||
| run: | | ||
| pyodide build-recipes \ | ||
| --recipe-dir 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /.libs/ | ||
| /*/build/ | ||
| /*/build.log | ||
| /*/dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
153 changes: 153 additions & 0 deletions
153
pyodide-recipes/packages/libsleef/patches/0001-no-x86intrin.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| - #include <x86intrin.h> | ||
| + #include <immintrin.h> | ||
| #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 <intrin.h> | ||
| #else | ||
| -#include <x86intrin.h> | ||
| +#include <immintrin.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> | ||
| 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 <intrin.h> | ||
| #else | ||
| -#include <x86intrin.h> | ||
| +#include <immintrin.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> | ||
| 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 <intrin.h> | ||
| #else | ||
| -#include <x86intrin.h> | ||
| +#include <immintrin.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> | ||
| 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 <intrin.h> | ||
| #else | ||
| -#include <x86intrin.h> | ||
| +#include <immintrin.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> | ||
| 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 <intrin.h> | ||
| #else | ||
| -#include <x86intrin.h> | ||
| +#include <immintrin.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> | ||
| 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 <x86intrin.h> | ||
| -#endif | ||
| +#include <immintrin.h> | ||
|
|
||
| #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 <x86intrin.h> | ||
| -#endif | ||
| +#include <immintrin.h> | ||
|
|
||
| #if (defined(_MSC_VER)) | ||
| #include <intrin.h> |
19 changes: 19 additions & 0 deletions
19
pyodide-recipes/packages/libsleef/patches/0002-no-mfpmatch.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This action is not actively maintained and is waiting on mymindstorm/setup-emsdk#48. In the meantime, you can use our fork to save 2-3 minutes per run.