Skip to content

Commit 2f98d2f

Browse files
authored
Merge pull request #874 from rgommers/numpy-min-2.0
BLD: drop numpy 1.x support
2 parents ca8d5ef + 02011aa commit 2f98d2f

6 files changed

Lines changed: 26 additions & 61 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ env:
1919
FORCE_COLOR: 3
2020
# Some common environment variables for both GNU/Linux and macOS jobs
2121
MPLBACKEND: Agg
22-
NUMPY_MIN: numpy==1.26.4
23-
CYTHON_MIN: cython==3.1.3
22+
NUMPY_MIN: numpy==2.0.0
23+
CYTHON_MIN: cython==3.2.5
24+
MESON_MIN: meson==1.4.0
25+
MESON_PYTHON_MIN: meson-python==0.18.0
2426

2527
jobs:
2628
test_pywavelets_linux:
@@ -94,8 +96,8 @@ jobs:
9496
pip install --upgrade pip build
9597
# Set numpy version first, other packages link against it
9698
if [ "${MINIMUM_REQUIREMENTS}" == "1" ]; then
97-
pip install ${CYTHON_MIN}
98-
pip install ${NUMPY_MIN}
99+
pip install ${MESON_MIN} ${MESON_PYTHON_MIN} ninja
100+
pip install ${CYTHON_MIN} ${NUMPY_MIN}
99101
else
100102
pip install ${PIP_FLAGS} cython
101103
pip install ${PIP_FLAGS} numpy
@@ -112,6 +114,8 @@ jobs:
112114
elif [ "${REFGUIDE_CHECK}" == "1" ]; then
113115
pip install sphinx numpydoc scipy-doctest
114116
pip install . -v
117+
elif [ "${MINIMUM_REQUIREMENTS}" == "1" ]; then
118+
pip install . -v --no-build-isolation
115119
elif [ "${OPTIONS_NAME}" == "struct-complex" ]; then
116120
pip install . -v -Csetup-args=-Dc_args=-DPYWT_TEST_STRUCT_COMPLEX
117121
else
@@ -219,6 +223,7 @@ jobs:
219223
pip install --upgrade pip build
220224
# Set numpy version first, other packages link against it
221225
if [ "${MINIMUM_REQUIREMENTS}" == "1" ]; then
226+
pip install ${MESON_MIN} ${MESON_PYTHON_MIN} ninja
222227
pip install ${CYTHON_MIN} ${NUMPY_MIN}
223228
else
224229
pip install ${PIP_FLAGS} cython numpy
@@ -232,6 +237,8 @@ jobs:
232237
elif [ "${REFGUIDE_CHECK}" == "1" ]; then
233238
pip install sphinx numpydoc scipy-doctest
234239
pip install . -v
240+
elif [ "${MINIMUM_REQUIREMENTS}" == "1" ]; then
241+
pip install . -v --no-build-isolation
235242
else
236243
pip install . -v
237244
fi

‎README.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ For more usage examples see the `demo`_ directory in the source package.
6565
Installation
6666
------------
6767

68-
PyWavelets supports `Python`_ >=3.10, and is only dependent on `NumPy`_
69-
(supported versions are currently ``>= 1.23.0``). To pass all of the tests,
68+
PyWavelets supports `Python`_ >=3.12, and is only dependent on `NumPy`_
69+
(supported versions are currently ``>=2.0.0,<3``). To pass all of the tests,
7070
`Matplotlib`_ is also required.
7171

7272
There are binary wheels for Intel Linux, Windows and macOS / OSX on PyPi. If

