From 61115998122c534b0d18828d1dd1d6fc7c6c57b7 Mon Sep 17 00:00:00 2001 From: Mi! Date: Mon, 4 Jul 2022 22:45:39 +0200 Subject: [PATCH] ci: buildup ci/cd (#85) * ci: adding black * ci: adding wheel builder --- .github/workflows/black.yaml | 10 +++++ .github/workflows/build-wheels.yaml | 61 +++++++++++++++++++++++++++++ README.md | 12 +++++- pyproject.toml | 4 +- setup.py | 14 ++++--- 5 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/black.yaml create mode 100644 .github/workflows/build-wheels.yaml diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml new file mode 100644 index 0000000..b04fb15 --- /dev/null +++ b/.github/workflows/black.yaml @@ -0,0 +1,10 @@ +name: Lint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: psf/black@stable diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml new file mode 100644 index 0000000..836d2a7 --- /dev/null +++ b/.github/workflows/build-wheels.yaml @@ -0,0 +1,61 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, macOS-10.15] + # Exclude windows-2019 + + steps: + - uses: actions/checkout@v3 + + + - name: Build wheels + uses: pypa/cibuildwheel@v2.7.0 + # to supply options, put them in 'env', like: + env: + CIBW_ARCHS_MACOS: x86_64 universal2 + CIBW_SKIP: pp* + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + # 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@v3 + with: + # unpacks default artifact into dist/ + # if `name: artifact` is omitted, the action will create extra parent dir + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + # To test: repository_url: https://test.pypi.org/legacy/ diff --git a/README.md b/README.md index f619db9..5839f6d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,19 @@ # Kite -![Python3](https://img.shields.io/badge/Python-3.x-brightgreen.svg) + [![Docs](https://img.shields.io/badge/kite-Documentation-blue.svg)](https://pyrocko.org/kite/docs/current/) +[![Build](https://github.com/pyrocko/kite/actions/workflows/build-wheels.yaml/badge.svg)](https://github.com/pyrocko/kite/actions/workflows/build-wheels.yaml) +Code style: black +![Python3](https://img.shields.io/badge/Python-3.7-brightgreen.svg) _Preparation of InSAR surface displacement maps for geophysical modelling_ +## Installation + +Install from pip: + +```sh +pip install kite +``` ## Introduction This framework is streamlining InSAR displacement processing routines for earthquake inversion through [Pyrocko](https://www.pyrocko.org) and Grond. diff --git a/pyproject.toml b/pyproject.toml index 919ab1a..0525332 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [build-system] -requires = ["setuptools ~= 61.0.0"] +requires = ["setuptools >= 61.0.0", "oldest-supported-numpy"] build-backend = "setuptools.build_meta" [project] name = "kite" version = "1.5.0" -requires-python = ">=3.6" +requires-python = ">=3.7" license = {text = "GPLv3"} description = "InSAR unwrapped surface displacement processing for earthquake modelling." readme = "README.md" diff --git a/setup.py b/setup.py index 08bdd15..8d94fb5 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,8 @@ import platform import tempfile +from distutils.sysconfig import get_python_inc + from setuptools import setup, Extension from os.path import join as pjoin @@ -122,17 +124,17 @@ def _have_openmp(): Extension( "kite.covariance_ext", sources=[pjoin("kite/ext", "covariance.c")], - include_dirs=[numpy.get_include()], - extra_compile_args=[] + omp_arg, - extra_link_args=[] + omp_lib, + include_dirs=[numpy.get_include(), get_python_inc()], + extra_compile_args=omp_arg, + extra_link_args=omp_lib, language="c", ), Extension( "kite.sources.disloc_ext", sources=[pjoin("kite/sources/ext", "disloc.c")], - include_dirs=[numpy.get_include()], - extra_compile_args=[] + omp_arg, - extra_link_args=[] + omp_lib, + include_dirs=[numpy.get_include(), get_python_inc()], + extra_compile_args=omp_arg, + extra_link_args=omp_lib, language="c", ), ]