Skip to content

Commit

Permalink
Add workflow for building wheels (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk authored May 20, 2022
1 parent 281e9b9 commit 91d88e9
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 5 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions python/include/_minpack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "minpack.h"
16 changes: 13 additions & 3 deletions python/meson.build
Original file line number Diff line number Diff line change
@@ -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')
15 changes: 15 additions & 0 deletions python/mesonpep517.toml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 13 additions & 2 deletions python/minpack/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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: '@[email protected]'.format(ext_module),
capture: true,
)
Expand Down

0 comments on commit 91d88e9

Please sign in to comment.