Skip to content

Commit 91d88e9

Browse files
authored
Add workflow for building wheels (#67)
1 parent 281e9b9 commit 91d88e9

File tree

6 files changed

+122
-5
lines changed

6 files changed

+122
-5
lines changed

.github/workflows/wheel.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: wheel
2+
3+
on: [push, workflow_dispatch]
4+
5+
jobs:
6+
sdist:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Reorganize repository
11+
run: |
12+
git config user.email ""
13+
git config user.name "dummy"
14+
git subtree add --prefix python/subprojects/minpack . HEAD
15+
git mv python/{mesonpep517,pyproject}.toml
16+
git commit -m "Python dist"
17+
- run: |
18+
pipx run build . --sdist
19+
working-directory: python
20+
- uses: actions/upload-artifact@v3
21+
with:
22+
name: minpack-python-sdist
23+
path: python/dist/*.tar.gz
24+
retention-days: 5
25+
26+
manylinux:
27+
needs:
28+
- sdist
29+
runs-on: ubuntu-latest
30+
container: condaforge/linux-anvil-cos7-x86_64
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python: ['3.7', '3.8', '3.9', '3.10']
35+
36+
defaults:
37+
run:
38+
shell: ${{ matrix.shell || 'bash -l {0}' }}
39+
40+
steps:
41+
- name: Create environment
42+
run: >-
43+
mamba create -n wheel
44+
--yes
45+
c-compiler
46+
fortran-compiler
47+
python=${{ matrix.python }}
48+
auditwheel
49+
git
50+
python
51+
pip
52+
python-build
53+
pkgconfig
54+
patchelf
55+
cffi
56+
numpy
57+
meson
58+
unzip
59+
wheel
60+
- name: Download sdist
61+
uses: actions/download-artifact@v2
62+
with:
63+
name: minpack-python-sdist
64+
- name: Build wheel
65+
run: |
66+
conda activate wheel
67+
set -ex
68+
tar xvf minpack-*.tar.gz
69+
python -m build minpack-*/ --wheel
70+
auditwheel show minpack-*/dist/*.whl
71+
auditwheel repair -w minpack-*/dist minpack-*/dist/*.whl --plat ${{ env.plat }}
72+
rm minpack-*/dist/*-linux_x86_64.whl
73+
env:
74+
plat: manylinux${{ matrix.python == '3.6' && '2010' || '_2_12' }}_x86_64
75+
- uses: actions/upload-artifact@v3
76+
with:
77+
name: minpack-python-${{ matrix.python }}
78+
path: minpack-*/dist/*.whl
79+
retention-days: 5

meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ minpack_inc = minpack_lib.private_dir_include()
3131
minpack_dep = declare_dependency(
3232
link_with: minpack_lib,
3333
include_directories: [minpack_inc, include_directories('include')],
34+
variables: {'includedir': meson.current_source_dir() / 'include'},
3435
)
3536

3637
minpack_lic = files(

python/include/_minpack.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "minpack.h"

python/meson.build

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
project(
22
'minpack',
33
'c',
4-
meson_version: '>=0.53',
4+
version: '2.0.0',
5+
meson_version: '>=0.55',
56
default_options: [
67
'buildtype=debugoptimized',
78
],
89
)
910
install = true
1011

11-
minpack_dep = dependency('minpack', version: '>=2.0.0')
12-
minpack_header = files('../include/minpack.h')
12+
minpack_dep = dependency(
13+
meson.project_name(),
14+
version: '>=@0@'.format(meson.project_version()),
15+
fallback: [meson.project_name(), '@0@_dep'.format(meson.project_name())],
16+
default_options: [
17+
'default_library=static',
18+
'api=true',
19+
'python=false',
20+
],
21+
)
22+
minpack_header = files('include'/'_minpack.h')
1323

1424
subdir('minpack')

python/mesonpep517.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build-system]
2+
requires = ["meson-python", "cffi"]
3+
build-backend = "mesonpy"
4+
5+
[project]
6+
name = "minpack"
7+
version = "2.0.0"
8+
description = "Minpack includes software for solving nonlinear equations and nonlinear least squares problems"
9+
readme = "README.rst"
10+
urls.repository = "https://github.com/fortran-lang/minpack"
11+
dependencies = [
12+
"cffi",
13+
"numpy",
14+
]
15+
requires-python = ">=3.6"

python/minpack/meson.build

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ python_dep = python.dependency(required: true)
1313
# Python's CFFI is horrible in working with preprocessor statements,
1414
# therefore, we have to preprocess the header before passing it to the ffibuilder
1515
minpack_pp = configure_file(
16-
command: [cc, '-DMINPACK_CFFI=1', '-E', '@INPUT@'],
17-
input: minpack_header[0],
16+
command: [
17+
cc,
18+
'-I@0@'.format(
19+
minpack_dep.get_variable(
20+
pkgconfig: 'includedir',
21+
internal: 'includedir',
22+
).split().get(0)
23+
),
24+
'-DMINPACK_CFFI=1',
25+
'-E',
26+
'@INPUT@',
27+
],
28+
input: minpack_header,
1829
output: '@[email protected]'.format(ext_module),
1930
capture: true,
2031
)

0 commit comments

Comments
 (0)