Skip to content

Commit a65c88c

Browse files
Merge pull request #129 from oscarbenjamin/pr_meson_python
Use meson-python instead of setuptools for wheels
2 parents 1ce152d + cfe2fea commit a65c88c

16 files changed

+260
-42
lines changed

.cirrus.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ cirrus_wheels_macos_arm64_task:
99
env:
1010
PATH: /opt/homebrew/opt/[email protected]/bin:$PATH
1111
CIBW_ARCHS_MACOS: arm64
12+
CIBW_TEST_COMMAND: "python -m flint.test"
1213
install_pre_requirements_script:
13-
- brew install [email protected]
14-
- ln -s python3 /opt/homebrew/opt/[email protected]/bin/python
15-
- which python
16-
- python --version
17-
install_cibuildwheel_script:
18-
- python -m pip install cibuildwheel==2.16.2
14+
- python3 -m venv venv
15+
- venv/bin/pip install --upgrade pip
16+
- venv/bin/pip install cibuildwheel==2.16.2
1917
run_cibuildwheel_script:
20-
- bin/cibw.sh
18+
- venv/bin/cibuildwheel --platform macos
2119
wheels_artifacts:
2220
path: "wheelhouse/*"

.github/workflows/buildwheel.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: [ubuntu-20.04, windows-2019, macos-12]
13+
os: [ubuntu-20.04, windows-2019, macos-13]
1414

1515
steps:
1616
- uses: actions/checkout@v4
@@ -31,6 +31,16 @@ jobs:
3131
path-type: inherit
3232
if: ${{ matrix.os == 'windows-2019' }}
3333

34+
# Install pkgconfig on Windows from choco rather than from msys and
35+
# avoid using the Strawberry one.
36+
- run: choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
37+
if: ${{ matrix.os == 'windows-2019' }}
38+
39+
# We have to set this here rather than in the cibuildwheel config
40+
# This is probably something to do with \ vs / in paths...
41+
- run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/.local/lib/pkgconfig" >> $env:GITHUB_ENV
42+
if: ${{ matrix.os == 'windows-2019' }}
43+
3444
- name: Build wheels
3545
uses: pypa/[email protected]
3646
env:
@@ -45,7 +55,7 @@ jobs:
4555

4656
build_sdist:
4757
name: Build sdist
48-
runs-on: ubuntu-20.04
58+
runs-on: ubuntu-22.04
4959

5060
steps:
5161
- uses: actions/checkout@v4
@@ -54,6 +64,11 @@ jobs:
5464
with:
5565
python-version: '3.12'
5666

67+
- run: sudo apt-get update
68+
- run: sudo apt-get install libgmp-dev libmpfr-dev xz-utils ninja-build
69+
- run: curl -O -L https://www.flintlib.org/flint-3.1.0.tar.gz
70+
- run: tar -xzf flint-3.1.0.tar.gz
71+
- run: cd flint-3.1.0 && ./configure --disable-static && make -j4 && sudo make install
5772
- run: pip install build
5873
- run: python -m build --sdist
5974

@@ -91,7 +106,7 @@ jobs:
91106
strategy:
92107
fail-fast: false
93108
matrix:
94-
os: [ubuntu-20.04, windows-2019, macos-12]
109+
os: [ubuntu-20.04, windows-2019, macos-13]
95110
python-version: ['3.9', '3.10', '3.11', '3.12']
96111

97112
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ MANIFEST
1818
.python-version
1919
*.DS_Store
2020
.venv
21+
.hypothesis

bin/activate

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export C_INCLUDE_PATH=$(pwd)/.local/include
22
export LIBRARY_PATH=$(pwd)/.local/lib
33
export LD_LIBRARY_PATH=$(pwd)/.local/lib
4-
export PYTHONPATH=$(pwd)/src

bin/cibw.sh

-18
This file was deleted.

bin/pip_install_ubuntu.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PYTHON_FLINT=$1
3535

3636
# First install their dependencies and build dependencies
3737
sudo apt-get update
38-
sudo apt-get install libgmp-dev libmpfr-dev xz-utils
38+
sudo apt-get install libgmp-dev libmpfr-dev xz-utils ninja-build
3939

