Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/src/meson.build
4013 views
1
# Compilers
2
cc = meson.get_compiler('c')
3
cpp = meson.get_compiler('cpp')
4
cython = meson.get_compiler('cython')
5
6
# Setup dependencies that are needed by many modules
7
inc_numpy = run_command(
8
py,
9
[
10
'-c',
11
'''
12
from os.path import relpath
13
import numpy
14
path = numpy.get_include()
15
try:
16
print(relpath(path))
17
except Exception:
18
print(path)
19
'''.strip(),
20
],
21
check: true,
22
).stdout().strip()
23
numpy = declare_dependency(include_directories: inc_numpy)
24
25
inc_cysignals = run_command(
26
py,
27
[
28
'-c',
29
'''
30
from os.path import relpath
31
import cysignals
32
path = cysignals.__file__.replace('__init__.py', '')
33
try:
34
print(relpath(path))
35
except Exception:
36
print(path)
37
'''.strip(),
38
],
39
check: true,
40
).stdout().strip()
41
cysignals = declare_dependency(include_directories: inc_cysignals)
42
43
inc_gmpy2 = run_command(
44
py,
45
[
46
'-c',
47
'''
48
from os.path import relpath
49
import gmpy2
50
path = gmpy2.__file__.replace('__init__.py', '')
51
try:
52
print(relpath(path))
53
except Exception:
54
print(path)
55
'''.strip(),
56
],
57
check: true,
58
).stdout().strip()
59
gmpy2 = declare_dependency(include_directories: inc_gmpy2)
60
gmp = dependency('gmp')
61
62
if is_windows
63
# Not yet available on Windows
64
cypari2 = disabler()
65
else
66
inc_cypari2 = run_command(
67
py,
68
[
69
'-c',
70
'''
71
from os.path import relpath
72
import cypari2
73
path = cypari2.__file__.replace('__init__.py', '')
74
try:
75
print(relpath(path))
76
except Exception:
77
print(path)
78
'''.strip(),
79
],
80
check: true,
81
).stdout().strip()
82
cypari2 = declare_dependency(include_directories: inc_cypari2)
83
endif
84
# Cannot be found via pkg-config
85
pari = cc.find_library('pari', required: not is_windows, disabler: true)
86
87
mpfr = dependency('mpfr')
88
89
if is_windows
90
# TODO: Reenable the following once conda's python is fixed
91
# https://github.com/conda-forge/python-feedstock/pull/770
92
# # In its currently released version, flint is not working on Windows; thus always use subproject
93
# #flint = dependency('flint', version: '>=3.1.3')
94
# cmake = import('cmake')
95
# cmake_opts = cmake.subproject_options()
96
# cmake_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'OFF'})
97
# flint_proj = cmake.subproject('flint', options: cmake_opts)
98
# flint = flint_proj.dependency('flint')
99
# meson.override_dependency('flint', flint)
100
flint = disabler()
101
else
102
flint = dependency('flint', version: '>=3.0.0')
103
if flint.version().version_compare('<3.1')
104
# In older versions of flint, pkg-config file is broken, so we manually use find_library
105
# This has been fixed in flint v3.1: https://github.com/flintlib/flint/pull/1647
106
flint = cc.find_library('flint')
107
endif
108
endif
109
110
blas_order = []
111
if host_machine.system() == 'darwin'
112
blas_order += 'accelerate'
113
endif
114
if host_machine.cpu_family() == 'x86_64'
115
blas_order += 'mkl'
116
endif
117
# pkg-config uses a lower-case name while CMake uses a capitalized name, so try
118
# that too to make the fallback detection with CMake work
119
blas_order += ['cblas', 'openblas', 'OpenBLAS', 'flexiblas', 'blis', 'blas']
120
blas = dependency(blas_order)
121
if is_windows
122
# pkg-config file is wrong on Windows (https://github.com/conda-forge/gsl-feedstock/issues/63)
123
gsl = cc.find_library('gsl', required: false, disabler: true)
124
else
125
gsl = dependency('gsl', version: '>=2.5')
126
endif
127
gd = dependency('gdlib', required: false, version: '>=2.1')
128
if not gd.found()
129
# Doesn't have a pkg-config file on some systems (https://github.com/conda-forge/libgd-feedstock/issues/55)
130
gd = cc.find_library('gd', required: not is_windows, disabler: true)
131
endif
132
# Only some platforms have a standalone math library (https://mesonbuild.com/howtox.html#add-math-library-lm-portably)
133
m = cc.find_library('m', required: false)
134
m4ri = dependency('m4ri', version: '>=20250128', required: false)
135
if not m4ri.found()
136
# Older versions of m4ri are declaring "@SIMD_CFLAGS@" as compile_args
137
# which breaks the build. So we exclude these compile args.
138
# https://github.com/malb/m4ri/commit/3197be5f7d3c67e8f13e32516557f35cbf4ff6ce
139
m4ri = dependency('m4ri', version: '>=20140914').partial_dependency(
140
includes: true,
141
link_args: true,
142
links: true,
143
sources: true,
144
)
145
endif
146
m4rie = dependency('m4rie', required: false)
147
if not m4rie.found()
148
# For some reason, m4rie is not found via pkg-config on some systems (eg Conda)
149
m4rie = cc.find_library('m4rie', required: not is_windows, disabler: true)
150
endif
151
mtx = dependency('mtx', required: false)
152
if not mtx.found()
153
# fallback for older versions without pkg-config
154
mtx = cc.find_library(
155
'mtx',
156
required: get_option('meataxe'),
157
disabler: true,
158
has_headers: ['meataxe.h'],
159
)
160
endif
161
png = dependency(['libpng', 'png', 'png16'], version: '>=1.2')
162
zlib = dependency('zlib', version: '>=1.2.11')
163
# We actually want >= 20231212, but the version number is not updated in the pkgconfig
164
# https://github.com/conda-forge/eclib-feedstock/issues/48
165
ec = dependency(
166
'eclib',
167
version: '>=20250122',
168
required: get_option('eclib'),
169
disabler: true,
170
)
171
ecm = cc.find_library('ecm', required: not is_windows, disabler: true)
172
gmpxx = dependency('gmpxx', required: not is_windows, disabler: true)
173
fflas = dependency(
174
'fflas-ffpack',
175
required: not is_windows,
176
disabler: true,
177
version: '>=2.5.0',
178
)
179
givaro = dependency(
180
'givaro',
181
required: not is_windows,
182
disabler: true,
183
version: '>=4.2.0',
184
)
185
linbox = dependency('linbox', required: false, version: '>=1.7.0')
186
if not linbox.found()
187
linbox = cc.find_library('linbox', required: not is_windows, disabler: true)
188
endif
189
mpc = cc.find_library('mpc', required: not is_windows, disabler: true)
190
mpfi = cc.find_library('mpfi', required: false)
191
if not mpfi.found()
192
mpfi_proj = subproject('mpfi')
193
mpfi = mpfi_proj.get_variable('mpfi_dep')
194
endif
195
196
gap = dependency('libgap', version: '>=4.13.0', required: false)
197
if not gap.found()
198
# Fallback in case pkg-config info is not available
199
# Test for common.h header that was added in 4.12 as a indirect version check
200
gap = cc.find_library(
201
'gap',
202
has_headers: ['gap/common.h'],
203
required: not is_windows,
204
disabler: true,
205
)
206
endif
207
singular = dependency('Singular', required: not is_windows, disabler: true)
208
singular_factory = disabler()
209
if singular.found()
210
singular_factory = singular
211
else
212
singular_proj = subproject('singular')
213
singular_factory = singular_proj.get_variable('factory_dep')
214
endif
215
# Cannot be found via pkg-config
216
ntl = cc.find_library('ntl', required: not is_windows, disabler: true)
217
218
# Meson currently ignores include_directories for Cython modules, so we
219
# have to add them manually.
220
# https://github.com/mesonbuild/meson/issues/9562
221
add_project_arguments('-I', meson.current_source_dir(), language: 'cython')
222
add_project_arguments('-I', meson.current_build_dir(), language: 'cython')
223
224
# Add global compiler flags
225
add_project_arguments('-X auto_pickle=False', language: 'cython')
226
add_project_arguments('-X autotestdict=False', language: 'cython')
227
add_project_arguments('-X binding=True', language: 'cython')
228
add_project_arguments('-X c_api_binop_methods=True', language: 'cython')
229
add_project_arguments('-X cdivision=True', language: 'cython')
230
add_project_arguments('-X cpow=True', language: 'cython')
231
add_project_arguments('-X embedsignature=True', language: 'cython')
232
add_project_arguments('--embed-positions', language: 'cython')
233
add_project_arguments('-X fast_getattr=True', language: 'cython')
234
#add_project_arguments('-X language_level="3"', language : 'cython')
235
add_project_arguments('-X legacy_implicit_noexcept=True', language: 'cython')
236
add_project_arguments(
237
'-X preliminary_late_includes_cy28=True',
238
language: 'cython',
239
)
240
241
inc_cpython = include_directories('sage/cpython')
242
inc_rings = include_directories('sage/rings')
243
inc_rings_finite = include_directories('sage/rings/finite_rings')
244
inc_flint = include_directories('sage/libs/flint')
245
inc_gsl = include_directories('sage/libs/gsl')
246
inc_ntl = include_directories('sage/libs/ntl')
247
inc_arb = include_directories('sage/libs/arb')
248
inc_data_structures = include_directories('sage/data_structures')
249
inc_ext = include_directories('sage/ext')
250
inc_partn_ref2 = include_directories('sage/groups/perm_gps/partn_ref2')
251
inc_src = include_directories('.')
252
253
src = meson.current_source_dir()
254
255
# Submodules
256
subdir('sage')
257
subdir('doc')
258
259