scikit-image

Форк
0
/
meson.build 
170 строк · 5.2 Кб
1
# Platform detection
2
is_windows = host_machine.system() == 'windows'
3
is_mingw = is_windows and cc.get_id() == 'gcc'
4

5
cython_c_args = []
6
if is_windows
7
  # For mingw-w64, link statically against the UCRT.
8
  gcc_link_args = ['-lucrt', '-static']
9
  if is_mingw
10
    add_project_link_arguments(gcc_link_args, language: ['c', 'cpp'])
11
    # Force gcc to float64 long doubles for compatibility with MSVC
12
    # builds, for C only.
13
    add_project_arguments('-mlong-double-64', language: 'c')
14
    # Make fprintf("%zd") work (see https://github.com/rgommers/scipy/issues/118)
15
    add_project_arguments('-D__USE_MINGW_ANSI_STDIO=1', language: ['c', 'cpp'])
16
    # Manual add of MS_WIN64 macro when not using MSVC.
17
    # https://bugs.python.org/issue28267
18
    bitness = run_command(
19
      '_build_utils/gcc_build_bitness.py',
20
      check: true
21
    ).stdout().strip()
22
    if bitness == '64'
23
      add_project_arguments('-DMS_WIN64', language: ['c', 'cpp'])
24
    endif
25
    # Silence warnings emitted by PyOS_snprintf for (%zd), see
26
    # https://github.com/rgommers/scipy/issues/118.
27
    # Use as c_args for extensions containing Cython code
28
    cython_c_args += ['-Wno-format-extra-args', '-Wno-format']
29
  endif
30
endif
31

32
# When cross-compiling skimage, the compiler needs access to NumPy and Pythran
33
# headers for the host platform (where the package will actually run). These
34
# headers may be incompatible with any corresponding headers that might be
35
# installed on the build system (where the compilation is performed). To make
36
# sure that the compiler finds the right headers, paths can be configured in
37
# the 'properties' section of a Meson cross file:
38
#
39
#   [properties]
40
#   numpy-include-dir = '/path/to/host/numpy/includes'
41
#   pythran-include-dir = '/path/to/host/pythran/includes'
42
#
43
# If a cross file is not provided or does not specify either of these
44
# properties, fall back to running Python on the build system to query NumPy or
45
# Pythran directly for the appropriate paths. This will detect appropriate
46
# paths for native builds. (This might even work for certain build/host cross
47
# combinations, but don't rely on that.)
48
#
49
# For more information about cross compilation in Meson, including a definition
50
# of "build" and "host" in this context, refer to
51
#
52
#     https://mesonbuild.com/Cross-compilation.html
53

54
# NumPy include directory
55
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
56
if incdir_numpy == 'not-given'
57
  # If not specified, try to query NumPy from the build python
58
  incdir_numpy = run_command(py3,
59
    [
60
      '-c',
61
      'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
62
    ],
63
    check: true
64
  ).stdout().strip()
65
endif
66

67
inc_np = include_directories(incdir_numpy)
68

69
cc = meson.get_compiler('c')
70

71
# Pythran include directory
72
incdir_pythran = meson.get_external_property('pythran-include-dir', 'not-given')
73
if incdir_pythran == 'not-given'
74
  # If not specified, try to query Pythran from the build python
75
  incdir_pythran = run_command(py3,
76
    [
77
      '-c',
78
      'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
79
    ],
80
    check: true
81
  ).stdout().strip()
82
endif
83

84
inc_pythran = include_directories(incdir_pythran)
85

86
# Pythran build flags
87
cpp_args_pythran = [
88
  '-DENABLE_PYTHON_MODULE',
89
  '-D__PYTHRAN__=3',
90
  '-DPYTHRAN_BLAS_NONE'
91
]
92

93
# Deal with M_PI & friends; add `use_math_defines` to c_args
94
# Cython doesn't always get this correctly itself
95
# explicitly add the define as a compiler flag for Cython-generated code.
96
if is_windows
97
  use_math_defines = ['-D_USE_MATH_DEFINES']
98
else
99
  use_math_defines = []
100
endif
101

102
# Don't use the deprecated NumPy C API. Define this to a fixed version instead of
103
# NPY_API_VERSION in order not to break compilation for released SciPy versions
104
# when NumPy introduces a new deprecation. Use in a meson.build file::
105
#
106
#   py3.extension_module('_name',
107
#     'source_fname',
108
#     numpy_nodepr_api)
109
#
110
numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'
111

112
python_sources = [
113
  '__init__.py',
114
  '__init__.pyi',
115
  'conftest.py',
116
  'py.typed'
117
]
118

119
py3.install_sources(
120
  python_sources,
121
  pure: false,
122
  subdir: 'skimage'
123
)
124

125
cython_cli = find_program('_build_utils/cythoner.py')
126
cy = meson.get_compiler('cython')
127

128
cython_args = ['@INPUT@', '@OUTPUT@']
129
if cy.version().version_compare('>=3.1.0')
130
  cython_args += ['-Xfreethreading_compatible=True']
131
endif
132

133
cython_cpp_args = cython_args + ['--cplus']
134

135
cython_gen = generator(cython_cli,
136
  arguments : cython_args,
137
  output : '@BASENAME@.c')
138

139
cython_gen_cpp = generator(cython_cli,
140
  arguments : ['@INPUT@', '@OUTPUT@', '--cplus'],
141
  output : '@BASENAME@.cpp')
142

143
c_undefined_ok = ['-Wno-maybe-uninitialized']
144

145
# Suppress warning for deprecated Numpy API.
146
# (Suppress warning messages emitted by #warning directives).
147
# Replace with numpy_nodepr_api after Cython 3.0 is out
148
_cpp_Wno_cpp = cpp.get_supported_arguments('-Wno-cpp')
149
cython_c_args += [_cpp_Wno_cpp, use_math_defines]
150
cython_cpp_args = cython_c_args
151

152
subdir('_shared')
153
subdir('_vendored')
154
subdir('color')
155
subdir('data')
156
subdir('draw')
157
subdir('exposure')
158
subdir('feature')
159
subdir('filters')
160
subdir('future')
161
subdir('graph')
162
subdir('io')
163
subdir('measure')
164
subdir('metrics')
165
subdir('morphology')
166
subdir('registration')
167
subdir('restoration')
168
subdir('segmentation')
169
subdir('transform')
170
subdir('util')
171

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

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

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

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