Skip to content

Commit

Permalink
Merge pull request #254 from casacore/use-cibuildwheel
Browse files Browse the repository at this point in the history
Use cibuildwheel

This PR adds support for building `python-casacore` using [cibuildwheel](https://cibuildwheel.readthedocs.io/en/stable/), and a GitHub workflow that builds and uploads these wheels to [PyPI](https://pypi.org/project/python-casacore/).
  • Loading branch information
gmloose authored Feb 16, 2024
2 parents 53e35d0 + 2820655 commit c8a686c
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 24 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and upload to PyPI

# Only build and upload when a new release tag is created
# on:
# push:
# tags:
# - "v[0-9]+.[0-9]+.[0-9]+"
# - "v[0-9]+.[0-9]+.[0-9]+[a-z]+[0-9]+"
# Alternatively, build on every branch push, tag push, and pull request change
on: [push] #, pull_request]

jobs:

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest] #, macos-latest]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
# Temporary allow overwrite until we use setuptools_scm to
# generate unique version numbers on every push
overwrite: true

upload_pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [build_sdist, build_wheels]
environment:
name: pypi
url: https://pypi.org/p/python-casacore
# For testing, use TestPyPI
# url: https://test.pypi.org/p/python-casacore
permissions:
id-token: write
# Upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# Alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/[email protected]
with:
# For testing, use TestPyPI
# repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
10 changes: 5 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
dist:
# - pep8
# - mypy
- py2_kern6
- py3_kern6
# - py2_kern6
# - py3_kern6
- py3_kern7
- py3_casacore_master
- py3_casacore_v3.3
# - py3_casacore_v3.3
- py3_casacore_v3.4
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build container
run: docker build . -t ${{ matrix.dist }} -f .github/workflows/${{ matrix.dist }}.docker
Expand Down Expand Up @@ -55,4 +55,4 @@ jobs:
# name: Publish Linux binary wheels
# with:
# path: bridge/*.whl
#
#
4 changes: 2 additions & 2 deletions .github/workflows/mypy.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM kernsuite/base:7
RUN docker-apt-install python3-pip
RUN pip3 install mypy
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN mypy --ignore-missing-imports casacore

6 changes: 3 additions & 3 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:

jobs:
osx:
runs-on: macos-10.15
runs-on: macos-11
continue-on-error: true

steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: install homebrew packages
run: |
Expand All @@ -40,6 +40,6 @@ jobs:
run: venv/bin/delocate-wheel -v dist/*.whl

- name: Publish OS X binary wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
path: dist/*.whl
4 changes: 2 additions & 2 deletions .github/workflows/pep8.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM kernsuite/base:7
RUN docker-apt-install python3-pip
RUN pip3 install pycodestyle
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pycodestyle casacore --ignore=E501

4 changes: 2 additions & 2 deletions .github/workflows/py2_kern6.docker
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN docker-apt-install \
python-six \
python-pip \
python-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip install -e .
RUN pip install -r tests/requirements.txt
RUN nosetests --with-coverage --verbose --cover-package=casacore
4 changes: 2 additions & 2 deletions .github/workflows/py3_casacore_master.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN docker-apt-install \
python3-six \
python3-pip \
python3-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip3 install -e .
RUN pip3 install -r tests/requirements.txt
RUN nosetests3 --with-coverage --verbose --cover-package=casacore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/py3_casacore_v3.3.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN docker-apt-install \
python3-six \
python3-pip \
python3-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip3 install -e .
RUN pip3 install -r tests/requirements.txt
RUN nosetests3 --with-coverage --verbose --cover-package=casacore
4 changes: 2 additions & 2 deletions .github/workflows/py3_casacore_v3.4.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN docker-apt-install \
python3-six \
python3-pip \
python3-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip3 install -e .
RUN pip3 install -r tests/requirements.txt
RUN nosetests3 --with-coverage --verbose --cover-package=casacore
4 changes: 2 additions & 2 deletions .github/workflows/py3_kern6.docker
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ RUN docker-apt-install \
python3-six \
python3-pip \
python3-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip3 install -e .
RUN pip3 install -r tests/requirements.txt
RUN nosetests3 --with-coverage --verbose --cover-package=casacore
4 changes: 2 additions & 2 deletions .github/workflows/py3_kern7.docker
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ RUN docker-apt-install \
python3-six \
python3-pip \
python3-nose
ADD . /code
WORKDIR /code
ADD . /src
WORKDIR /src
RUN pip3 install -e .
RUN pip3 install -r tests/requirements.txt
RUN nosetests3 --with-coverage --verbose --cover-package=casacore
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = [
"build",
"cmake>=3.18",
"oldest-supported-numpy",
"setuptools",
"wheel",
]

[tool.cibuildwheel]
build = "cp3{7,8,9,10,11,12}-*_x86_64"
build-verbosity = 1
environment = """ \
CFLAGS="-I/usr/include/cfitsio" \
LD_LIBRARY_PATH=/opt/boost/lib \
"""
test-command = "cd {package}/tests && pytest"
test-requires = "pytest"

[tool.cibuildwheel.macos]
repair-wheel-command = """\
DYLD_LIBRARY_PATH=${BOOST_INSTALL_DIR}/lib delocate-wheel \
--require-archs {delocate_archs} -w {dest_dir} -v {wheel}\
"""

[tool.cibuildwheel.linux]
skip = ["*-musllinux_*"]

[[tool.cibuildwheel.overrides]]
select="cp37-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py37_master"

[[tool.cibuildwheel.overrides]]
select="cp38-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py38_master"

[[tool.cibuildwheel.overrides]]
select="cp39-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py39_master"

[[tool.cibuildwheel.overrides]]
select="cp310-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py310_master"

[[tool.cibuildwheel.overrides]]
select="cp311-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py311_master"

[[tool.cibuildwheel.overrides]]
select="cp312-*"
manylinux-x86_64-image = "quay.io/casacore/casacore:py312_master"

0 comments on commit c8a686c

Please sign in to comment.