Skip to content

Commit

Permalink
update meson files
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez authored Sep 27, 2024
1 parent 3b1c99d commit e3b9006
Show file tree
Hide file tree
Showing 113 changed files with 2,223 additions and 1,497 deletions.
23 changes: 13 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(
'SageMath',
['c', 'cpp', 'cython'],
version: files('src/VERSION.txt'),
license: 'GPL v3'
license: 'GPL v3',
)

# Python module
Expand All @@ -12,18 +12,21 @@ py = py_module.find_installation(pure: false)
py_dep = py.dependency()

# Additional targets
py_with_pytest = py_module.find_installation(required: false, modules: ['pytest'])
py_with_pytest = py_module.find_installation(
required: false,
modules: ['pytest'],
)
if py_with_pytest.found()
test(
'pytest',
py_with_pytest,
'pytest',
py_with_pytest,
args: [
'-m',
'pytest',
'-c',
meson.current_source_dir() / 'tox.ini',
'--doctest',
meson.current_source_dir() / 'src' / 'sage' / 'categories'
'-m',
'pytest',
'-c',
meson.current_source_dir() / 'tox.ini',
'--doctest',
meson.current_source_dir() / 'src' / 'sage' / 'categories',
],
timeout: 0,
)
Expand Down
1 change: 1 addition & 0 deletions meson.format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
indent_by: ' '
127 changes: 68 additions & 59 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,95 @@ cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')

# Setup dependencies that are needed by many modules
inc_numpy = run_command(py,
[
inc_numpy = run_command(
py,
[
'-c',
'''
import numpy
print(numpy.get_include())
'''.strip()
],
check: true
).stdout().strip()
numpy = declare_dependency(
include_directories: inc_numpy,
)
'''.strip(),
],
check: true,
).stdout().strip()
numpy = declare_dependency(include_directories: inc_numpy)

inc_cysignals = run_command(py,
[
inc_cysignals = run_command(
py,
[
'-c',
'''
import cysignals
print(cysignals.__file__.replace('__init__.py', ''))
'''.strip()
],
check: true
).stdout().strip()
cysignals = declare_dependency(
include_directories: inc_cysignals,
)
'''.strip(),
],
check: true,
).stdout().strip()
cysignals = declare_dependency(include_directories: inc_cysignals)

inc_gmpy2 = run_command(py,
[
inc_gmpy2 = run_command(
py,
[
'-c',
'''
import gmpy2
print(gmpy2.__file__.replace('__init__.py', ''))
'''.strip()
],
check: true
).stdout().strip()
gmpy2 = declare_dependency(
include_directories: inc_gmpy2,
)
'''.strip(),
],
check: true,
).stdout().strip()
gmpy2 = declare_dependency(include_directories: inc_gmpy2)
gmp = dependency('gmp', required: true)

inc_cypari2 = run_command(py,
[
inc_cypari2 = run_command(
py,
[
'-c',
'''
import cypari2
print(cypari2.__file__.replace('__init__.py', ''))
'''.strip()
],
check: true
).stdout().strip()
cypari2 = declare_dependency(
include_directories: inc_cypari2,
)
'''.strip(),
],
check: true,
).stdout().strip()
cypari2 = declare_dependency(include_directories: inc_cypari2)
pari = cc.find_library('pari')

mpfr = cc.find_library('mpfr')

# Once https://github.com/mesonbuild/meson/pull/12616 is released, we can simply do the following:
# flint = dependency('flint', version : '>=3.0.0')
flint = dependency('flint', version : '>=3.0.0', required: false, allow_fallback: false)
flint = dependency(
'flint',
version: '>=3.0.0',
required: false,
allow_fallback: false,
)
if not flint.found()
flint = subproject('flint').get_variable('flint_dep')
flint = subproject('flint').get_variable('flint_dep')
else
# Currently the flint pkg-config file is broken, so we manually use find_library
# Can be removed once we require a version of flint that ships https://github.com/flintlib/flint/pull/1647
flint = cc.find_library('flint')
# Currently the flint pkg-config file is broken, so we manually use find_library
# Can be removed once we require a version of flint that ships https://github.com/flintlib/flint/pull/1647
flint = cc.find_library('flint')
endif

