Skip to content

Use meson-python instead of setuptools for wheels #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7e2c4b3
Use meson-python instead of setuptools for wheels
oscarbenjamin Mar 20, 2024
c7d58a3
Install dependencies when building the sdist
oscarbenjamin Mar 20, 2024
066dd56
Use newer Ubuntu for CI job
oscarbenjamin Mar 20, 2024
5c5ed7f
Add lib directories to PATH for MinGW to find them
oscarbenjamin Mar 21, 2024
1433d02
Use pkg-config to find the dependencies
oscarbenjamin Mar 21, 2024
0c80033
Install pkg-config when building Windows wheels
oscarbenjamin Mar 21, 2024
c377c3f
Use Flint 3.1.0 for alternate CPython jobs
oscarbenjamin Mar 21, 2024
947dda5
Use pkgconf instead of pkg-conf on Windows
oscarbenjamin Mar 21, 2024
b971367
Use 3.0.1 for alternate Python jobs
oscarbenjamin Mar 21, 2024
64b7147
Install pkgconf in Windows
oscarbenjamin Mar 21, 2024
e290517
Don't use path-type:inherit
oscarbenjamin Mar 21, 2024
d19ffa5
Add back path-type: inherit
oscarbenjamin Mar 21, 2024
4fa6371
Remove Strawberry Perl from Windows CI
oscarbenjamin Mar 21, 2024
bf18a35
Install pkgconfig from choco
oscarbenjamin Mar 21, 2024
819f1d9
Print pkgconfig files
oscarbenjamin Mar 21, 2024
6fcd116
Don't remove Strawbery
oscarbenjamin Mar 21, 2024
f63aed5
Show all files in .local
oscarbenjamin Mar 21, 2024
ddbddbb
Show all files after building
oscarbenjamin Mar 21, 2024
f4b8aea
try copying the DLL to lib...
oscarbenjamin Mar 21, 2024
c1ae393
try making libgmp.dll as well...
oscarbenjamin Mar 21, 2024
3dd4088
print logs from CI ...
oscarbenjamin Mar 21, 2024
615d3b7
Don't copy the files that only exist on Windows
oscarbenjamin Mar 21, 2024
0849e11
Only show logs on failure
oscarbenjamin Mar 21, 2024
34d9759
Try setting environment variable in GA .yml file...
oscarbenjamin Mar 21, 2024
d240b83
Don't override environment variables on Windows
oscarbenjamin Mar 22, 2024
c23a58c
Add back the Windows cibuildwheel env var
oscarbenjamin Mar 22, 2024
a03b692
Remove PYTHON_FLINT_MINGW64 env var
oscarbenjamin Mar 22, 2024
a9d07c0
Set env var in GA yml file again
oscarbenjamin Mar 22, 2024
1f7bcd8
Restore fully to when the Windows build worked...
oscarbenjamin Mar 22, 2024
0647f59
Remove MINGGW^$ var
oscarbenjamin Mar 22, 2024
cb8aa77
Remove environment variables from unix build in CI
oscarbenjamin Mar 23, 2024
06c297d
Add back PKG_CONFIG_PATH on unix
oscarbenjamin Mar 23, 2024
7c665d9
Add back LD_LBRARY_PATH for auditwheel
oscarbenjamin Mar 23, 2024
6d76c18
Try setting PKG_CONFIG_PATH both ways...
oscarbenjamin Mar 23, 2024
9c89ad9
Set 3rd PKG_CONFIG_PATH
oscarbenjamin Mar 23, 2024
5fd90e2
Don't set any environment variables on Windows
oscarbenjamin Mar 23, 2024
e3576c0
try setting PKG_CONFIG_PATH
oscarbenjamin Mar 23, 2024
4517a37
Set PKG_CONFIG_PATH in CI workflow
oscarbenjamin Mar 23, 2024
46fe647
Add temporary CI job
oscarbenjamin Mar 24, 2024
df3d923
Add -lfint for Flint < 3.1.0
oscarbenjamin Mar 25, 2024
20bfdfa
Use cc.find_library
oscarbenjamin Mar 25, 2024
bd97d07
Update OSX runners to macos-13
oscarbenjamin Mar 25, 2024
2bb1443
Remove old cibw.sh script
oscarbenjamin Mar 25, 2024
9b1539f
Remove temp CI job
oscarbenjamin Mar 25, 2024
6af8e93
Use isolated build directory
oscarbenjamin Mar 25, 2024
8cbb5f1
Remove msys pkgconfig
oscarbenjamin Mar 25, 2024
899858f
Remove unnecessary build dependencies
oscarbenjamin Mar 25, 2024
844de58
Add cython back tothe build dependencies
oscarbenjamin Mar 25, 2024
963d47f
Remove redundant dependency line in meson.build
oscarbenjamin Mar 26, 2024
b0e0e3b
rename test.py -> test_all.py for pytest
oscarbenjamin Apr 4, 2024
c2ccbdc
ignore hypothesis
oscarbenjamin Apr 4, 2024
cfe2fea
Add spin cofiguration
oscarbenjamin Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ cirrus_wheels_macos_arm64_task:
env:
PATH: /opt/homebrew/opt/[email protected]/bin:$PATH
CIBW_ARCHS_MACOS: arm64
CIBW_TEST_COMMAND: "python -m flint.test"
install_pre_requirements_script:
- brew install [email protected]
- ln -s python3 /opt/homebrew/opt/[email protected]/bin/python
- which python
- python --version
install_cibuildwheel_script:
- python -m pip install cibuildwheel==2.16.2
- python3 -m venv venv
- venv/bin/pip install --upgrade pip
- venv/bin/pip install cibuildwheel==2.16.2
run_cibuildwheel_script:
- bin/cibw.sh
- venv/bin/cibuildwheel --platform macos
wheels_artifacts:
path: "wheelhouse/*"
21 changes: 18 additions & 3 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
os: [ubuntu-20.04, windows-2019, macos-13]

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

