Skip to content

Commit

Permalink
Adds PyPi packaging
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Jeandet <[email protected]>
  • Loading branch information
jeandet committed Mar 1, 2022
1 parent 0d684c0 commit 40553b7
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: C/C++ CI

on: [push]

jobs:
build:
name: build an tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Install dependencies
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev python3-astropy lcov g++ ninja-build && sudo pip3 install --upgrade meson
- name: Configure with meson
run: meson -Db_coverage=true -Dwith_tests=true . build
- name: Build (meson)
run: ninja -C build
- name: Run tests (meson)
run: ninja test -C build
- name: Generate Coverage repport
run: |
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.info
flags: unittests
name: codecov-cdfpp
yml: ./codecov.yml
fail_ci_if_error: true
32 changes: 32 additions & 0 deletions .github/workflows/pythonpublish-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python packages linux

on:
release:
types: [published]

jobs:
build:
name: build python packages
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
steps:
- name: install deps
run: yum install -y libcurl-devel && /opt/python/cp310-cp310/bin/pip install twine
- uses: actions/checkout@v1
with:
submodules: true
- name: Build for Python 3.7
run: /opt/python/cp37-cp37m/bin/python -m build .
- name: Build for Python 3.8
run: /opt/python/cp38-cp38/bin/python -m build .
- name: Build for Python 3.9
run: /opt/python/cp39-cp39/bin/python -m build .
- name: Build for Python 3.10
run: /opt/python/cp310-cp310/bin/python -m build .
- name: Make wheels universal
run: for wheel in $(ls dist/*.whl); do auditwheel repair $wheel; done
- name: Publish on PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: /opt/python/cp310-cp310/bin/twine upload wheelhouse/*
29 changes: 29 additions & 0 deletions .github/workflows/pythonpublish-osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python packages OSX

on:
release:
types: [published]

jobs:
build:
runs-on: macos-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v1
- name: Build python wheel
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: |
pip install twine build auditwheel
FC=gfortran-11 CC=gcc-11 CXX=g++-11 python -m build .
- name: Publish on PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*.whl
29 changes: 29 additions & 0 deletions .github/workflows/pythonpublish-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python packages Windows

on:
release:
types: [published]

jobs:
build:
runs-on: windows-latest
strategy:
max-parallel: 1
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v1
- name: Build python wheel
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: |
pip install twine build
python -m build .
- name: Publish on PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TBC
15 changes: 11 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'py_tsyganenko',
'cpp', 'c', 'fortran',
version : '0.1.3',
version : '0.1.0',
default_options : ['warning_level=2', 'cpp_std=c++17', 'fortran_std=legacy'],
license : 'GPL3'
)
Expand All @@ -11,17 +11,24 @@ pybind11_dep = dependency('pybind11', required : true)
pymod = import('python')
python3 = pymod.find_installation('python3')

tsyganenko = library('tsyganenko','src/Geopack-2008_dp.for','src/T96.for',
extra_files = ['setup.py', 'pyproject.toml', 'README.md',
'.github/workflows/ccpp.yml', '.github/workflows/pythonpublish-linux.yml',
'.github/workflows/pythonpublish-osx.yml', '.github/workflows/pythonpublish-win.yml']

tsyganenko = static_library('tsyganenko','src/Geopack-2008_dp.for','src/T96.for',
extra_files: extra_files,
fortran_args:['-fdollar-ok', '-ffixed-form', '-fdefault-double-8', '-fdefault-real-8'])

libquadmath = meson.get_compiler('fortran').find_library('quadmath')

srcs = [
'wrapper/wrapper.cpp'
]

python3.extension_module('py_tsyganenko', srcs,
link_with:tsyganenko,
link_with:[tsyganenko],
include_directories:'src',
dependencies: [ pybind11_dep, python3.dependency() ],
dependencies: [ pybind11_dep, python3.dependency(),libquadmath],
install: true
)

27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["mesonpep517", "ninja",]
build-backend = "mesonpep517.buildapi"


[tool.mesonpep517.metadata]
description="A simple python wrapper of N. A. Tsyganenko Fortran models and Geopack module"
author = "Alexis Jeandet"
author-email = "[email protected]"
summary = "A simple python wrapper of N. A. Tsyganenko Fortran models and Geopack module"
[project]
[urls]
homepage = "https://github.com/LaboratoryOfPlasmaPhysics/py_tsyganenko"
license = "GNU General Public License v3"
readme = "README.md"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
]
dependencies = []
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

import setuptools

if __name__ == "__main__":
setuptools.setup()

0 comments on commit 40553b7

Please sign in to comment.