diff --git a/.circleci/config.yml b/.circleci/config.yml index ea93575ac9430..67bb6fd5367e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: - run: | /opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev . ~/virtualenvs/pandas-dev/bin/activate - python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1 + python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.15.0 meson[ninja]==1.4.0 python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1 python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror" python -m pip list --no-cache-dir diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f93950224eaae..1d74c1d0f5852 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -226,7 +226,7 @@ jobs: run: | /opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev . ~/virtualenvs/pandas-dev/bin/activate - python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1 + python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.4.0 meson-python==0.15.0 python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true" python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1 python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror" @@ -265,7 +265,7 @@ jobs: run: | /opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev . ~/virtualenvs/pandas-dev/bin/activate - python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1 + python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.15.0 meson[ninja]==1.4.0 python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1 python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror" python -m pip list --no-cache-dir @@ -337,7 +337,7 @@ jobs: - name: Build Environment run: | python --version - python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1 + python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.4.0 meson-python==0.15.0 python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy python -m pip install versioneer[toml] python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml index 85ee5230b31be..719b92392f3ac 100644 --- a/ci/deps/actions-310.yaml +++ b/ci/deps/actions-310.yaml @@ -7,8 +7,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-311-downstream_compat.yaml b/ci/deps/actions-311-downstream_compat.yaml index efd790d77afbb..4ca927bd97ecb 100644 --- a/ci/deps/actions-311-downstream_compat.yaml +++ b/ci/deps/actions-311-downstream_compat.yaml @@ -8,8 +8,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-311-numpydev.yaml b/ci/deps/actions-311-numpydev.yaml index b62e8630f2059..b219ec0158127 100644 --- a/ci/deps/actions-311-numpydev.yaml +++ b/ci/deps/actions-311-numpydev.yaml @@ -6,8 +6,8 @@ dependencies: # build dependencies - versioneer[toml] - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 - cython>=0.29.33 # test dependencies diff --git a/ci/deps/actions-311-pyarrownightly.yaml b/ci/deps/actions-311-pyarrownightly.yaml index d84063ac2a9ba..b0fae6f0f7f93 100644 --- a/ci/deps/actions-311-pyarrownightly.yaml +++ b/ci/deps/actions-311-pyarrownightly.yaml @@ -6,9 +6,9 @@ dependencies: # build dependencies - versioneer[toml] - - meson[ninja]=1.2.1 + - meson[ninja]=1.4.0 - cython>=0.29.33 - - meson-python=0.13.1 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-311.yaml b/ci/deps/actions-311.yaml index 535c260582eec..2c9031175fd42 100644 --- a/ci/deps/actions-311.yaml +++ b/ci/deps/actions-311.yaml @@ -7,8 +7,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-312.yaml b/ci/deps/actions-312.yaml index 8b3f19f55e4b6..9bde872b567f0 100644 --- a/ci/deps/actions-312.yaml +++ b/ci/deps/actions-312.yaml @@ -7,8 +7,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-39-minimum_versions.yaml b/ci/deps/actions-39-minimum_versions.yaml index 94cb21d1621b6..3213da20cf46f 100644 --- a/ci/deps/actions-39-minimum_versions.yaml +++ b/ci/deps/actions-39-minimum_versions.yaml @@ -9,8 +9,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-39.yaml b/ci/deps/actions-39.yaml index 4cc9b1fbe2491..5c6984816e6f5 100644 --- a/ci/deps/actions-39.yaml +++ b/ci/deps/actions-39.yaml @@ -7,8 +7,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/actions-pypy-39.yaml b/ci/deps/actions-pypy-39.yaml index d9c8dd81b7c33..cab5a9148da75 100644 --- a/ci/deps/actions-pypy-39.yaml +++ b/ci/deps/actions-pypy-39.yaml @@ -10,8 +10,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/ci/deps/circle-310-arm64.yaml b/ci/deps/circle-310-arm64.yaml index 869aae8596681..3aa6d541bc83b 100644 --- a/ci/deps/circle-310-arm64.yaml +++ b/ci/deps/circle-310-arm64.yaml @@ -7,8 +7,8 @@ dependencies: # build dependencies - versioneer[toml] - cython>=0.29.33 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/environment.yml b/environment.yml index e7bf2556d27f8..641031e4c6d90 100644 --- a/environment.yml +++ b/environment.yml @@ -9,8 +9,8 @@ dependencies: # build dependencies - versioneer[toml] - cython~=3.0.5 - - meson[ninja]=1.2.1 - - meson-python=0.13.1 + - meson[ninja]=1.4.0 + - meson-python=0.15.0 # test dependencies - pytest>=7.3.2 diff --git a/meson.build b/meson.build index 06623a305ab54..d4916f8c92182 100644 --- a/meson.build +++ b/meson.build @@ -4,11 +4,10 @@ project( 'c', 'cpp', 'cython', version: run_command(['generate_version.py', '--print'], check: true).stdout().strip(), license: 'BSD-3', - meson_version: '>=1.2.1', + meson_version: '>=1.4.0', default_options: [ 'buildtype=release', 'c_std=c11', - 'warning_level=2', ] ) @@ -17,7 +16,6 @@ py = import('python').find_installation(pure: false) tempita = files('generate_pxi.py') versioneer = files('generate_version.py') - add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'c') add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'cpp') @@ -27,6 +25,22 @@ add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'cpp') add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'c') add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'cpp') +if meson.get_compiler('c').get_id() == 'msvc' + # MSVC throws a lot of C4244 warnings around loss of data with warning_level=2 + # On other compilers we would have to add -Wconversion to see these + # these expose a lot of potential issues in our code base + add_project_arguments(['/w'], language: 'c') + add_project_arguments(['/w'], language: 'cpp') +else + args = ['-Wall', '-Wextra'] + if build_machine.system() == 'darwin' + # error: pragma diagnostic pop could not pop, no matching push + args += ['-Wno-unknown-pragmas'] + endif + add_project_arguments(args, language: 'c') + add_project_arguments(args, language: 'cpp') +endif + if fs.exists('_version_meson.py') py.install_sources('_version_meson.py', subdir: 'pandas') diff --git a/pandas/_libs/byteswap.pyx b/pandas/_libs/byteswap.pyx index 67cd7ad58d229..f6ef7ae9e2ef4 100644 --- a/pandas/_libs/byteswap.pyx +++ b/pandas/_libs/byteswap.pyx @@ -15,7 +15,7 @@ from libc.string cimport memcpy def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): cdef uint32_t value - assert offset + sizeof(value) < len(data) + assert offset + sizeof(value) < len(data) cdef const void *ptr = (data) + offset memcpy(&value, ptr, sizeof(value)) if byteswap: @@ -28,7 +28,7 @@ def read_float_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): cdef uint64_t value - assert offset + sizeof(value) < len(data) + assert offset + sizeof(value) < len(data) cdef const void *ptr = (data) + offset memcpy(&value, ptr, sizeof(value)) if byteswap: @@ -41,7 +41,7 @@ def read_double_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): cdef uint16_t res - assert offset + sizeof(res) < len(data) + assert offset + sizeof(res) < len(data) memcpy(&res, (data) + offset, sizeof(res)) if byteswap: res = _byteswap2(res) @@ -50,7 +50,7 @@ def read_uint16_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): cdef uint32_t res - assert offset + sizeof(res) < len(data) + assert offset + sizeof(res) < len(data) memcpy(&res, (data) + offset, sizeof(res)) if byteswap: res = _byteswap4(res) @@ -59,7 +59,7 @@ def read_uint32_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): def read_uint64_with_byteswap(bytes data, Py_ssize_t offset, bint byteswap): cdef uint64_t res - assert offset + sizeof(res) < len(data) + assert offset + sizeof(res) < len(data) memcpy(&res, (data) + offset, sizeof(res)) if byteswap: res = _byteswap8(res) diff --git a/pandas/_libs/hashtable_func_helper.pxi.in b/pandas/_libs/hashtable_func_helper.pxi.in index ca1b28b9442ca..3bba114bfe360 100644 --- a/pandas/_libs/hashtable_func_helper.pxi.in +++ b/pandas/_libs/hashtable_func_helper.pxi.in @@ -43,7 +43,13 @@ cdef value_count_{{dtype}}(const {{dtype}}_t[:] values, bint dropna, const uint8 # Don't use Py_ssize_t, since table.n_buckets is unsigned khiter_t k - {{c_type}} val + # without explicit initialization the compiler detects that val could + # be uninitialized towards the end of this function + {{if dtype == 'object'}} + {{c_type}} val = None + {{else}} + {{c_type}} val = {{to_c_type}}(0) + {{endif}} int ret = 0 bint uses_mask = mask is not None @@ -105,7 +111,7 @@ cdef value_count_{{dtype}}(const {{dtype}}_t[:] values, bint dropna, const uint8 cdef: int64_t[::1] result_counts = np.empty(table.size + na_add, dtype=np.int64) - for i in range(table.size): + for i in range(table.size): # cast required for 32 bit builds {{if dtype == 'object'}} k = kh_get_{{ttype}}(table, result_keys.data[i]) {{else}} @@ -114,6 +120,8 @@ cdef value_count_{{dtype}}(const {{dtype}}_t[:] values, bint dropna, const uint8 result_counts[i] = table.vals[k] if na_counter > 0: + if n <= 0: # in this case val would be uninitialized + raise ValueError("Expected n > 0") result_counts[table.size] = na_counter result_keys.append(val) diff --git a/pandas/_libs/include/pandas/vendored/klib/khash_python.h b/pandas/_libs/include/pandas/vendored/klib/khash_python.h index 811fdd139de2c..a567c029e07f1 100644 --- a/pandas/_libs/include/pandas/vendored/klib/khash_python.h +++ b/pandas/_libs/include/pandas/vendored/klib/khash_python.h @@ -33,11 +33,9 @@ static void *traced_calloc(size_t num, size_t size) { } static void *traced_realloc(void *old_ptr, size_t size) { + PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr); void *ptr = realloc(old_ptr, size); if (ptr != NULL) { - if (old_ptr != ptr) { - PyTraceMalloc_Untrack(KHASH_TRACE_DOMAIN, (uintptr_t)old_ptr); - } PyTraceMalloc_Track(KHASH_TRACE_DOMAIN, (uintptr_t)ptr, size); } return ptr; diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 00668576d5d53..ee6c1854526ba 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -137,7 +137,7 @@ except ImportError: @cython.wraparound(False) @cython.boundscheck(False) -def memory_usage_of_objects(arr: object[:]) -> int64_t: +def memory_usage_of_objects(arr: ndarray[object]) -> int64_t: """ Return the memory usage of an object array in bytes. @@ -3058,7 +3058,9 @@ def to_object_array_tuples(rows: object) -> np.ndarray: @cython.wraparound(False) @cython.boundscheck(False) -def fast_multiget(dict mapping, object[:] keys, default=np.nan) -> "ArrayLike": +def fast_multiget(dict mapping, + ndarray[object, ndim=1] keys, + default=np.nan) -> "ArrayLike": cdef: Py_ssize_t i, n = len(keys) object val diff --git a/pandas/_libs/meson.build b/pandas/_libs/meson.build index c27386743c6e9..1749dac0c4484 100644 --- a/pandas/_libs/meson.build +++ b/pandas/_libs/meson.build @@ -61,18 +61,18 @@ subdir('tslibs') libs_sources = { # Dict of extension name -> dict of {sources, include_dirs, and deps} # numpy include dir is implicitly included - 'algos': {'sources': ['algos.pyx', _algos_common_helper, _algos_take_helper], 'deps': _khash_primitive_helper_dep}, + 'algos': {'sources': ['algos.pyx', _algos_common_helper, _algos_take_helper], 'deps': [_khash_primitive_helper_dep]}, 'arrays': {'sources': ['arrays.pyx']}, 'groupby': {'sources': ['groupby.pyx']}, 'hashing': {'sources': ['hashing.pyx']}, - 'hashtable': {'sources': ['hashtable.pyx', _hashtable_class_helper, _hashtable_func_helper], 'deps': _khash_primitive_helper_dep}, - 'index': {'sources': ['index.pyx', _index_class_helper], 'deps': _khash_primitive_helper_dep}, + 'hashtable': {'sources': ['hashtable.pyx', _hashtable_class_helper, _hashtable_func_helper], 'deps': [_khash_primitive_helper_dep]}, + 'index': {'sources': ['index.pyx', _index_class_helper], 'deps': [_khash_primitive_helper_dep]}, 'indexing': {'sources': ['indexing.pyx']}, 'internals': {'sources': ['internals.pyx']}, 'interval': {'sources': ['interval.pyx', _intervaltree_helper], - 'deps': _khash_primitive_helper_dep}, + 'deps': [_khash_primitive_helper_dep]}, 'join': {'sources': ['join.pyx', _khash_primitive_helper], - 'deps': _khash_primitive_helper_dep}, + 'deps': [_khash_primitive_helper_dep]}, 'lib': {'sources': ['lib.pyx', 'src/parser/tokenizer.c']}, 'missing': {'sources': ['missing.pyx']}, 'pandas_datetime': {'sources': ['src/vendored/numpy/datetime/np_datetime.c', @@ -83,7 +83,7 @@ libs_sources = { 'src/parser/io.c', 'src/parser/pd_parser.c']}, 'parsers': {'sources': ['parsers.pyx', 'src/parser/tokenizer.c', 'src/parser/io.c'], - 'deps': _khash_primitive_helper_dep}, + 'deps': [_khash_primitive_helper_dep]}, 'json': {'sources': ['src/vendored/ujson/python/ujson.c', 'src/vendored/ujson/python/objToJSON.c', 'src/vendored/ujson/python/JSONtoObj.c', @@ -116,7 +116,7 @@ foreach ext_name, ext_dict : libs_sources ext_dict.get('sources'), cython_args: cython_args, include_directories: [inc_np, inc_pd], - dependencies: ext_dict.get('deps', ''), + dependencies: ext_dict.get('deps', []) + [np_dep], subdir: 'pandas/_libs', install: true ) diff --git a/pandas/_libs/tslib.pyx b/pandas/_libs/tslib.pyx index d320bfdbe3022..b29252a5b8e51 100644 --- a/pandas/_libs/tslib.pyx +++ b/pandas/_libs/tslib.pyx @@ -70,7 +70,6 @@ from pandas._libs.tslibs.conversion cimport ( from pandas._libs.tslibs.dtypes cimport npy_unit_to_abbrev from pandas._libs.tslibs.nattype cimport ( NPY_NAT, - c_NaT as NaT, c_nat_strings as nat_strings, ) from pandas._libs.tslibs.timestamps cimport _Timestamp @@ -347,39 +346,6 @@ def array_with_unit_to_datetime( return result, tz -cdef _array_with_unit_to_datetime_object_fallback(ndarray[object] values, str unit): - cdef: - Py_ssize_t i, n = len(values) - ndarray[object] oresult - tzinfo tz = None - - # TODO: fix subtle differences between this and no-unit code - oresult = cnp.PyArray_EMPTY(values.ndim, values.shape, cnp.NPY_OBJECT, 0) - for i in range(n): - val = values[i] - - if checknull_with_nat_and_na(val): - oresult[i] = NaT - elif is_integer_object(val) or is_float_object(val): - - if val != val or val == NPY_NAT: - oresult[i] = NaT - else: - try: - oresult[i] = Timestamp(val, unit=unit) - except OutOfBoundsDatetime: - oresult[i] = val - - elif isinstance(val, str): - if len(val) == 0 or val in nat_strings: - oresult[i] = NaT - - else: - oresult[i] = val - - return oresult, tz - - @cython.wraparound(False) @cython.boundscheck(False) def first_non_null(values: ndarray) -> int: diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index 3a55f5fa0c003..aa512dc1f9b00 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -105,7 +105,7 @@ def cast_from_unit_vectorized( int64_t m int p NPY_DATETIMEUNIT in_reso, out_reso - Py_ssize_t i + Py_ssize_t i = 0 assert values.dtype.kind == "f" diff --git a/pandas/_libs/tslibs/meson.build b/pandas/_libs/tslibs/meson.build index 85410f771233f..9bcdf799659b8 100644 --- a/pandas/_libs/tslibs/meson.build +++ b/pandas/_libs/tslibs/meson.build @@ -34,7 +34,7 @@ foreach ext_name, ext_dict : tslibs_sources ext_dict.get('sources'), cython_args: cython_args, include_directories: [inc_np, inc_pd], - dependencies: ext_dict.get('deps', ''), + dependencies: ext_dict.get('deps', []) + [np_dep], subdir: 'pandas/_libs/tslibs', install: true ) diff --git a/pandas/_libs/tslibs/util.pxd b/pandas/_libs/tslibs/util.pxd index e4ac3a9e167a3..a5822e57d3fa6 100644 --- a/pandas/_libs/tslibs/util.pxd +++ b/pandas/_libs/tslibs/util.pxd @@ -185,11 +185,11 @@ cdef inline const char* get_c_string(str py_string) except NULL: return get_c_string_buf_and_size(py_string, NULL) -cdef inline bytes string_encode_locale(str py_string) noexcept: +cdef inline bytes string_encode_locale(str py_string): """As opposed to PyUnicode_Encode, use current system locale to encode.""" return PyUnicode_EncodeLocale(py_string, NULL) -cdef inline object char_to_string_locale(const char* data) noexcept: +cdef inline object char_to_string_locale(const char* data): """As opposed to PyUnicode_FromString, use current system locale to decode.""" return PyUnicode_DecodeLocale(data, NULL) diff --git a/pandas/_libs/window/meson.build b/pandas/_libs/window/meson.build index ad15644f73a0c..f3adabe8e7a36 100644 --- a/pandas/_libs/window/meson.build +++ b/pandas/_libs/window/meson.build @@ -3,6 +3,7 @@ py.extension_module( ['aggregations.pyx'], cython_args: ['-X always_allow_keywords=true'], include_directories: [inc_np, inc_pd], + dependencies: [np_dep], subdir: 'pandas/_libs/window', override_options : ['cython_language=cpp'], install: true @@ -13,6 +14,7 @@ py.extension_module( ['indexers.pyx'], cython_args: ['-X always_allow_keywords=true'], include_directories: [inc_np, inc_pd], + dependencies: [np_dep], subdir: 'pandas/_libs/window', install: true ) diff --git a/pandas/meson.build b/pandas/meson.build index 435103a954d86..98007e5099a24 100644 --- a/pandas/meson.build +++ b/pandas/meson.build @@ -1,7 +1,13 @@ -incdir_numpy = run_command(py, - [ - '-c', - ''' +# NumPy 2.0 can be detected with meson >= 0.14.0 +np_dep = dependency('numpy', required : false) + +if np_dep.found() + inc_np = [] +else + incdir_numpy = run_command(py, + [ + '-c', + ''' import os import numpy as np try: @@ -12,12 +18,14 @@ try: except Exception: incdir = np.get_include() print(incdir) - ''' - ], - check: true -).stdout().strip() + ''' + ], + check: true + ).stdout().strip() + + inc_np = include_directories(incdir_numpy) +endif -inc_np = include_directories(incdir_numpy) inc_pd = include_directories('_libs/include') fs.copyfile('__init__.py') diff --git a/pyproject.toml b/pyproject.toml index f96fbee4a5818..3ca922463b53f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,8 @@ # Minimum requirements for the build system to execute. # See https://github.com/scipy/scipy/pull/12940 for the AIX issue. requires = [ - "meson-python==0.13.1", - "meson==1.2.1", + "meson-python==0.15.0", + "meson==1.4.0", "wheel", "Cython~=3.0.5", # Note: sync with setup.py, environment.yml and asv.conf.json # Any NumPy version should be fine for compiling. Users are unlikely diff --git a/requirements-dev.txt b/requirements-dev.txt index 0cc064d2660bb..5df33123f5f31 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,8 +4,8 @@ pip versioneer[toml] cython~=3.0.5 -meson[ninja]==1.2.1 -meson-python==0.13.1 +meson[ninja]==1.4.0 +meson-python==0.15.0 pytest>=7.3.2 pytest-cov pytest-xdist>=2.2.0