# Install pkgconfig on Windows from choco rather than from msys and
# avoid using the Strawberry one.
- run: choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
if: ${{ matrix.os == 'windows-2019' }}

# We have to set this here rather than in the cibuildwheel config
# This is probably something to do with \ vs / in paths...
- run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/.local/lib/pkgconfig" >> $env:GITHUB_ENV
if: ${{ matrix.os == 'windows-2019' }}

- name: Build wheels
uses: pypa/[email protected]
env:
Expand All @@ -45,7 +55,7 @@ jobs:

build_sdist:
name: Build sdist
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -54,6 +64,11 @@ jobs:
with:
python-version: '3.12'

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

Expand Down Expand Up @@ -91,7 +106,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
os: [ubuntu-20.04, windows-2019, macos-13]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ MANIFEST
.python-version
*.DS_Store
.venv
.hypothesis
1 change: 0 additions & 1 deletion bin/activate
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export C_INCLUDE_PATH=$(pwd)/.local/include
export LIBRARY_PATH=$(pwd)/.local/lib
export LD_LIBRARY_PATH=$(pwd)/.local/lib
export PYTHONPATH=$(pwd)/src
18 changes: 0 additions & 18 deletions bin/cibw.sh

This file was deleted.

2 changes: 1 addition & 1 deletion bin/pip_install_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PYTHON_FLINT=$1

# First install their dependencies and build dependencies
sudo apt-get update
sudo apt-get install libgmp-dev libmpfr-dev xz-utils
sudo apt-get install libgmp-dev libmpfr-dev xz-utils ninja-build

if [ -z "$FLINT_GIT" ]; then
# Install from release tarball
Expand Down
19 changes: 19 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
project('python-flint', 'cython', 'c')

py = import('python').find_installation(pure: false)
dep_py = py.dependency()

cc = meson.get_compiler('c')

gmp_dep = dependency('gmp')
mpfr_dep = dependency('mpfr')
flint_dep = dependency('flint')

# flint.pc was missing -lflint until Flint 3.1.0
if flint_dep.version().version_compare('<3.1')
flint_dep = cc.find_library('flint')
endif

pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep]

subdir('src/flint')
45 changes: 34 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[build-system]
requires = ["setuptools",
"numpy; sys_platform == 'win32' and python_version < '3.12'",
"Cython>=3"]
build-backend = "setuptools.build_meta"
requires = ["meson-python", "cython"]
build-backend = "mesonpy"