4040
if [ -z "$FLINT_GIT" ]; then
4141
# Install from release tarball

meson.build

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project('python-flint', 'cython', 'c')
2+
3+
py = import('python').find_installation(pure: false)
4+
dep_py = py.dependency()
5+
6+
cc = meson.get_compiler('c')
7+
8+
gmp_dep = dependency('gmp')
9+
mpfr_dep = dependency('mpfr')
10+
flint_dep = dependency('flint')
11+
12+
# flint.pc was missing -lflint until Flint 3.1.0
13+
if flint_dep.version().version_compare('<3.1')
14+
flint_dep = cc.find_library('flint')
15+
endif
16+
17+
pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep]
18+
19+
subdir('src/flint')

pyproject.toml

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[build-system]
2-
requires = ["setuptools",
3-
"numpy; sys_platform == 'win32' and python_version < '3.12'",
4-
"Cython>=3"]
5-
build-backend = "setuptools.build_meta"
2+
requires = ["meson-python", "cython"]
3+
build-backend = "mesonpy"
64

75
[project]
86
name = "python-flint"
@@ -21,18 +19,46 @@ classifiers = [
2119
file = "README.md"
2220
content-type = "text/markdown"
2321

22+
[tool.spin]
23+
package = "flint"
24+
25+
[tool.spin.commands]
26+
27+
"Build" = [
28+
"spin.cmds.meson.build",
29+
"spin.cmds.meson.test",
30+
"spin.cmds.build.sdist",
31+
"spin.cmds.pip.install",
32+
]
33+
"Documentation" = [
34+
"spin.cmds.meson.docs",
35+
]
36+
"Environments" = [
37+
"spin.cmds.meson.shell",
38+
"spin.cmds.meson.ipython",
39+
"spin.cmds.meson.python",
40+
"spin.cmds.meson.run",
41+
]
42+
2443
[tool.cibuildwheel]
2544
build = "cp39-* cp310-* cp311-* cp312-*"
2645
skip = "*-win32 *-manylinux_i686 *-musllinux_*"
2746
manylinux-x86_64-image = "manylinux2014"
2847
manylinux-i686-image = "manylinux2014"
2948
test-command = "python -c \"import flint; print(str(flint.fmpz(2)))\""
3049

31-
[tool.cibuildwheel.environment]
32-
# bin/build_dependencies_unix.sh places headers and shared libraries under .local
33-
C_INCLUDE_PATH = "$(pwd)/.local/include/"
34-
LIBRARY_PATH = "$(pwd)/.local/lib/"
50+
[tool.cibuildwheel.linux.environment]
51+
# LD_LIBRARY_PATH is needed by auditwheel
3552
LD_LIBRARY_PATH = "$(pwd)/.local/lib:$LD_LIBRARY_PATH"
53+
PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig"
54+
55+
[tool.cibuildwheel.macos.environment]
56+
PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig"
57+
58+
[tool.cibuildwheel.windows.environment]
59+
# Setting PKG_CONFIG_PATH here breaks pkgconfig for some reason...
60+
# We set it in the CI workflow instead.
61+
# PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig:$PKG_CONFIG_PATH"
3662

3763
[tool.cibuildwheel.linux]
3864
before-all = "bin/cibw_before_all_linux.sh"
@@ -44,6 +70,3 @@ before-all = "bin/cibw_before_all_macosx_$(uname -m).sh"
4470
before-all = "C:\\msys64\\usr\\bin\\bash bin/cibw_before_all_windows.sh"
4571
before-build = "pip install delvewheel && C:\\msys64\\usr\\bin\\bash bin/cibw_before_build_windows.sh"
4672
repair-wheel-command = "bin\\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel}"
47-
48-
[tool.cibuildwheel.windows.environment]
49-
PYTHON_FLINT_MINGW64 = "true"

src/flint/flint_base/meson.build

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pkgdir = 'flint/flint_base'
2+
3+
pyfiles = [
4+
'__init__.py',
5+
]
6+
7+
exts = [
8+
'flint_base',
9+
'flint_context',
10+
]
11+
12+
py.install_sources(
13+
pyfiles,
14+
pure: false,
15+
subdir: pkgdir,
16+
)
17+
18+
foreach ext : exts
19+
py.extension_module(
20+
ext,
21+
ext + '.pyx',
22+
dependencies: pyflint_deps,
23+
install: true,
24+
subdir: pkgdir,
25+
)
26+
endforeach

src/flint/functions/meson.build

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pyfiles = [
2+
'__init__.py',
3+
]
4+
5+
exts = [
6+
'showgood',
7+
]
8+
9+
py.install_sources(
10+
pyfiles,
11+
pure: false,
12+
subdir: 'flint/functions',
13+
)
14+
15+
foreach ext : exts
16+
py.extension_module(
17+
ext,
18+
ext + '.pyx',
19+
dependencies: pyflint_deps,
20+
install: true,
21+
subdir: 'flint/functions',
22+
)
23+
endforeach

src/flint/meson.build

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
thisdir = 'flint'
2+
3+
pyfiles = [
4+
'__init__.py',
5+
]
6+
7+
exts = [
8+
'pyflint',
9+
]
10+
11+
pkgs = [
12+
'flint_base',
13+
'types',
14+
'functions',
15+
'utils',
16+
'test',
17+
]
18+
19+
py.install_sources(
20+
pyfiles,
21+
pure: false,
22+
subdir: thisdir,
23+
)
24+
25+
foreach ext : exts
26+
py.extension_module(
27+
ext,
28+
ext + '.pyx',
29+
dependencies: pyflint_deps,
30+
install: true,
31+
subdir: thisdir,
32+
)
33+
endforeach
34+
35+
foreach pkg : pkgs
36+
subdir(pkg)
37+
endforeach

src/flint/test/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import argparse
1111

1212
import flint
13-
from flint.test.test import all_tests
13+
from flint.test.test_all import all_tests
1414

1515

1616
def run_tests(verbose=None):

src/flint/test/meson.build

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
thisdir = 'flint/test'
2+
3+
pyfiles = [
4+
'__init__.py',
5+
'__main__.py',
6+
'test_all.py',
7+
]
8+
9+
py.install_sources(
10+
pyfiles,
11+
pure: false,
12+
subdir: thisdir,
13+
)
File renamed without changes.

src/flint/types/meson.build

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
thisdir = 'flint/types'
2+
3+
pyfiles = [
4+
'__init__.py',
5+
]
6+
7+
exts = [
8+
'fmpz',
9+
'fmpz_poly',
10+
'fmpz_mat',
11+
'fmpz_series',
12+
13+
'fmpq',
14+
'fmpq_poly',
15+
'fmpq_mat',
16+
'fmpq_series',
17+
18+
'nmod',
19+
'nmod_poly',
20+
'nmod_mat',
21+
'nmod_series',
22+
23+
'fmpz_mod',
24+
'fmpz_mod_poly',
25+
'fmpz_mod_mat',
26+
27+
'arf',
28+
29+
'arb',
30+
'arb_poly',
31+
'arb_mat',
32+
'arb_series',
33+
34+
'acb',
35+
'acb_poly',
36+
'acb_mat',
37+
'acb_series',
38+
39+
'dirichlet',
40+
41+
'fmpz_mpoly',
42+
]
43+
44+
py.install_sources(
45+
pyfiles,
46+
pure: false,
47+
subdir: thisdir,
48+
)
49+
50+
foreach ext : exts
51+
py.extension_module(
52+
ext,
53+
ext + '.pyx',
54+
dependencies: pyflint_deps,
55+
install: true,
56+
subdir: thisdir,
57+
)
58+
endforeach

src/flint/utils/meson.build

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
thisdir = 'flint/utils'
2+
3+
pyfiles = [
4+
'__init__.py',
5+
'flint_exceptions.py',
6+
]
7+
8+
exts = []
9+
10+
py.install_sources(
11+
pyfiles,
12+
pure: false,
13+
subdir: thisdir,
14+
)
15+
16+
foreach ext : exts
17+
py.extension_module(
18+
ext,
19+
ext + '.pyx',
20+
dependencies: pyflint_deps,
21+
install: true,
22+
subdir: thisdir,
23+
)
24+
endforeach

0 commit comments

Comments
 (0)