‎meson.build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(
33
'c', 'cython',
44
version: '1.11.0.dev0',
55
license: 'MIT',
6-
meson_version: '>= 1.1.0',
6+
meson_version: '>= 1.4.0',
77
default_options: [
88
'buildtype=debugoptimized',
99
'b_ndebug=if-release',

‎pyproject.toml‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ build-backend = "mesonpy"
99
requires = [
1010
"meson-python>=0.18.0",
1111
"Cython>=3.2.5",
12-
13-
# numpy requirement for wheel builds for distribution on PyPI - building
14-
# against 2.x yields wheels that are also compatible with numpy 1.x at
15-
# runtime.
16-
# Note that building against numpy 1.x works fine too - users and
17-
# redistributors can do this by installing the numpy version they like and
18-
# disabling build isolation.
19-
"numpy>=2.0.0",
12+
"numpy>=2.0.0,<3",
2013
]
2114

2215
[project]
@@ -32,7 +25,7 @@ maintainers = [
3225
]
3326
description = "PyWavelets, wavelet transform module"
3427
requires-python = ">=3.12"
35-
dependencies = ["numpy>=1.26.4,<3"]
28+
dependencies = ["numpy>=2.0.0,<3"]
3629
readme = "README.rst"
3730
classifiers = [
3831
"Development Status :: 5 - Production/Stable",

‎pywt/_extensions/meson.build‎

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,15 @@ if m_dep.found()
33
add_project_link_arguments('-lm', language : 'c')
44
endif
55

6-
# Don't use the deprecated NumPy C API. Define this to a fixed version instead of
7-
# NPY_API_VERSION in order not to break compilation for released PyWavelets
8-
# versions when NumPy introduces a new deprecation.
9-
numpy_nodepr_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION']
10-
11-
# Uses the `numpy-config` executable (or a user's numpy.pc pkg-config file),
12-
# will work for numpy>=2.0.0b1 and meson>=1.4.0
13-
_numpy_dep = dependency('numpy', required: false)
14-
if _numpy_dep.found()
15-
np_dep = declare_dependency(dependencies: _numpy_dep, compile_args: numpy_nodepr_api)
16-
else
17-
# For cross-compilation it is often not possible to run the Python interpreter
18-
# in order to retrieve numpy's include directory. It can be specified in the
19-
# cross file instead:
20-
# [properties]
21-
# numpy-include-dir = /abspath/to/host-pythons/site-packages/numpy/core/include
22-
#
23-
# This uses the path as is, and avoids running the interpreter.
24-
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
25-
if incdir_numpy == 'not-given'
26-
incdir_numpy = run_command(py,
27-
[
28-
'-c',
29-
'''import os
30-
import numpy as np
31-
try:
32-
incdir = os.path.relpath(np.get_include())
33-
except Exception:
34-
incdir = np.get_include()
35-
print(incdir)
36-
'''
37-
],
38-
check: true
39-
).stdout().strip()
40-
endif
41-
inc_np = include_directories(incdir_numpy)
42-
np_dep = declare_dependency(include_directories: inc_np, compile_args: numpy_nodepr_api)
43-
endif
6+
# Uses the `numpy-config` executable (or a user's numpy.pc pkg-config file).
7+
_numpy_dep = dependency('numpy', version: ['>=2.0', '<3'])
8+
np_dep = declare_dependency(
9+
dependencies: _numpy_dep,
10+
# Don't use the deprecated NumPy C API. Define this to a fixed version
11+
# instead of NPY_API_VERSION in order not to break compilation for released
12+
# PyWavelets versions when NumPy introduces a new deprecation.
13+
compile_args: ['-DNPY_NO_DEPRECATED_API=NPY_2_0_API_VERSION'],
14+
)
4415

4516
sources = [
4617
'c/common.c',

‎pywt/_utils.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import inspect
55
from collections.abc import Iterable
66

7-
import numpy as np
7+
from numpy.exceptions import AxisError
88

99
from ._extensions._pywt import (
1010
ContinuousWavelet,
@@ -13,12 +13,6 @@
1313
Wavelet,
1414
)
1515

16-
AxisError: type[Exception]
17-
if np.lib.NumpyVersion(np.__version__) >= '1.25.0':
18-
from numpy.exceptions import AxisError
19-
else:
20-
from numpy import AxisError
21-
2216

2317
def _as_wavelet(wavelet):
2418
"""Convert wavelet name to a Wavelet object."""

0 commit comments

Comments
 (0)