[project]
name = "python-flint"
Expand All @@ -21,18 +19,46 @@ classifiers = [
file = "README.md"
content-type = "text/markdown"

[tool.spin]
package = "flint"

[tool.spin.commands]

"Build" = [
"spin.cmds.meson.build",
"spin.cmds.meson.test",
"spin.cmds.build.sdist",
"spin.cmds.pip.install",
]
"Documentation" = [
"spin.cmds.meson.docs",
]
"Environments" = [
"spin.cmds.meson.shell",
"spin.cmds.meson.ipython",
"spin.cmds.meson.python",
"spin.cmds.meson.run",
]

[tool.cibuildwheel]
build = "cp39-* cp310-* cp311-* cp312-*"
skip = "*-win32 *-manylinux_i686 *-musllinux_*"
manylinux-x86_64-image = "manylinux2014"
manylinux-i686-image = "manylinux2014"
test-command = "python -c \"import flint; print(str(flint.fmpz(2)))\""

[tool.cibuildwheel.environment]
# bin/build_dependencies_unix.sh places headers and shared libraries under .local
C_INCLUDE_PATH = "$(pwd)/.local/include/"
LIBRARY_PATH = "$(pwd)/.local/lib/"
[tool.cibuildwheel.linux.environment]
# LD_LIBRARY_PATH is needed by auditwheel
LD_LIBRARY_PATH = "$(pwd)/.local/lib:$LD_LIBRARY_PATH"
PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig"

[tool.cibuildwheel.macos.environment]
PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig"

[tool.cibuildwheel.windows.environment]
# Setting PKG_CONFIG_PATH here breaks pkgconfig for some reason...
# We set it in the CI workflow instead.
# PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig:$PKG_CONFIG_PATH"

[tool.cibuildwheel.linux]
before-all = "bin/cibw_before_all_linux.sh"
Expand All @@ -44,6 +70,3 @@ before-all = "bin/cibw_before_all_macosx_$(uname -m).sh"
before-all = "C:\\msys64\\usr\\bin\\bash bin/cibw_before_all_windows.sh"
before-build = "pip install delvewheel && C:\\msys64\\usr\\bin\\bash bin/cibw_before_build_windows.sh"
repair-wheel-command = "bin\\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel}"

[tool.cibuildwheel.windows.environment]
PYTHON_FLINT_MINGW64 = "true"
26 changes: 26 additions & 0 deletions src/flint/flint_base/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pkgdir = 'flint/flint_base'

pyfiles = [
'__init__.py',
]

exts = [
'flint_base',
'flint_context',
]

py.install_sources(
pyfiles,
pure: false,
subdir: pkgdir,
)

foreach ext : exts
py.extension_module(
ext,
ext + '.pyx',
dependencies: pyflint_deps,
install: true,
subdir: pkgdir,
)
endforeach
23 changes: 23 additions & 0 deletions src/flint/functions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pyfiles = [
'__init__.py',
]

exts = [
'showgood',
]

py.install_sources(
pyfiles,
pure: false,
subdir: 'flint/functions',
)

foreach ext : exts
py.extension_module(
ext,
ext + '.pyx',
dependencies: pyflint_deps,
install: true,
subdir: 'flint/functions',
)
endforeach
37 changes: 37 additions & 0 deletions src/flint/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
thisdir = 'flint'

pyfiles = [
'__init__.py',
]

exts = [
'pyflint',
]

pkgs = [
'flint_base',
'types',
'functions',
'utils',
'test',
]

py.install_sources(
pyfiles,
pure: false,
subdir: thisdir,
)

foreach ext : exts
py.extension_module(
ext,
ext + '.pyx',
dependencies: pyflint_deps,
install: true,
subdir: thisdir,
)
endforeach

foreach pkg : pkgs
subdir(pkg)
endforeach
2 changes: 1 addition & 1 deletion src/flint/test/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import argparse

import flint
from flint.test.test import all_tests
from flint.test.test_all import all_tests


def run_tests(verbose=None):
Expand Down
13 changes: 13 additions & 0 deletions src/flint/test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
thisdir = 'flint/test'

pyfiles = [
'__init__.py',
'__main__.py',
'test_all.py',
]

py.install_sources(
pyfiles,
pure: false,
subdir: thisdir,
)
File renamed without changes.
58 changes: 58 additions & 0 deletions src/flint/types/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
thisdir = 'flint/types'

pyfiles = [
'__init__.py',
]

exts = [
'fmpz',
'fmpz_poly',
'fmpz_mat',
'fmpz_series',

'fmpq',
'fmpq_poly',
'fmpq_mat',
'fmpq_series',

'nmod',
'nmod_poly',
'nmod_mat',
'nmod_series',

'fmpz_mod',
'fmpz_mod_poly',
'fmpz_mod_mat',

'arf',

'arb',
'arb_poly',
'arb_mat',
'arb_series',

'acb',
'acb_poly',
'acb_mat',
'acb_series',

'dirichlet',

'fmpz_mpoly',
]

py.install_sources(
pyfiles,
pure: false,
subdir: thisdir,
)

foreach ext : exts
py.extension_module(
ext,
ext + '.pyx',
dependencies: pyflint_deps,
install: true,
subdir: thisdir,
)
endforeach
24 changes: 24 additions & 0 deletions src/flint/utils/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
thisdir = 'flint/utils'

pyfiles = [
'__init__.py',
'flint_exceptions.py',
]

exts = []

py.install_sources(
pyfiles,
pure: false,
subdir: thisdir,
)

foreach ext : exts
py.extension_module(
ext,
ext + '.pyx',
dependencies: pyflint_deps,
install: true,
subdir: thisdir,
)
endforeach
Loading