scipy

Форк
0
/
meson.build 
154 строки · 5.9 Кб
1
project(
2
  'scipy',
3
  'c', 'cpp', 'cython',
4
  version: run_command(['tools/gitversion.py'], check: true).stdout().strip(),
5
  license: 'BSD-3',
6
  meson_version: '>= 1.5.0',
7
  default_options: [
8
    'buildtype=debugoptimized',
9
    'b_ndebug=if-release',
10
    'c_std=c17',
11
    'cpp_std=c++17',
12
    'fortran_std=legacy',
13
    'blas=openblas',
14
    'lapack=openblas'
15
  ],
16
)
17

18
py3 = import('python').find_installation(pure: false)
19
py3_dep = py3.dependency()
20

21
min_numpy_version = '1.23.5'  # keep in sync with pyproject.toml
22

23
# Emit a warning for 32-bit Python installs on Windows; users are getting
24
# unexpected from-source builds there because we no longer provide wheels.
25
is_windows = host_machine.system() == 'windows'
26
if is_windows and py3.has_variable('EXT_SUFFIX')
27
  ext_suffix = py3.get_variable('EXT_SUFFIX')
28
  if ext_suffix.contains('win32')
29
    warning('You are building from source on a 32-bit Python install. SciPy does not provide 32-bit wheels; install 64-bit Python if you are having issues!')
30
  endif
31
endif
32

33
cc = meson.get_compiler('c')
34
cpp = meson.get_compiler('cpp')
35
cy = meson.get_compiler('cython')
36
# generator() doesn't accept compilers, only found programs - cast it.
37
cython = find_program(cy.cmd_array()[0])
38

39
# Check compiler is recent enough (see "Toolchain Roadmap" for details)
40
if cc.get_id() == 'gcc'
41
  if not cc.version().version_compare('>=9.1')
42
    error('SciPy requires GCC >= 9.1')
43
  endif
44
elif cc.get_id() == 'clang' or cc.get_id() == 'clang-cl'
45
  if not cc.version().version_compare('>=12.0')
46
    error('SciPy requires clang >= 12.0')
47
  endif
48
elif cc.get_id() == 'msvc'
49
  if not cc.version().version_compare('>=19.20')
50
    error('SciPy requires at least vc142 (default with Visual Studio 2019) ' + \
51
          'when building with MSVC')
52
  endif
53
endif
54
if not cy.version().version_compare('>=3.0.8')
55
  error('SciPy requires Cython >= 3.0.8')
56
endif
57

58
_global_c_args = cc.get_supported_arguments(
59
  '-Wno-unused-but-set-variable',
60
  '-Wno-unused-function',
61
  '-Wno-conversion',
62
  '-Wno-misleading-indentation',
63
)
64
add_project_arguments(_global_c_args, language : 'c')
65

66
# We need -lm for all C code (assuming it uses math functions, which is safe to
67
# assume for SciPy). For C++ it isn't needed, because libstdc++/libc++ is
68
# guaranteed to depend on it. For Fortran code, Meson already adds `-lm`.
69
m_dep = cc.find_library('m', required : false)
70
if m_dep.found()
71
  add_project_link_arguments('-lm', language : 'c')
72
endif
73

74
if host_machine.system() == 'os400'
75
  # IBM i system, needed to avoid build errors - see gh-17193
76
  add_project_arguments('-D__STDC_FORMAT_MACROS', language : 'cpp')
77
  add_project_link_arguments('-Wl,-bnotextro', language : ['c', 'cpp', 'fortran'])
78
endif
79

80
# Adding at project level causes many spurious -lgfortran flags.
81
add_languages('fortran', native: false)
82
ff = meson.get_compiler('fortran')
83
if ff.has_argument('-Wno-conversion')
84
  add_project_arguments('-Wno-conversion', language: 'fortran')
85
endif
86

87
if host_machine.system() == 'darwin'
88
  if cc.has_link_argument('-Wl,-ld_classic')
89
    # New linker introduced in macOS 14 not working yet, see gh-19357 and gh-19387
90
    add_project_link_arguments('-Wl,-ld_classic', language : ['c', 'cpp', 'fortran'])
91
  endif
92
  if cc.has_link_argument('-Wl,-dead_strip')
93
    # Allow linker to strip unused symbols
94
    add_project_link_arguments('-Wl,-dead_strip', language : ['c', 'cpp', 'fortran'])
95
  endif
96
endif
97

98
# Intel compilers default to fast-math, so disable it if we detect Intel
99
# compilers. A word of warning: this may not work with the conda-forge
100
# compilers, because those have the annoying habit of including lots of flags
101
# that are gcc-specific in CFLAGS/CXXFLAGS/FFLAGS, which throws off the
102
# detection logic below. You have to remove the wrong flags (only `-isystem`
103
# is actually needed, everything else shouldn't be there).
104
_intel_cflags = []
105
_intel_fflags = []
106
if cc.get_id() in ['intel', 'intel-llvm']
107
  _intel_cflags += cc.get_supported_arguments('-fp-model=strict')
108
elif cc.get_id() in ['intel-cl', 'intel-llvm-cl']
109
  _intel_cflags += cc.get_supported_arguments('/fp:strict')
110
endif
111
if ff.get_id() in ['intel', 'intel-llvm']
112
  _intel_fflags = ff.get_supported_arguments('-fp-model=strict')
113
  minus0_arg = ['-assume', 'minus0']
114
  if ff.has_multi_arguments(minus0_arg)
115
    _intel_fflags += minus0_arg
116
  endif
117
elif ff.get_id() in ['intel-cl', 'intel-llvm-cl']
118
  # Intel Fortran on Windows does things differently, so deal with that
119
  # (also specify dynamic linking and the right name mangling)
120
  _intel_fflags = ff.get_supported_arguments(
121
    '/fp:strict', '/MD', '/names:lowercase', '/assume:underscore',
122
    '/assume:minus0'
123
  )
124
endif
125
add_project_arguments(_intel_cflags, language: ['c', 'cpp'])
126
add_project_arguments(_intel_fflags, language: 'fortran')
127

128
# Hide symbols when building on Linux with GCC. For Python extension modules,
129
# we only need `PyInit_*` to be public, anything else may cause problems. So we
130
# use a linker script to avoid exporting those symbols (this is in addition to
131
# Meson using `-fvisibility=hidden` for C and `-fvisibility-inlines-hidden` for
132
# C++ code. See gh-15996 for details.
133
_linker_script = meson.project_source_root() / 'scipy/_build_utils/link-version-pyinit.map'
134
version_link_args = ['-Wl,--version-script=' + _linker_script]
135
# Note that FreeBSD only accepts version scripts when -shared is passed,
136
# hence we need to pass that to `cc.links` explicitly (flag is already
137
# present for `extension_module` invocations).
138
if not cc.links('', name: '-Wl,--version-script', args: ['-shared', version_link_args])
139
  version_link_args = []
140
endif
141

142
generate_f2pymod = find_program('tools/generate_f2pymod.py')
143
tempita = find_program('scipy/_build_utils/tempita.py')
144

145
use_pythran = get_option('use-pythran')
146
if use_pythran
147
  pythran = find_program('pythran', native: true, version: '>=0.14.0')
148
  # xsimd is unvendored from pythran by conda-forge, and due to a compiler
149
  # activation bug the default <prefix>/include/ may not be visible (see
150
  # gh-15698). Hence look for xsimd explicitly.
151
  xsimd_dep = dependency('xsimd', required: false)
152
endif
153

154
subdir('scipy')
155

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.