blas_order = []
if host_machine.system() == 'darwin'
blas_order += 'accelerate'
blas_order += 'accelerate'
endif
if host_machine.cpu_family() == 'x86_64'
blas_order += 'mkl'
blas_order += 'mkl'
endif
# pkg-config uses a lower-case name while CMake uses a capitalized name, so try
# that too to make the fallback detection with CMake work
blas_order += ['cblas', 'openblas', 'OpenBLAS', 'flexiblas', 'blis', 'blas']
blas = dependency(blas_order)
gsl = dependency('gsl', fallback: ['gsl', 'gsl_dep'], version : '>=2.5', required: true)
gsl = dependency(
'gsl',
fallback: ['gsl', 'gsl_dep'],
version: '>=2.5',
required: true,
)
gd = cc.find_library('gd')
iml = cc.find_library('iml')
m = cc.find_library('m')
Expand All @@ -110,7 +116,7 @@ fplll = dependency('fplll')
givaro = cc.find_library('givaro')
linbox = dependency('linbox', required: false)
if not linbox.found()
linbox = cc.find_library('linbox')
linbox = cc.find_library('linbox')
endif
braiding = cc.find_library('braiding')
gc = cc.find_library('gc')
Expand All @@ -122,7 +128,7 @@ mpc = cc.find_library('mpc')
# Test for common.h header that was added in 4.12 as a indirect version check
gap = cc.find_library('gap', has_headers: ['gap/common.h'], required: false)
if not gap.found()
gap = subproject('gap').get_variable('gap_dep')
gap = subproject('gap').get_variable('gap_dep')
endif

singular = dependency('Singular')
Expand All @@ -135,22 +141,25 @@ ntl = cc.find_library('ntl', required: true)
# Meson currently ignores include_directories for Cython modules, so we
# have to add them manually.
# https://github.com/mesonbuild/meson/issues/9562
add_project_arguments('-I', meson.current_source_dir(), language : 'cython')
add_project_arguments('-I', meson.current_build_dir(), language : 'cython')
add_project_arguments('-I', meson.current_source_dir(), language: 'cython')
add_project_arguments('-I', meson.current_build_dir(), language: 'cython')

# Add global compiler flags
add_project_arguments('-X auto_pickle=False', language : 'cython')
add_project_arguments('-X autotestdict=False', language : 'cython')
add_project_arguments('-X binding=False', language : 'cython')
add_project_arguments('-X c_api_binop_methods=True', language : 'cython')
add_project_arguments('-X cdivision=True', language : 'cython')
add_project_arguments('-X cpow=True', language : 'cython')
add_project_arguments('-X embedsignature=True', language : 'cython')
add_project_arguments('--embed-positions', language : 'cython')
add_project_arguments('-X fast_getattr=True', language : 'cython')
add_project_arguments('-X auto_pickle=False', language: 'cython')
add_project_arguments('-X autotestdict=False', language: 'cython')
add_project_arguments('-X binding=False', language: 'cython')
add_project_arguments('-X c_api_binop_methods=True', language: 'cython')
add_project_arguments('-X cdivision=True', language: 'cython')
add_project_arguments('-X cpow=True', language: 'cython')
add_project_arguments('-X embedsignature=True', language: 'cython')
add_project_arguments('--embed-positions', language: 'cython')
add_project_arguments('-X fast_getattr=True', language: 'cython')
#add_project_arguments('-X language_level="3"', language : 'cython')
add_project_arguments('-X legacy_implicit_noexcept=True', language : 'cython')
add_project_arguments('-X preliminary_late_includes_cy28=True', language : 'cython')
add_project_arguments('-X legacy_implicit_noexcept=True', language: 'cython')
add_project_arguments(
'-X preliminary_late_includes_cy28=True',
language: 'cython',
)

inc_cpython = include_directories('sage/cpython')
inc_rings = include_directories('sage/rings')
Expand Down
21 changes: 12 additions & 9 deletions src/sage/algebras/finite_dimensional_algebras/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ py.install_sources(
'finite_dimensional_algebra_element.pxd',
'finite_dimensional_algebra_ideal.py',
'finite_dimensional_algebra_morphism.py',
subdir : 'sage/algebras/finite_dimensional_algebras'
subdir: 'sage/algebras/finite_dimensional_algebras',
)

