Skip to content
name: Publish sdist and wheels for macos, manylinux, and windows, publish to pypi if a release
on: [pull_request, push]
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: 'cp*'
CIBW_SKIP: 'cp35-* cp36-* cp37-* *-manylinux_i686 *-musllinux_* *-win32 cp311-macosx_x86_64'
CIBW_BEFORE_TEST: pip install -r {project}/tests/requirement_tests.txt
CIBW_TEST_COMMAND: pytest -s -v {project}/tests
WINDOWS_HDF5: 1.14.2
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2022]
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel
- name: Build wheels on Linux
if: runner.os == 'Linux'
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL: |
AEC_VERSION="1.0.4"
HDF5_VERSION="1.12.1"
yum update -y
yum -y install zlib-devel
pushd /tmp
echo "Downloading & unpacking aec ${AEC_VERSION}"
curl -fsSLO https://gitlab.dkrz.de/k202009/libaec/uploads/ea0b7d197a950b0c110da8dfdecbb71f/libaec-${AEC_VERSION}.tar.gz
tar zxf libaec-$AEC_VERSION.tar.gz
echo "Building & installing libaec"
pushd libaec-$AEC_VERSION
./configure
make -j 2
make install
ldconfig
popd
echo "Downloading & unpacking HDF5 ${HDF5_VERSION}"
curl -fsSLO "https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION%.*}/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz"
tar -xzvf hdf5-$HDF5_VERSION.tar.gz
echo "Building & installing HDF5"
pushd hdf5-$HDF5_VERSION
./configure \
--prefix=/usr \
--enable-build-mode=production \
--with-szlib \
--enable-tools=no \
--enable-tests=no
make -j 2
make install
ldconfig
popd
run: |
python -m cibuildwheel --output-dir dist
- name: Build wheels Mac OS
if: runner.os == 'macOS'
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
CIBW_BEFORE_BUILD: |
#brew update
#brew --version
export HOMEBREW_NO_AUTO_UPDATE=1
export HDF5_DIR="$(brew --prefix hdf5)";
brew install hdf5
run: |
python -m cibuildwheel --output-dir dist
- name: Cache HDF5 On Windows
if: runner.os == 'Windows'
id: cache-hdf5-windows
uses: actions/cache@v3
env:
cache-name: cache-hdf5-windows
with:
path: C:\cache\hdf5\${{ env.WINDOWS_HDF5 }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.WINDOWS_HDF5 }}
- name: Fill Windows Cache
if: runner.os == 'Windows' && steps.cache-hdf5-windows.outputs.cache-hit != 'true'
continue-on-error: false
shell: cmd
run: |
mkdir C:\cache\hdf5\${{ env.WINDOWS_HDF5 }}
curl -L -o C:\cache\hdf5\${{ env.WINDOWS_HDF5 }}\hdf5.zip https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.2/bin/windows/hdf5-1.14.2-Std-win10_64-vs16.zip
- name: Build wheels Windows
if: runner.os == 'Windows'
shell: cmd
# the v140 toolchain is used, so that fewer vc_redist installs are required
# some of the information is available here:
# https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line
# but tracking down the 14.0 magic number (and especially newer ones isn't always easy)
# this has a partial table:
# https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
run: |
C:\windows\system32\tar.exe xf C:\cache\hdf5\${{ env.WINDOWS_HDF5 }}\hdf5.zip
start /wait msiexec /a "%cd%\hdf\HDF5-${{ env.WINDOWS_HDF5 }}-win64.msi" /qn TARGETDIR="c:\hdf5\"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.1
set HDF5_DIR=C:\hdf5\HDF_Group\HDF5\${{ env.WINDOWS_HDF5 }}\cmake
python -m cibuildwheel --output-dir dist
- name: Store wheel as artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.whl
build_sdist:
name: Build sdist
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies

Check failure on line 151 in .github/workflows/publish-sdist-wheels.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-sdist-wheels.yml

Invalid workflow file

You have an error in your yaml syntax on line 151
run:
- name: Install Dependencies
run:
python -m pip install build
- name: Build a source tarball
run:
python -m build --sdist
- name: Test tarball
run: |
sudo apt install -y libhdf5-dev
pip install -r tests/requirement_tests.txt
pip install dist/*
pytest -s -v tests
- name: Store sdist as artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.tar.gz
upload_artifacts:
name: Upload wheels to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
steps:
- name: Download artifacts produced during the build_wheels and build_sdist jobs
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Display structure of downloaded files
run: ls -R
working-directory: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: dist/