Skip to content

Commit df93b11

Browse files
charrismattip
andauthored
MAINT: Update meson build infrastructure. (numpy#25049)
Backports of numpy#24969, numpy#24979, numpy#24968, numpy#25068. * apply 24969.diff * apply 24979.diff * apply 24968.diff * TST: skip flaky test in test_histogram --------- Co-authored-by: mattip <matti.picus@gmail.com>
1 parent 7387600 commit df93b11

File tree

5 files changed

+35
-41
lines changed

5 files changed

+35
-41
lines changed

numpy/core/include/numpy/npy_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
#define npy_ftell ftell
169169
#endif
170170
#include <sys/types.h>
171+
#ifndef _WIN32
172+
#include <unistd.h>
173+
#endif
171174
#define npy_lseek lseek
172175
#define npy_off_t off_t
173176

numpy/core/meson.build

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -257,37 +257,6 @@ foreach filefunc_maybe: optional_file_funcs
257257
endif
258258
endforeach
259259

260-
# Optional locale function
261-
have_strtold_l = cc.has_function('strtold_l', include_directories: inc_curdir,
262-
prefix:'''
263-
#include <stdlib.h>
264-
#include <xlocale.h>
265-
#include "feature_detection_locale.h"
266-
''')
267-
if not have_strtold_l
268-
# Retry with locale.h, seems to vary across Linux distros
269-
have_strtold_l = cc.has_function('strtold_l', include_directories: inc_curdir,
270-
prefix:'''
271-
#include <stdlib.h>
272-
#include <locale.h>
273-
#include "feature_detection_locale.h"
274-
''')
275-
endif
276-
if have_strtold_l
277-
cdata.set10('HAVE_STRTOLD_L', true)
278-
else
279-
# FIXME: this is wrong! the HAVE_ define should not exist, or it'll be
280-
# interpreted as the function being available (true/false does nothing, see
281-
# note on HAVE_ defines higher up). This is necessary though in order to make
282-
# the Linux CI job pass. So either the check is wrong somehow, or this
283-
# function is not available in CI. For the latter there is a fallback path,
284-
# but that is broken because we don't have the exact long double
285-
# representation checks.
286-
if cc.get_argument_syntax() != 'msvc'
287-
cdata.set10('HAVE_STRTOLD_L', false)
288-
endif
289-
endif
290-
291260
# Other optional functions
292261
optional_misc_funcs = [
293262
'backtrace',
@@ -305,7 +274,7 @@ endforeach
305274
# SSE headers only enabled automatically on amd64/x32 builds
306275
optional_headers = [
307276
'features.h', # for glibc version linux
308-
'xlocale.h', # see GH#8367
277+
'xlocale.h', # removed in glibc 2.26, but may still be useful - see gh-8367
309278
'dlfcn.h', # dladdr
310279
'execinfo.h', # backtrace
311280
'libunwind.h', # backtrace for LLVM/Clang using libunwind
@@ -317,6 +286,19 @@ foreach header: optional_headers
317286
endif
318287
endforeach
319288

289+
# Optional locale function - GNU-specific
290+
_strtold_prefix = '''
291+
#define _GNU_SOURCE
292+
#include <locale.h>
293+
#include <stdlib.h>
294+
'''
295+
if cdata.get('HAVE_XLOCALE_H', 0) == 1
296+
_strtold_prefix += '#include <xlocale.h>'
297+
endif
298+
if cc.has_function('strtold_l', include_directories: inc_curdir, prefix: _strtold_prefix)
299+
cdata.set10('HAVE_STRTOLD_L', true)
300+
endif
301+
320302
# Optional compiler attributes
321303
# TODO: this doesn't work with cc.has_function_attribute, see
322304
# https://github.com/mesonbuild/meson/issues/10732

numpy/core/src/common/numpyos.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
#include "npy_pycompat.h"
1313

14+
#if defined(HAVE_STRTOLD_L) && !defined(_GNU_SOURCE)
15+
# define _GNU_SOURCE
16+
#endif
1417
#include <locale.h>
1518
#include <stdio.h>
1619

numpy/lib/tests/test_histograms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,9 @@ def test_histogram_bin_edges(self):
398398
edges = histogram_bin_edges(arr, bins='auto', range=(0, 1))
399399
assert_array_equal(edges, e)
400400

401-
@requires_memory(free_bytes=1e10)
402-
@pytest.mark.slow
401+
# @requires_memory(free_bytes=1e10)
402+
# @pytest.mark.slow
403+
@pytest.mark.skip(reason="Bad memory reports lead to OOM in ci testing")
403404
def test_big_arrays(self):
404405
sample = np.zeros([100000000, 3])
405406
xbins = 400

numpy/meson.build

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ endif
1010

1111
# Platform detection
1212
is_windows = host_machine.system() == 'windows'
13-
is_mingw = is_windows and cc.get_id() == 'gcc'
13+
is_mingw = is_windows and cc.get_define('__MINGW32__') != ''
1414

1515
if is_mingw
16-
# For mingw-w64, link statically against the UCRT.
17-
gcc_link_args = ['-lucrt', '-static']
18-
add_project_link_arguments(gcc_link_args, language: ['c', 'cpp'])
19-
# Force gcc to float64 long doubles for compatibility with MSVC
20-
# builds, for C only.
21-
add_project_arguments('-mlong-double-64', language: 'c')
16+
is_mingw_built_python = run_command(
17+
py, ['-c', 'import sysconfig; print(sysconfig.get_platform())'],
18+
check: true).stdout().strip().startswith('mingw')
19+
if not is_mingw_built_python
20+
# For mingw-w64, link statically against the UCRT.
21+
gcc_link_args = ['-lucrt', '-static']
22+
add_project_link_arguments(gcc_link_args, language: ['c', 'cpp'])
23+
# Force gcc to float64 long doubles for compatibility with MSVC
24+
# builds, for C only.
25+
add_project_arguments('-mlong-double-64', language: 'c')
26+
endif
2227
# Make fprintf("%zd") work (see https://github.com/rgommers/scipy/issues/118)
2328
add_project_arguments('-D__USE_MINGW_ANSI_STDIO=1', language: ['c', 'cpp'])
2429
endif

0 commit comments

Comments
 (0)