-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Blosc/skbuild-core
Support wheels and test them for different platforms
- Loading branch information
Showing
13 changed files
with
328 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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,109 @@ | ||
name: Python wheels | ||
on: | ||
# Trigger the workflow on push or pull request, | ||
# but only for the main branch | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
|
||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
arch: [x86_64, aarch64, arm64] | ||
exclude: | ||
- os: windows-latest | ||
arch: aarch64 | ||
- os: macos-latest | ||
arch: aarch64 | ||
- os: windows-latest | ||
arch: arm64 | ||
- os: ubuntu-latest | ||
arch: arm64 | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Set up QEMU | ||
if: ${{ matrix.arch == 'aarch64' }} | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Install Ninja | ||
uses: seanmiddleditch/gha-setup-ninja@master | ||
|
||
- name: Install MSVC amd64 | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
with: | ||
arch: amd64 | ||
|
||
- name: Build wheels (Windows) | ||
if: runner.os == 'Windows' | ||
uses: pypa/cibuildwheel@v2.14.1 | ||
env: | ||
CIBW_BUILD: 'cp38-win_amd64 cp39-win_amd64 cp310-win_amd64 cp311-win_amd64' | ||
CIBW_BEFORE_TEST: pip install blosc2 | ||
CIBW_TEST_COMMAND: cmd /V /C "set "BLOSC_TRACE=1" && python {project}/examples/array_roundtrip.py" | ||
CIBW_BUILD_VERBOSITY: 1 | ||
|
||
- name: Build wheels (Mac OSX arm64) | ||
if: ${{ matrix.os == 'macos-latest' && matrix.arch == 'arm64' }} | ||
uses: pypa/cibuildwheel@v2.14.1 | ||
env: | ||
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*' | ||
CIBW_BEFORE_TEST: pip install blosc2 | ||
CIBW_TEST_COMMAND: BLOSC_TRACE=1 python {project}/examples/array_roundtrip.py | ||
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_ARCHS_MACOS: "arm64" | ||
|
||
- name: Build wheels (Linux / Mac OSX) | ||
if: ${{ matrix.os != 'windows-latest' && (matrix.arch == 'x86_64' || matrix.arch == 'aarch64') }} | ||
uses: pypa/cibuildwheel@v2.14.1 | ||
env: | ||
CIBW_BEFORE_BUILD: python -m pip install --upgrade pip && python -m pip install -r requirements-build.txt | ||
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*' | ||
CIBW_SKIP: '*-manylinux*_i686 *-musllinux_* ${{ env.CIBW_SKIP}}' | ||
CIBW_ARCHS_LINUX: ${{ matrix.arch }} | ||
CIBW_BEFORE_TEST: pip install blosc2 | ||
CIBW_TEST_COMMAND: BLOSC_TRACE=1 python {project}/examples/array_roundtrip.py | ||
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_ARCHS_MACOS: "x86_64" | ||
|
||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
|
||
|
||
upload_pypi: | ||
needs: [ build_wheels ] # last but not least | ||
runs-on: ubuntu-latest | ||
# Only upload wheels when tagging (typically a release) | ||
if: startsWith(github.event.ref, 'refs/tags') | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifact | ||
path: dist | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.blosc_pypi_secret }} |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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,27 @@ | ||
####################################################################### | ||
# Copyright (c) 2019-present, Blosc Development Team <blosc@blosc.org> | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under a BSD-style license (found in the | ||
# LICENSE file in the root directory of this source tree) | ||
####################################################################### | ||
|
||
|
||
import blosc2 | ||
import numpy as np | ||
|
||
|
||
# Register the plugin_example | ||
blosc2.register_filter(250, None, None, "plugin_example") | ||
|
||
# Create blosc2 NDArray from a NumPy array | ||
shape = [100, 100] | ||
size = int(np.prod(shape)) | ||
nparray = np.arange(size, dtype=np.int32).reshape(shape) | ||
blosc2_array = blosc2.asarray(nparray, cparams={"filters": [250]}) | ||
|
||
# Retrieve data and check it is the same | ||
if np.array_equal(blosc2_array[...], nparray): | ||
print("Successful roundtrip!") | ||
else: | ||
print("Bad roundtrip! Try setting BLOSC_TRACE=1 envvar for more info on failure.") |
This file contains 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,31 @@ | ||
####################################################################### | ||
# Copyright (c) 2019-present, Blosc Development Team <blosc@blosc.org> | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under a BSD-style license (found in the | ||
# LICENSE file in the root directory of this source tree) | ||
####################################################################### | ||
|
||
import numpy as np | ||
|
||
import blosc2 | ||
|
||
blosc2.register_filter(250, None, None, "plugin_example") | ||
|
||
# Set the compression and decompression parameters | ||
storage = {"contiguous": True, "cparams": {"filters": [250], "typesize": 4}} | ||
|
||
# Create the SChunk | ||
nchunks = 10 | ||
data = np.arange(200 * 1000 * nchunks, dtype=np.int32) | ||
schunk = blosc2.SChunk(chunksize=200 * 1000 * 4, data=data, **storage) | ||
|
||
cframe = schunk.to_cframe() | ||
|
||
schunk2 = blosc2.schunk_from_cframe(cframe, False) | ||
data2 = np.empty(data.shape, dtype=data.dtype) | ||
schunk2.get_slice(out=data2) | ||
if np.array_equal(data, data2): | ||
print("Successful roundtrip!") | ||
else: | ||
print("Bad roundtrip! Try setting BLOSC_TRACE=1 envvar for more info on failure.") |
This file contains 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
Oops, something went wrong.