-
-
Notifications
You must be signed in to change notification settings - Fork 30
Migrate from setuptools to meson-python build backend #182
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
dimpase
merged 13 commits into
sagemath:master
from
tobiasdiez:copilot/fix-3964b91e-9f2a-4559-822d-031eb0fb710f
Aug 24, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
24c1e1b
Initial plan
Copilot df9eb90
Initial analysis and planning for setuptools to meson-python migration
Copilot 62fce03
Create working meson.build configuration
Copilot 98d94b3
Complete migration from setuptools to meson-python
Copilot 8bfe949
Improve meson build
tobiasdiez 3815f81
Add instructions on how to build via conda
tobiasdiez 1668a12
Fix failing tests
tobiasdiez 7fb7f10
Fix Unicode-to-C coercion errors
tobiasdiez 2227b12
Cleanup meson script based on reviewer feedback
tobiasdiez 2e63fe1
Make license info compatible with PEP 639
tobiasdiez a41195d
http -> https
tobiasdiez c44f727
Remove unnecessary distutils comments
tobiasdiez 933cc14
bump constraint on meson-python version
dimpase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
py.install_sources( | ||
'__init__.py', | ||
'closure.pxd', | ||
'convert.pxd', | ||
'gen.pxd', | ||
'handle_error.pxd', | ||
'pari_instance.pxd', | ||
'paridecl.pxd', | ||
'paripriv.pxd', | ||
'pycore_long.pxd', | ||
'stack.pxd', | ||
'string_utils.pxd', | ||
'types.pxd', | ||
'cypari.h', | ||
'pycore_long.h', | ||
'auto_paridecl.pxd', | ||
'auto_gen.pxi', | ||
'auto_instance.pxi', | ||
subdir: 'cypari2' | ||
) | ||
|
||
|
||
extension_data = { | ||
'closure': files('closure.pyx'), | ||
'stack': files('stack.pyx'), | ||
'custom_block': files('custom_block.pyx'), | ||
'convert': files('convert.pyx'), | ||
'string_utils': files('string_utils.pyx'), | ||
'handle_error': files('handle_error.pyx'), | ||
'gen': files('gen.pyx'), | ||
'pari_instance': files('pari_instance.pyx') | ||
} | ||
|
||
foreach name, pyx : extension_data | ||
py.extension_module( | ||
name, | ||
sources: pyx, | ||
subdir: 'cypari2', | ||
install: true, | ||
dependencies: [cysignals, pari], | ||
) | ||
endforeach | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# distutils: libraries = gmp pari | ||
""" | ||
Declarations for non-inline functions from PARI. | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# distutils: libraries = gmp pari | ||
""" | ||
Declarations for private functions from PARI | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
project('cypari2', | ||
['c', 'cython'], | ||
version: files('VERSION'), | ||
license: 'GPL v2+', | ||
default_options: ['c_std=c17', 'python.install_env=auto'], | ||
meson_version: '>=1.2', | ||
) | ||
|
||
# Python module | ||
# https://mesonbuild.com/Python-module.html | ||
py = import('python').find_installation(pure: false) | ||
|
||
# Compilers | ||
cc = meson.get_compiler('c') | ||
cython = meson.get_compiler('cython') | ||
# Workaround as described in https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#arithmetic-methods | ||
add_project_arguments('-X c_api_binop_methods=True', language: 'cython') | ||
|
||
# Dependencies | ||
inc_cysignals = run_command( | ||
py, | ||
[ | ||
'-c', | ||
''' | ||
from os.path import relpath | ||
import cysignals | ||
path = cysignals.__file__.replace('__init__.py', '') | ||
try: | ||
print(relpath(path)) | ||
except Exception: | ||
print(path) | ||
'''.strip(), | ||
], | ||
check: true, | ||
).stdout().strip() | ||
cysignals = declare_dependency(include_directories: inc_cysignals) | ||
# Cannot be found via pkg-config | ||
pari = cc.find_library('pari', required: true) | ||
|
||
# Run code generation step | ||
code_gen_result = run_command( | ||
py.full_path(), '-c', | ||
''' | ||
import sys | ||
sys.path.insert(0, ".") | ||
from autogen import rebuild | ||
rebuild(force=True) | ||
print("Code generation successful") | ||
''', | ||
check: true | ||
) | ||
|
||
subdir('cypari2') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools", | ||
"Cython>=3.0", | ||
"cysignals>=1.11.3", | ||
] | ||
# We need access to the autogen package at build time. | ||
# Hence we declare a custom build backend. | ||
build-backend = "_custom_build_meta" # just re-exports setuptools.build_meta definitions | ||
backend-path = ["."] | ||
requires = ["meson-python>=0.18.0", "cython>=3.0", "cysignals>=1.11.3"] | ||
build-backend = "mesonpy" | ||
|
||
[project] | ||
name = "cypari2" | ||
description = "A Python interface to the number theory library PARI/GP" | ||
authors = [ | ||
{name = "Luca De Feo, Vincent Delecroix, Jeroen Demeyer, Vincent Klein"}, | ||
{ name = "Luca De Feo, Vincent Delecroix, Jeroen Demeyer, Vincent Klein" }, | ||
] | ||
maintainers = [ | ||
{name = "SageMath developers", email = "[email protected]"}, | ||
] | ||
dependencies = [ | ||
"cysignals>=1.11.3", | ||
{ name = "SageMath developers", email = "[email protected]" }, | ||
] | ||
dependencies = ["cysignals>=1.11.3"] | ||
requires-python = ">=3.9" | ||
readme = "README.rst" | ||
license = {text = "GNU General Public License, version 2 or later"} | ||
license = "GPL-2.0-or-later" | ||
license-files = ["LICENSE"] | ||
keywords = ["PARI/GP number theory"] | ||
dynamic = [ | ||
"version", | ||
] | ||
dynamic = ["version"] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/sagemath/cypari2" | ||
|
||
[tool.setuptools.dynamic] | ||
version = {file = "VERSION"} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.