extension_data = {
'finite_dimensional_algebra_element' : files('finite_dimensional_algebra_element.pyx')
'finite_dimensional_algebra_element' : files(
'finite_dimensional_algebra_element.pyx',
),
}

foreach name, pyx : extension_data
py.extension_module(name,
sources: pyx,
subdir: 'sage/algebras/finite_dimensional_algebras',
install: true,
include_directories: [inc_cpython],
dependencies: [py_dep, gmp],
)
py.extension_module(
name,
sources: pyx,
subdir: 'sage/algebras/finite_dimensional_algebras',
install: true,
include_directories: [inc_cpython],
dependencies: [py_dep, gmp],
)
endforeach

44 changes: 24 additions & 20 deletions src/sage/algebras/fusion_rings/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,41 @@ py.install_sources(
'fusion_ring.py',
'poly_tup_engine.pxd',
'shm_managers.pxd',
subdir : 'sage/algebras/fusion_rings'
subdir: 'sage/algebras/fusion_rings',
)

extension_data = {
'fast_parallel_fusion_ring_braid_repn' : files('fast_parallel_fusion_ring_braid_repn.pyx')
'fast_parallel_fusion_ring_braid_repn' : files(
'fast_parallel_fusion_ring_braid_repn.pyx',
),
}

foreach name, pyx : extension_data
py.extension_module(name,
sources: pyx,
subdir: 'sage/algebras/fusion_rings',
install: true,
include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings],
dependencies: [py_dep, cysignals, gmp],
)
py.extension_module(
name,
sources: pyx,
subdir: 'sage/algebras/fusion_rings',
install: true,
include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings],
dependencies: [py_dep, cysignals, gmp],
)
endforeach

extension_data_cpp = {
'fast_parallel_fmats_methods': files('fast_parallel_fmats_methods.pyx'),
'poly_tup_engine': files('poly_tup_engine.pyx'),
'shm_managers': files('shm_managers.pyx'),
'fast_parallel_fmats_methods': files('fast_parallel_fmats_methods.pyx'),
'poly_tup_engine': files('poly_tup_engine.pyx'),
'shm_managers': files('shm_managers.pyx'),
}

foreach name, pyx : extension_data_cpp
py.extension_module(name,
sources: pyx,
subdir: 'sage/algebras/fusion_rings',
install: true,
override_options : ['cython_language=cpp'],
include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings],
dependencies: [py_dep, cysignals, gmp, singular],
)
py.extension_module(
name,
sources: pyx,
subdir: 'sage/algebras/fusion_rings',
install: true,
override_options: ['cython_language=cpp'],
include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings],
dependencies: [py_dep, cysignals, gmp, singular],
)
endforeach

32 changes: 20 additions & 12 deletions src/sage/algebras/letterplace/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
py.install_sources('all.py', 'free_algebra_element_letterplace.pxd', 'free_algebra_letterplace.pxd', subdir : 'sage/algebras/letterplace')
py.install_sources(
'all.py',
'free_algebra_element_letterplace.pxd',
'free_algebra_letterplace.pxd',
subdir: 'sage/algebras/letterplace',
)

extension_data_cpp = {
'free_algebra_element_letterplace': files('free_algebra_element_letterplace.pyx'),
'free_algebra_letterplace': files('free_algebra_letterplace.pyx'),
'letterplace_ideal': files('letterplace_ideal.pyx'),
'free_algebra_element_letterplace': files(
'free_algebra_element_letterplace.pyx',
),
'free_algebra_letterplace': files('free_algebra_letterplace.pyx'),
'letterplace_ideal': files('letterplace_ideal.pyx'),
}

foreach name, pyx : extension_data_cpp
py.extension_module(name,
sources: pyx,
subdir: 'sage/algebras/letterplace',
install: true,
override_options : ['cython_language=cpp'],
include_directories: [inc_cpython, inc_rings],
dependencies: [py_dep, gmp, singular],
)
py.extension_module(
name,
sources: pyx,
subdir: 'sage/algebras/letterplace',
install: true,
override_options: ['cython_language=cpp'],
include_directories: [inc_cpython, inc_rings],
dependencies: [py_dep, gmp, singular],
)
endforeach

Loading

0 comments on commit e3b9006

Please sign in to comment.