diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 0000000..902f55b --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -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 diff --git a/.github/workflows/pythonpublish-linux.yml b/.github/workflows/pythonpublish-linux.yml new file mode 100644 index 0000000..28f7aeb --- /dev/null +++ b/.github/workflows/pythonpublish-linux.yml @@ -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/* diff --git a/.github/workflows/pythonpublish-osx.yml b/.github/workflows/pythonpublish-osx.yml new file mode 100644 index 0000000..7208e9e --- /dev/null +++ b/.github/workflows/pythonpublish-osx.yml @@ -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 diff --git a/.github/workflows/pythonpublish-win.yml b/.github/workflows/pythonpublish-win.yml new file mode 100644 index 0000000..760a2c0 --- /dev/null +++ b/.github/workflows/pythonpublish-win.yml @@ -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/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..402ec4d --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +TBC diff --git a/meson.build b/meson.build index f15be1c..5fd6896 100644 --- a/meson.build +++ b/meson.build @@ -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' ) @@ -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 ) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e223bdf --- /dev/null +++ b/pyproject.toml @@ -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 = "alexis.jeandet@member.fsf.org" +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 = [] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bac24a4 --- /dev/null +++ b/setup.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +import setuptools + +if __name__ == "__main__": + setuptools.setup()