Skip to content

Commit

Permalink
Add acctions for building wheels
Browse files Browse the repository at this point in the history
Including automagically build and upload to pypi upon release.
Also use tbump to increment version and date in CITATION.cff
  • Loading branch information
kjmeagher committed Jan 22, 2024
1 parent daad99d commit a9d994a
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ jobs:
python3 -m pip install meson numpy sphinx breathe sphinx_rtd_theme pytest pytest-subtests
meson setup build . -D b_coverage=true --prefix=${HOME}/inst/
ninja -C build test
- name: Install and test linking
if: matrix.build == 'meson' && startsWith( matrix.os, 'macos')
env:
PKG_CONFIG_PATH: /Users/runner/inst/lib/pkgconfig
run: |
ninja -C build install
c++ -std=c++17 $(pkg-config nuflux --cflags --libs) tests/test_basic.cxx -o test_basic
./test_basic
- name: Generate Coverage Report and Docs
if: matrix.build == 'meson' && startsWith( matrix.os, 'ubuntu')
run: |
Expand Down Expand Up @@ -83,7 +91,7 @@ jobs:
options: -v /cvmfs/icecube.opensciencegrid.org/:/cvmfs/icecube.opensciencegrid.org/ -v /home/runner/work/nuflux/nuflux:/nuflux
image: centos:centos7.9.2009
run: |
yum -y install glibc-headers glibc-devel
yum -y install glibc-headers glibc-devel unzip
eval $(/cvmfs/icecube.opensciencegrid.org/${{matrix.cvmfs}}/setup.sh)
export PATH=${HOME}/.local/bin:${PATH}
pip install --user meson ninja pytest pytest-subtests
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build Wheels
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Install Deps
run: |
sudo apt-get update
sudo apt-get install libcfitsio-dev python-is-python3 libboost-python-dev ninja-build
curl -L https://github.com/icecube/photospline/archive/refs/tags/v2.2.1.tar.gz | tar xz
cmake -S photospline-2.2.1 -B photospline -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
sudo make install -C photospline
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist
- name: Test sdist
run: |
python -m pip install meson pytest pytest-subtests
python -m pip install dist/nuflux-*.tar.gz
python tests/test_fluxes.py
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/nuflux-*.tar.gz
build_wheels:
name: Build wheels cp${{ matrix.python }}-manylinux_x86_64
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["37","38","39","310","311","312"]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp${{ matrix.python }}-manylinux_x86_64
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-cp${{ matrix.python }}
path: ./wheelhouse/*.whl
test_wheels:
name: Test Wheel with Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel
uses: actions/download-artifact@v4
with:
path: artifact
- name: Display structure of downloaded files
run: |
PYNAME=$(echo cp${{matrix.python-version}} | sed 's/\.//')
FNAME=artifact/cibw-wheels-${PYNAME}/nuflux-*-${PYNAME}-*.whl
python3 -m pip install pytest pytest-subtests $FNAME
- uses: actions/checkout@v4
- name: Test
working-directory: tests
run: ./test_fluxes.py
cvmfs_test_wheel:
name: Test Wheel with cvmfs ${{matrix.cvmfs}}
needs: build_wheels
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cvmfs: [py3-v4.1.1, py3-v4.2.1, py3-v4.3.0]
include:
- cvmfs: py3-v4.1.1
python-tag: cp37
- cvmfs: py3-v4.2.1
python-tag: cp310
- cvmfs: py3-v4.3.0
python-tag: cp311
steps:
- uses: cvmfs-contrib/github-action-cvmfs@v3
- name: Checkout nuflux
uses: actions/checkout@v2
- name: Download wheel
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-${{ matrix.python-tag }}
merge-multiple: true
- name: Build and Run Tests in Docker
uses: addnab/docker-run-action@v3
with:
options: -v /cvmfs/icecube.opensciencegrid.org/:/cvmfs/icecube.opensciencegrid.org/ -v /home/runner/work/nuflux/nuflux:/nuflux
image: centos:centos7.9.2009
run: |
eval $(/cvmfs/icecube.opensciencegrid.org/${{matrix.cvmfs}}/setup.sh)
python3 -m pip install --user pytest pytest-subtests /nuflux/nuflux-*-${{matrix.python-tag}}-*.whl
python3 /nuflux/tests/test_fluxes.py
upload_pypi:
needs: [cvmfs_test_wheel,test_wheels,build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dmypy.json

# Pyre type checker
.pyre/

#cibuildwheel
/wheelhouse/
33 changes: 33 additions & 0 deletions contrib/manylinux2014.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# run with:
# docker build -t kjmeagher/nuflux-manylinux2014_x86_64 - < manylinux2014.Dockerfile
# python -m cibuildwheel --platform linux
# docker push kjmeagher/nuflux-manylinux2014_x86_64
FROM quay.io/pypa/manylinux2014_x86_64:latest

WORKDIR /
RUN curl -L https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2 | tar xj
WORKDIR /boost_1_84_0/
RUN ./bootstrap.sh --with-libraries=python --with-python=python3.7 &&\
./b2 install variant=release debug-symbols=off install --layout=system &&\
./bootstrap.sh --with-libraries=python --with-python=python3.8 &&\
./b2 install variant=release debug-symbols=off install --layout=system &&\
./bootstrap.sh --with-libraries=python --with-python=python3.9 &&\
./b2 install variant=release debug-symbols=off install --layout=system &&\
./bootstrap.sh --with-libraries=python --with-python=python3.10 &&\
./b2 install variant=release debug-symbols=off install --layout=system &&\
./bootstrap.sh --with-libraries=python --with-python=python3.11 &&\
./b2 install variant=release debug-symbols=off install --layout=system &&\
./bootstrap.sh --with-libraries=python --with-python=python3.12 &&\
./b2 install variant=release debug-symbols=off install --layout=system
WORKDIR /
RUN rm -rfv /boost_1_84_0
RUN curl -L https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.3.1.tar.gz | tar xz
WORKDIR /cfitsio-4.3.1
RUN ./configure --prefix=/usr/local && make install
WORKDIR /
RUN rm -rfv /cfitsio-4.3.1
RUN curl -L https://github.com/icecube/photospline/archive/refs/tags/v2.2.1.tar.gz | tar xz
RUN cmake -E env LDFLAGS="-lz" cmake -S photospline-2.2.1 -B photospline_build -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release &&\
make install -C photospline_build
WORKDIR /
RUN rm -rfv photospline-2.2.1 phosopline_build
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,46 @@ doi = "https://doi.org/10.5281/zenodo.8180337"

[project.optional-dependencies]
test = ["pytest","pytest-subtests"]
dev = ["tbump"]

[tool.meson-python.args]
setup = ['-Dpymodule=true']

[tool.pytest.ini_options]
addopts = "--doctest-glob='README.md'"
testpaths = ["tests", "README.md"]

[tool.cibuildwheel]
build = "cp3{7,8,9,10,11,12}-manylinux_x86_64"
manylinux-x86_64-image = "kjmeagher/nuflux-manylinux2014_x86_64"
test-extras = ["test"]
test-command = "{project}/tests/test_fluxes.py"

[tool.tbump]
github_url = "https://github.com/icecube/nuflux"

[tool.tbump.version]
current = "2.0.4"
regex = '''
(?P<major>\d+)
\.
(?P<minor>\d+)
\.
(?P<patch>\d+)
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "meson.build"
search = "version: '{current_version}'"

[[tool.tbump.file]]
src = "CITATION.cff"
search = "version: {current_version}"

[[tool.tbump.before_commit]]
name = "Update release date in citation file"
cmd = "sed -i '' \"s/date-released: .*$/date-released: $(date -uI)/\" CITATION.cff"
5 changes: 4 additions & 1 deletion src/include/nuflux/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ nuflux_headers = [
'LegacyPromptFlux.h', 'nuflux.h',
'SplineFlux2.h', 'SplineFlux.h',
]
install_headers(nuflux_headers, subdir : 'nuflux')

if not get_option('pymodule')
install_headers(nuflux_headers, subdir : 'nuflux')
endif

0 comments on commit a9d994a

Please sign in to comment.