diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml new file mode 100644 index 0000000..a0ff6dc --- /dev/null +++ b/.github/workflows/wheel.yml @@ -0,0 +1,79 @@ +name: wheel + +on: [push, workflow_dispatch] + +jobs: + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Reorganize repository + run: | + git config user.email "" + git config user.name "dummy" + git subtree add --prefix python/subprojects/minpack . HEAD + git mv python/{mesonpep517,pyproject}.toml + git commit -m "Python dist" + - run: | + pipx run build . --sdist + working-directory: python + - uses: actions/upload-artifact@v3 + with: + name: minpack-python-sdist + path: python/dist/*.tar.gz + retention-days: 5 + + manylinux: + needs: + - sdist + runs-on: ubuntu-latest + container: condaforge/linux-anvil-cos7-x86_64 + strategy: + fail-fast: false + matrix: + python: ['3.7', '3.8', '3.9', '3.10'] + + defaults: + run: + shell: ${{ matrix.shell || 'bash -l {0}' }} + + steps: + - name: Create environment + run: >- + mamba create -n wheel + --yes + c-compiler + fortran-compiler + python=${{ matrix.python }} + auditwheel + git + python + pip + python-build + pkgconfig + patchelf + cffi + numpy + meson + unzip + wheel + - name: Download sdist + uses: actions/download-artifact@v2 + with: + name: minpack-python-sdist + - name: Build wheel + run: | + conda activate wheel + set -ex + tar xvf minpack-*.tar.gz + python -m build minpack-*/ --wheel + auditwheel show minpack-*/dist/*.whl + auditwheel repair -w minpack-*/dist minpack-*/dist/*.whl --plat ${{ env.plat }} + rm minpack-*/dist/*-linux_x86_64.whl + env: + plat: manylinux${{ matrix.python == '3.6' && '2010' || '_2_12' }}_x86_64 + - uses: actions/upload-artifact@v3 + with: + name: minpack-python-${{ matrix.python }} + path: minpack-*/dist/*.whl + retention-days: 5 diff --git a/meson.build b/meson.build index 7d5e9e8..cdeece5 100644 --- a/meson.build +++ b/meson.build @@ -31,6 +31,7 @@ minpack_inc = minpack_lib.private_dir_include() minpack_dep = declare_dependency( link_with: minpack_lib, include_directories: [minpack_inc, include_directories('include')], + variables: {'includedir': meson.current_source_dir() / 'include'}, ) minpack_lic = files( diff --git a/python/include/_minpack.h b/python/include/_minpack.h new file mode 100644 index 0000000..b3e8ff0 --- /dev/null +++ b/python/include/_minpack.h @@ -0,0 +1 @@ +#include "minpack.h" diff --git a/python/meson.build b/python/meson.build index 91d3eaa..17f6cbd 100644 --- a/python/meson.build +++ b/python/meson.build @@ -1,14 +1,24 @@ project( 'minpack', 'c', - meson_version: '>=0.53', + version: '2.0.0', + meson_version: '>=0.55', default_options: [ 'buildtype=debugoptimized', ], ) install = true -minpack_dep = dependency('minpack', version: '>=2.0.0') -minpack_header = files('../include/minpack.h') +minpack_dep = dependency( + meson.project_name(), + version: '>=@0@'.format(meson.project_version()), + fallback: [meson.project_name(), '@0@_dep'.format(meson.project_name())], + default_options: [ + 'default_library=static', + 'api=true', + 'python=false', + ], +) +minpack_header = files('include'/'_minpack.h') subdir('minpack') diff --git a/python/mesonpep517.toml b/python/mesonpep517.toml new file mode 100644 index 0000000..953de00 --- /dev/null +++ b/python/mesonpep517.toml @@ -0,0 +1,15 @@ +[build-system] +requires = ["meson-python", "cffi"] +build-backend = "mesonpy" + +[project] +name = "minpack" +version = "2.0.0" +description = "Minpack includes software for solving nonlinear equations and nonlinear least squares problems" +readme = "README.rst" +urls.repository = "https://github.com/fortran-lang/minpack" +dependencies = [ + "cffi", + "numpy", +] +requires-python = ">=3.6" diff --git a/python/minpack/meson.build b/python/minpack/meson.build index 812ba00..bc7bca7 100644 --- a/python/minpack/meson.build +++ b/python/minpack/meson.build @@ -13,8 +13,19 @@ python_dep = python.dependency(required: true) # Python's CFFI is horrible in working with preprocessor statements, # therefore, we have to preprocess the header before passing it to the ffibuilder minpack_pp = configure_file( - command: [cc, '-DMINPACK_CFFI=1', '-E', '@INPUT@'], - input: minpack_header[0], + command: [ + cc, + '-I@0@'.format( + minpack_dep.get_variable( + pkgconfig: 'includedir', + internal: 'includedir', + ).split().get(0) + ), + '-DMINPACK_CFFI=1', + '-E', + '@INPUT@', + ], + input: minpack_header, output: '@0@.h'.format(ext_module), capture: true, )