Skip to content

Commit

Permalink
try windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Oct 20, 2023
1 parent 0283e03 commit dea0607
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 10 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/build_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Build and Test Linux with latest netcdf-c
on: [push, pull_request]
jobs:
build-linux:
name: Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
env:
PNETCDF_VERSION: 1.12.1
NETCDF_VERSION: 4.9.2
NETCDF_DIR: ${{ github.workspace }}/..
NETCDF_EXTRA_CONFIG: --enable-pnetcdf
CC: mpicc.mpich
#NO_NET: 1
strategy:
matrix:
python-version: ["3.11"]
steps:

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev libcurl4-openssl-dev bzip2 libsnappy-dev libblosc-dev libzstd-dev
echo "Download and build PnetCDF version ${PNETCDF_VERSION}"
wget https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
pushd pnetcdf-${PNETCDF_VERSION}
./configure --prefix $NETCDF_DIR --enable-shared --disable-fortran --disable-cxx
make -j 2
make install
popd
echo "Download and build netCDF version ${NETCDF_VERSION}"
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
pushd netcdf-c-${NETCDF_VERSION}
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
export LDFLAGS="-L${NETCDF_DIR}/lib"
export LIBS="-lhdf5_mpich_hl -lhdf5_mpich -lm -lz"
./configure --prefix $NETCDF_DIR --enable-netcdf-4 --enable-shared --enable-dap --enable-parallel4 $NETCDF_EXTRA_CONFIG
make -j 2
make install
popd
# - name: The job has failed
# if: ${{ failure() }}
# run: |
# cd netcdf-c-${NETCDF_VERSION}
# cat config.log

- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip
pip install numpy cython cftime pytest twine wheel check-manifest mpi4py
- name: Install netcdf4-python
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
export NETCDF_PLUGIN_DIR=${{ github.workspace }}/netcdf-c-${NETCDF_VERSION}/plugins/plugindir
python setup.py install
- name: Test
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
python checkversion.py
# serial
cd test
python run_all.py
# parallel (hdf5 for netcdf4, pnetcdf for netcdf3)
cd ../examples
mpirun.mpich -np 4 python mpi_example.py
if [ $? -ne 0 ] ; then
echo "hdf5 mpi test failed!"
exit 1
else
echo "hdf5 mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example_compressed.py
if [ $? -ne 0 ] ; then
echo "hdf5 compressed mpi test failed!"
exit 1
else
echo "hdf5 compressed mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example.py NETCDF3_64BIT_DATA
if [ $? -ne 0 ] ; then
echo "pnetcdf mpi test failed!"
exit 1
else
echo "pnetcdf mpi test passed!"
fi
# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
# python setup.py --version
# check-manifest --version
# check-manifest --verbose
# pip wheel . -w dist --no-deps
# twine check dist/*
78 changes: 78 additions & 0 deletions .github/workflows/build_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Test on Linux with netcdf-c github master
on: [push, pull_request]
jobs:
build-linux:
name: Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
env:
NETCDF_DIR: ${{ github.workspace }}/..
CC: mpicc.mpich
#NO_NET: 1
strategy:
matrix:
python-version: ["3.11"]
steps:

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev libcurl4-openssl-dev bzip2 libsnappy-dev libblosc-dev libzstd-dev
echo "Download and build netCDF github master"
git clone https://github.com/Unidata/netcdf-c
pushd netcdf-c
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
export LDFLAGS="-L${NETCDF_DIR}/lib"
export LIBS="-lhdf5_mpich_hl -lhdf5_mpich -lm -lz"
autoreconf -i
./configure --prefix $NETCDF_DIR --enable-netcdf-4 --enable-shared --enable-dap --enable-parallel4
make -j 2
make install
popd
# - name: The job has failed
# if: ${{ failure() }}
# run: |
# cd netcdf-c-${NETCDF_VERSION}
# cat config.log

- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip
pip install numpy cython cftime pytest twine wheel check-manifest mpi4py
- name: Install netcdf4-python
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
export NETCDF_PLUGIN_DIR=${{ github.workspace }}/netcdf-c/plugins/plugindir
python setup.py install
- name: Test
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
#export HDF5_PLUGIN_PATH=${NETCDF_DIR}/plugins/plugindir
python checkversion.py
# serial
cd test
python run_all.py
# parallel
cd ../examples
mpirun.mpich -np 4 python mpi_example.py
if [ $? -ne 0 ] ; then
echo "hdf5 mpi test failed!"
exit 1
else
echo "hdf5 mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example_compressed.py
if [ $? -ne 0 ] ; then
echo "hdf5 compressed mpi test failed!"
exit 1
else
echo "hdf5 compressed mpi test passed!"
fi
104 changes: 104 additions & 0 deletions .github/workflows/build_old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Build and Test Linux with older netcdf-c
on: [push, pull_request]
jobs:
build-linux:
name: Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
env:
PNETCDF_VERSION: 1.12.1
NETCDF_VERSION: 4.8.1
NETCDF_DIR: ${{ github.workspace }}/..
NETCDF_EXTRA_CONFIG: --enable-pnetcdf
CC: mpicc.mpich
#NO_NET: 1
strategy:
matrix:
python-version: ["3.11"]
steps:

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev libcurl4-openssl-dev bzip2 libsnappy-dev libblosc-dev libzstd-dev
echo "Download and build PnetCDF version ${PNETCDF_VERSION}"
wget https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
pushd pnetcdf-${PNETCDF_VERSION}
./configure --prefix $NETCDF_DIR --enable-shared --disable-fortran --disable-cxx
make -j 2
make install
popd
echo "Download and build netCDF version ${NETCDF_VERSION}"
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
pushd netcdf-c-${NETCDF_VERSION}
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
export LDFLAGS="-L${NETCDF_DIR}/lib"
export LIBS="-lhdf5_mpich_hl -lhdf5_mpich -lm -lz"
./configure --prefix $NETCDF_DIR --enable-netcdf-4 --enable-shared --enable-dap --enable-parallel4 $NETCDF_EXTRA_CONFIG
make -j 2
make install
popd
# - name: The job has failed
# if: ${{ failure() }}
# run: |
# cd netcdf-c-${NETCDF_VERSION}
# cat config.log

- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip
pip install numpy cython cftime pytest twine wheel check-manifest mpi4py
- name: Install netcdf4-python
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
export NETCDF_PLUGIN_DIR=${{ github.workspace }}/netcdf-c-${NETCDF_VERSION}/plugins/plugindir
python setup.py install
- name: Test
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
python checkversion.py
# serial
cd test
python run_all.py
# parallel (hdf5 for netcdf4, pnetcdf for netcdf3)
cd ../examples
mpirun.mpich -np 4 python mpi_example.py
if [ $? -ne 0 ] ; then
echo "hdf5 mpi test failed!"
exit 1
else
echo "hdf5 mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example_compressed.py
if [ $? -ne 0 ] ; then
echo "hdf5 compressed mpi test failed!"
exit 1
else
echo "hdf5 compressed mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example.py NETCDF3_64BIT_DATA
if [ $? -ne 0 ] ; then
echo "pnetcdf mpi test failed!"
exit 1
else
echo "pnetcdf mpi test passed!"
fi
# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
# python setup.py --version
# check-manifest --version
# check-manifest --verbose
# pip wheel . -w dist --no-deps
# twine check dist/*
58 changes: 53 additions & 5 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- uses: actions/setup-python@v4
name: Install Python
Expand Down Expand Up @@ -82,8 +79,59 @@ jobs:
name: pypi-artifacts
path: ${{ github.workspace }}/wheelhouse/*.whl


build_wheels_windows:
name: Build wheels for ${{matrix.arch}} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
arch: [win_amd64]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: 3.x

- name: Setup Micromamba Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
environment-name: build
init-shell: bash
create-args: >-
python=${{ matrix.python-version }} hdf5 libnetcdf --channel conda-forge
- name: Install cibuildwheel
run: |
python -m pip install --upgrade cibuildwheel
- name: Build wheels for Windows (${{ matrix.arch }})
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-${{ matrix.arch }} cp310-${{ matrix.arch }} cp311-${{ matrix.arch }} cp312-${{ matrix.arch }}"
CIBW_ENVIRONMENT_WINDOWS: >
HDF5_DIR="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library"
netCDF4_DIR="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library"
PATH="C:\\Users\\runneradmin\\micromamba\\envs\\build\\Library\\bin;${PATH}"
CIBW_BEFORE_BUILD: "python -m pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
CIBW_TEST_COMMAND: >
python -c "import netCDF4; print(f'netCDF4 v{netCDF4.__version__}')"
&& xcopy {project}\\test . /E/H
&& python -m pip install --upgrade numpy cython packaging
&& python run_all.py
- uses: actions/upload-artifact@v3
with:
name: pypi-artifacts
path: ${{ github.workspace }}/wheelhouse/*.whl


show-artifacts:
needs: [build_bdist, build_sdist]
needs: [build_bdist, build_sdist, build_wheels_windows]
name: "Show artifacts"
runs-on: ubuntu-latest
steps:
Expand All @@ -98,7 +146,7 @@ jobs:
publish-artifacts-pypi:
needs: [build_bdist, build_sdist]
needs: [build_bdist, build_sdist, build_wheels_windows]
name: "Publish to PyPI"
runs-on: ubuntu-latest
# upload to PyPI for every tag starting with 'v'
Expand Down
Loading

0 comments on commit dea0607

Please sign in to comment.