--- /dev/null
+[run]
+branch = True
+include = */numpy/*
+disable_warnings = include-ignored
exclude .*
exclude azure-*.yml
+# Include coveragerc for runtests.py
+include .coveragerc
+
# Sub-directories. Included are: numpy/, doc/, benchmarks/, tools/
include numpy/_version.py
recursive-include numpy/random *.pyx *.pxd *.pyx.in *.pxd.in
Metadata-Version: 1.2
Name: numpy
-Version: 1.21.1
+Version: 1.21.2
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
-Requires-Python: >=3.7
+Requires-Python: >=3.7,<3.11
--- /dev/null
+
+Contributors
+============
+
+A total of 10 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Bas van Beek
+* Carl Johnsen +
+* Charles Harris
+* Gwyn Ciesla +
+* Matthieu Dartiailh
+* Matti Picus
+* Niyas Sait +
+* Ralf Gommers
+* Sayed Adel
+* Sebastian Berg
+
+Pull requests merged
+====================
+
+A total of 18 pull requests were merged for this release.
+
+* `#19497 <https://github.com/numpy/numpy/pull/19497>`__: MAINT: set Python version for 1.21.x to ``<3.11``
+* `#19533 <https://github.com/numpy/numpy/pull/19533>`__: BUG: Fix an issue wherein importing ``numpy.typing`` could raise
+* `#19646 <https://github.com/numpy/numpy/pull/19646>`__: MAINT: Update Cython version for Python 3.10.
+* `#19648 <https://github.com/numpy/numpy/pull/19648>`__: TST: Bump the python 3.10 test version from beta4 to rc1
+* `#19651 <https://github.com/numpy/numpy/pull/19651>`__: TST: avoid distutils.sysconfig in runtests.py
+* `#19652 <https://github.com/numpy/numpy/pull/19652>`__: MAINT: add missing dunder method to nditer type hints
+* `#19656 <https://github.com/numpy/numpy/pull/19656>`__: BLD, SIMD: Fix testing extra checks when ``-Werror`` isn't applicable...
+* `#19657 <https://github.com/numpy/numpy/pull/19657>`__: BUG: Remove logical object ufuncs with bool output
+* `#19658 <https://github.com/numpy/numpy/pull/19658>`__: MAINT: Include .coveragerc in source distributions to support...
+* `#19659 <https://github.com/numpy/numpy/pull/19659>`__: BUG: Fix bad write in masked iterator output copy paths
+* `#19660 <https://github.com/numpy/numpy/pull/19660>`__: ENH: Add support for windows on arm targets
+* `#19661 <https://github.com/numpy/numpy/pull/19661>`__: BUG: add base to templated arguments for platlib
+* `#19662 <https://github.com/numpy/numpy/pull/19662>`__: BUG,DEP: Non-default UFunc signature/dtype usage should be deprecated
+* `#19666 <https://github.com/numpy/numpy/pull/19666>`__: MAINT: Add Python 3.10 to supported versions.
+* `#19668 <https://github.com/numpy/numpy/pull/19668>`__: TST,BUG: Sanitize path-separators when running ``runtest.py``
+* `#19671 <https://github.com/numpy/numpy/pull/19671>`__: BLD: load extra flags when checking for libflame
+* `#19676 <https://github.com/numpy/numpy/pull/19676>`__: BLD: update circleCI docker image
+* `#19677 <https://github.com/numpy/numpy/pull/19677>`__: REL: Prepare for 1.21.2 release.
.. toctree::
:maxdepth: 3
+ 1.21.2 <release/1.21.2-notes>
1.21.1 <release/1.21.1-notes>
1.21.0 <release/1.21.0-notes>
1.20.3 <release/1.20.3-notes>
--- /dev/null
+.. currentmodule:: numpy
+
+==========================
+NumPy 1.21.2 Release Notes
+==========================
+
+The NumPy 1.21.2 is maintenance release that fixes bugs discovered after
+1.21.1. It also provides 64 bit manylinux Python 3.10.0rc1 wheels for
+downstream testing. Note that Python 3.10 is not yet final. There is also
+preliminary support for Windows on ARM64 builds, but there is no OpenBLAS for
+that platform and no wheels are available.
+
+The Python versions supported for this release are 3.7-3.9. The 1.21.x series
+is compatible with Python 3.10.0rc1 and Python 3.10 will be officially
+supported after it is released. The previous problems with gcc-11.1 have been
+fixed by gcc-11.2, check your version if you are using gcc-11.
+
+
+Contributors
+============
+
+A total of 10 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Bas van Beek
+* Carl Johnsen +
+* Charles Harris
+* Gwyn Ciesla +
+* Matthieu Dartiailh
+* Matti Picus
+* Niyas Sait +
+* Ralf Gommers
+* Sayed Adel
+* Sebastian Berg
+
+
+Pull requests merged
+====================
+
+A total of 18 pull requests were merged for this release.
+
+* `#19497 <https://github.com/numpy/numpy/pull/19497>`__: MAINT: set Python version for 1.21.x to ``<3.11``
+* `#19533 <https://github.com/numpy/numpy/pull/19533>`__: BUG: Fix an issue wherein importing ``numpy.typing`` could raise
+* `#19646 <https://github.com/numpy/numpy/pull/19646>`__: MAINT: Update Cython version for Python 3.10.
+* `#19648 <https://github.com/numpy/numpy/pull/19648>`__: TST: Bump the python 3.10 test version from beta4 to rc1
+* `#19651 <https://github.com/numpy/numpy/pull/19651>`__: TST: avoid distutils.sysconfig in runtests.py
+* `#19652 <https://github.com/numpy/numpy/pull/19652>`__: MAINT: add missing dunder method to nditer type hints
+* `#19656 <https://github.com/numpy/numpy/pull/19656>`__: BLD, SIMD: Fix testing extra checks when ``-Werror`` isn't applicable...
+* `#19657 <https://github.com/numpy/numpy/pull/19657>`__: BUG: Remove logical object ufuncs with bool output
+* `#19658 <https://github.com/numpy/numpy/pull/19658>`__: MAINT: Include .coveragerc in source distributions to support...
+* `#19659 <https://github.com/numpy/numpy/pull/19659>`__: BUG: Fix bad write in masked iterator output copy paths
+* `#19660 <https://github.com/numpy/numpy/pull/19660>`__: ENH: Add support for windows on arm targets
+* `#19661 <https://github.com/numpy/numpy/pull/19661>`__: BUG: add base to templated arguments for platlib
+* `#19662 <https://github.com/numpy/numpy/pull/19662>`__: BUG,DEP: Non-default UFunc signature/dtype usage should be deprecated
+* `#19666 <https://github.com/numpy/numpy/pull/19666>`__: MAINT: Add Python 3.10 to supported versions.
+* `#19668 <https://github.com/numpy/numpy/pull/19668>`__: TST,BUG: Sanitize path-separators when running ``runtest.py``
+* `#19671 <https://github.com/numpy/numpy/pull/19671>`__: BLD: load extra flags when checking for libflame
+* `#19676 <https://github.com/numpy/numpy/pull/19676>`__: BLD: update circleCI docker image
+* `#19677 <https://github.com/numpy/numpy/pull/19677>`__: REL: Prepare for 1.21.2 release.
Generic,
IO,
Iterable,
+ Iterator,
List,
Mapping,
NoReturn,
buffersize: Any = ...,
) -> Any: ...
def __getattr__(self, key: str) -> Any: ...
+ def __enter__(self) -> nditer: ...
+ def __exit__(
+ self,
+ exc_type: None | Type[BaseException],
+ exc_value: None | BaseException,
+ traceback: None | TracebackType,
+ ) -> None: ...
+ def __iter__(self) -> Iterator[Any]: ...
+ def __next__(self) -> Any: ...
+ def __len__(self) -> int: ...
+ def __copy__(self) -> nditer: ...
+ def __getitem__(self, index: SupportsIndex | slice) -> Any: ...
+ def __setitem__(self, index: SupportsIndex | slice, value: Any) -> None: ...
+ def __delitem__(self, key: SupportsIndex | slice) -> None: ...
+
class poly1d:
def __init__(
version_json = '''
{
- "date": "2021-07-18T11:34:41-0600",
+ "date": "2021-08-15T12:15:47-0600",
"dirty": false,
"error": null,
- "full-revisionid": "df6d2600c51502e1877aac563658d0616a75c5e5",
- "version": "1.21.1"
+ "full-revisionid": "2fe48d2d98a85c8ea3f3d5caffd952ea69e99335",
+ "version": "1.21.2"
}
''' # END VERSION_JSON
'PyUFunc_SimpleBinaryComparisonTypeResolver',
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
TD(O, f='npy_ObjectLogicalAnd'),
- TD(O, f='npy_ObjectLogicalAnd', out='?'),
),
'logical_not':
Ufunc(1, 1, None,
None,
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
TD(O, f='npy_ObjectLogicalNot'),
- TD(O, f='npy_ObjectLogicalNot', out='?'),
),
'logical_or':
Ufunc(2, 1, False_,
'PyUFunc_SimpleBinaryComparisonTypeResolver',
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
TD(O, f='npy_ObjectLogicalOr'),
- TD(O, f='npy_ObjectLogicalOr', out='?'),
),
'logical_xor':
Ufunc(2, 1, False_,
docstrings.get('numpy.core.umath.logical_xor'),
'PyUFunc_SimpleBinaryComparisonTypeResolver',
TD(nodatetime_or_obj, out='?'),
+ # TODO: using obj.logical_xor() seems pretty much useless:
TD(P, f='logical_xor'),
),
'maximum':
#define NPY_CPU_HPPA
#elif defined(__alpha__)
#define NPY_CPU_ALPHA
-#elif defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
+ /* _M_ARM64 is defined in MSVC for ARM64 compilation on Windows */
#if defined(__ARMEB__) || defined(__AARCH64EB__)
#if defined(__ARM_32BIT_STATE)
#define NPY_CPU_ARMEB_AARCH32
#else
#define NPY_CPU_ARMEB
#endif
- #elif defined(__ARMEL__) || defined(__AARCH64EL__)
+ #elif defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
#if defined(__ARM_32BIT_STATE)
#define NPY_CPU_ARMEL_AARCH32
- #elif defined(__ARM_64BIT_STATE)
+ #elif defined(__ARM_64BIT_STATE) || defined(_M_ARM64)
#define NPY_CPU_ARMEL_AARCH64
#else
#define NPY_CPU_ARMEL
args, &count, strides, mask, mask_stride, cast_info->auxdata);
}
int res = stransfer(&cast_info->context,
- args, &count, strides, mask, mask_stride, cast_info->auxdata);
+ args, &N, strides, mask, mask_stride, cast_info->auxdata);
if (res < 0) {
return -1;
}
else if (NPY_UNLIKELY(out->singleton != descr)) {
/* This does not warn about `metadata`, but units is important. */
if (!PyArray_EquivTypes(out->singleton, descr)) {
- PyErr_Format(PyExc_TypeError,
+ /* Deprecated NumPy 1.21.2 (was an accidental error in 1.21) */
+ if (DEPRECATE(
"The `dtype` and `signature` arguments to "
"ufuncs only select the general DType and not details "
"such as the byte order or time unit (with rare "
"In rare cases where the time unit was preserved, "
"either cast the inputs or provide an output array. "
"In the future NumPy may transition to allow providing "
- "`dtype=` to denote the outputs `dtype` as well");
- Py_DECREF(descr);
- return NULL;
+ "`dtype=` to denote the outputs `dtype` as well. "
+ "(Deprecated NumPy 1.21)") < 0) {
+ Py_DECREF(descr);
+ return NULL;
+ }
}
}
Py_INCREF(out);
)
def test_not_deprecated(self, name: str) -> None:
self.assert_not_deprecated(lambda: getattr(self.ctypes, name))
+
+
+class TestUFuncForcedDTypeWarning(_DeprecationTestCase):
+ message = "The `dtype` and `signature` arguments to ufuncs only select the"
+
+ def test_not_deprecated(self):
+ import pickle
+ # does not warn (test relies on bad pickling behaviour, simply remove
+ # it if the `assert int64 is not int64_2` should start failing.
+ int64 = np.dtype("int64")
+ int64_2 = pickle.loads(pickle.dumps(int64))
+ assert int64 is not int64_2
+ self.assert_not_deprecated(lambda: np.add(3, 4, dtype=int64_2))
+
+ def test_deprecation(self):
+ int64 = np.dtype("int64")
+ self.assert_deprecated(lambda: np.add(3, 5, dtype=int64.newbyteorder()))
+ self.assert_deprecated(lambda: np.add(3, 5, dtype="m8[ns]"))
+
+ def test_behaviour(self):
+ int64 = np.dtype("int64")
+ arr = np.arange(10, dtype="m8[s]")
+
+ with pytest.warns(DeprecationWarning, match=self.message):
+ np.add(3, 5, dtype=int64.newbyteorder())
+ with pytest.warns(DeprecationWarning, match=self.message):
+ np.add(3, 5, dtype="m8[ns]") # previously used the "ns"
+ with pytest.warns(DeprecationWarning, match=self.message):
+ np.add(arr, arr, dtype="m8[ns]") # never preserved the "ns"
+ with pytest.warns(DeprecationWarning, match=self.message):
+ np.maximum(arr, arr, dtype="m8[ns]") # previously used the "ns"
+ with pytest.warns(DeprecationWarning, match=self.message):
+ np.maximum.reduce(arr, dtype="m8[ns]") # never preserved the "ns"
@pytest.mark.parametrize("a",
[np.zeros((3,), dtype='f8'),
np.zeros((9876, 3*5), dtype='f8')[::2, :],
- np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :]])
+ np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :],
+ # Also test with the last dimension strided (so it does not fit if
+ # there is repeated access)
+ np.zeros((9,), dtype='f8')[::3],
+ np.zeros((9876, 3*10), dtype='f8')[::2, ::5],
+ np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, ::-1]])
def test_iter_writemasked(a):
# Note, the slicing above is to ensure that nditer cannot combine multiple
# axes into one. The repetition is just to make things a bit more
"0.00000000000000000000000000000000000000000000140129846432"
"4817070923729583289916131280261941876515771757068283889791"
"08268586060148663818836212158203125")
- assert_equal(fpos64(0.5**(1022 + 52), unique=False, precision=1074),
+
+ assert_equal(fpos64(5e-324, unique=False, precision=1074),
"0.00000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000"
np.add(arr, arr, dtype="m")
np.maximum(arr, arr, dtype="m")
- def test_forced_dtype_warning(self):
- # does not warn (test relies on bad pickling behaviour, simply remove
- # it if the `assert int64 is not int64_2` should start failing.
- int64 = np.dtype("int64")
- int64_2 = pickle.loads(pickle.dumps(int64))
- assert int64 is not int64_2
- np.add(3, 4, dtype=int64_2)
-
- arr = np.arange(10, dtype="m8[s]")
- msg = "The `dtype` and `signature` arguments to ufuncs only select the"
- with pytest.raises(TypeError, match=msg):
- np.add(3, 5, dtype=int64.newbyteorder())
- with pytest.raises(TypeError, match=msg):
- np.add(3, 5, dtype="m8[ns]") # previously used the "ns"
- with pytest.raises(TypeError, match=msg):
- np.add(arr, arr, dtype="m8[ns]") # never preserved the "ns"
- with pytest.raises(TypeError, match=msg):
- np.maximum(arr, arr, dtype="m8[ns]") # previously used the "ns"
- with pytest.raises(TypeError, match=msg):
- np.maximum.reduce(arr, dtype="m8[ns]") # never preserved the "ns"
-
def test_true_divide(self):
a = np.array(10)
b = np.array(20)
assert_raises(TypeError, f, a, b)
assert_raises(TypeError, f, c, a)
+ @pytest.mark.parametrize("ufunc",
+ [np.logical_and, np.logical_or]) # logical_xor object loop is bad
+ @pytest.mark.parametrize("signature",
+ [(None, None, object), (object, None, None),
+ (None, object, None)])
+ def test_logical_ufuncs_object_signatures(self, ufunc, signature):
+ a = np.array([True, None, False], dtype=object)
+ res = ufunc(a, a, signature=signature)
+ assert res.dtype == object
+
+ @pytest.mark.parametrize("ufunc",
+ [np.logical_and, np.logical_or, np.logical_xor])
+ @pytest.mark.parametrize("signature",
+ [(bool, None, object), (object, None, bool),
+ (None, object, bool)])
+ def test_logical_ufuncs_mixed_object_signatures(self, ufunc, signature):
+ # Most mixed signatures fail (except those with bool out, e.g. `OO->?`)
+ a = np.array([True, None, False])
+ with pytest.raises(TypeError):
+ ufunc(a, a, signature=signature)
+
def test_reduce_noncontig_output(self):
# Check that reduction deals with non-contiguous output arrays
# appropriately.
x = np.array([1, 1j, 2, 2.5+.37j, np.inf, np.nan])
y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j, 2, 3])
lx = list(range(len(x)))
- # Compute the values for complex type in python
- p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
- # Substitute a result allowed by C99 standard
- p_r[4] = complex(np.inf, np.nan)
- # Do the same with numpy complex scalars
+
+ # Hardcode the expected `builtins.complex` values,
+ # as complex exponentiation is broken as of bpo-44698
+ p_r = [
+ 1+0j,
+ 0.20787957635076193+0j,
+ 0.35812203996480685+0.6097119028618724j,
+ 0.12659112128185032+0.48847676699581527j,
+ complex(np.inf, np.nan),
+ complex(np.nan, np.nan),
+ ]
+
n_r = [x[i] ** y[i] for i in lx]
for i in lx:
assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
x = np.array([1, 1j, 2, 2.5+.37j, np.inf, np.nan])
y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j, 2, 3])
lx = list(range(len(x)))
- # Compute the values for complex type in python
- p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
- # Substitute a result allowed by C99 standard
- p_r[4] = complex(np.inf, np.nan)
- # Do the same with numpy arrays
+
+ # Hardcode the expected `builtins.complex` values,
+ # as complex exponentiation is broken as of bpo-44698
+ p_r = [
+ 1+0j,
+ 0.20787957635076193+0j,
+ 0.35812203996480685+0.6097119028618724j,
+ 0.12659112128185032+0.48847676699581527j,
+ complex(np.inf, np.nan),
+ complex(np.nan, np.nan),
+ ]
+
n_r = x ** y
for i in lx:
assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
@pytest.mark.parametrize("stride", [-4,-3,-2,-1,1,2,3,4])
@pytest.mark.parametrize("astype", [np.complex64, np.complex128])
@pytest.mark.parametrize("func", ['abs', 'square', 'conjugate'])
-
+
def test_array(self, stride, astype, func):
dtype = [('template_id', '<i8'), ('bank_chisq','<f4'),
('bank_chisq_dof','<i8'), ('chisq', '<f4'), ('chisq_dof','<i8'),
myfunc = getattr(np, func)
a = vec['mycomplex']
g = myfunc(a[::stride])
-
+
b = vec['mycomplex'].copy()
h = myfunc(b[::stride])
-
+
assert_array_max_ulp(h.real, g.real, 1)
assert_array_max_ulp(h.imag, g.imag, 1)
clang = dict(
native = '-march=native',
opt = "-O3",
- werror = '-Werror'
+ # One of the following flags needs to be applicable for Clang to
+ # guarantee the sanity of the testing process, however in certain
+ # cases `-Werror` gets skipped during the availability test due to
+ # "unused arguments" warnings.
+ # see https://github.com/numpy/numpy/issues/19624
+ werror = '-Werror-implicit-function-declaration -Werror'
),
icc = dict(
native = '-xHost',
if info is None:
return
+ # Add the extra flag args to info
+ extra_info = self.calc_extra_info()
+ dict_append(info, **extra_info)
+
if self.check_embedded_lapack(info):
# check if the user has supplied all information required
self.set_info(**info)
@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
+@pytest.mark.skipif(
+ sys.version_info == (3, 10, 0, "candidate", 1),
+ reason="Broken as of bpo-44524",
+)
def test_lookfor():
out = StringIO()
utils.lookfor('eigenvalue', module='numpy', output=out,
class WithPublicMethods:
def first_method():
pass
-
+
def _has_method_heading(cls):
out = StringIO()
utils.info(cls, output=out)
return (uint64_t)product;
}
#else
-#ifdef _WIN32
+#if defined(_WIN32)
#include <intrin.h>
#if defined(_WIN64) && defined(_M_AMD64)
#pragma intrinsic(_umul128)
+#elif defined(_WIN64) && defined(_M_ARM64)
+#pragma intrinsic(__umulh)
+static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
+ *high = __umulh(a, b);
+ return a * b;
+}
#else
#pragma intrinsic(__emulu)
static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
from __future__ import annotations
import sys
-from typing import Any, overload, Sequence, TYPE_CHECKING, Union, TypeVar
+from typing import (
+ Any,
+ overload,
+ Sequence,
+ TYPE_CHECKING,
+ Union,
+ TypeVar,
+ Generic,
+)
from numpy import (
ndarray,
class _SupportsArray(Protocol[_DType_co]):
def __array__(self) -> ndarray[Any, _DType_co]: ...
else:
- _SupportsArray = Any
+ class _SupportsArray(Generic[_DType_co]):
+ pass
# TODO: Wait for support for recursive types
_NestedSequence = Union[
_ObjectCodes,
)
+_DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype)
+
_DTypeLikeNested = Any # TODO: wait for support for recursive types
if TYPE_CHECKING or HAVE_PROTOCOL:
itemsize: int
aligned: bool
- _DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype)
# A protocol for anything with the dtype attribute
class _SupportsDType(Protocol[_DType_co]):
--- /dev/null
+import copy
+import numpy as np
+
+nditer_obj: np.nditer
+
+with nditer_obj as context:
+ reveal_type(context) # E: numpy.nditer
+
+reveal_type(len(nditer_obj)) # E: builtins.int
+reveal_type(copy.copy(nditer_obj)) # E: numpy.nditer
+reveal_type(next(nditer_obj)) # E: Any
+reveal_type(iter(nditer_obj)) # E: typing.Iterator[Any]
+reveal_type(nditer_obj[1]) # E: Any
+reveal_type(nditer_obj[1:5]) # E: Any
+
+nditer_obj[1] = 1
+nditer_obj[1:5] = 1
+del nditer_obj[1]
+del nditer_obj[1:5]
--- /dev/null
+"""Tests for the optional typing-extensions dependency."""
+
+import sys
+import textwrap
+import subprocess
+
+CODE = textwrap.dedent(r"""
+ import sys
+ import importlib
+
+ assert "typing_extensions" not in sys.modules
+ assert "numpy.typing" not in sys.modules
+
+ # Importing `typing_extensions` will now raise an `ImportError`
+ sys.modules["typing_extensions"] = None
+ assert importlib.import_module("numpy.typing")
+""")
+
+
+def test_no_typing_extensions() -> None:
+ """Import `numpy.typing` in the absence of typing-extensions.
+
+ Notes
+ -----
+ Ideally, we'd just run the normal typing tests in an environment where
+ typing-extensions is not installed, but unfortunatelly this is currently
+ impossible as it is an indirect hard dependency of pytest.
+
+ """
+ p = subprocess.run([sys.executable, '-c', CODE], capture_output=True)
+ if p.returncode:
+ raise AssertionError(
+ f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
+ )
+
#-----------------------------------
# Path to the release notes
-RELEASE_NOTES = 'doc/source/release/1.21.1-notes.rst'
+RELEASE_NOTES = 'doc/source/release/1.21.2-notes.rst'
#-------------------------------------------------------
"packaging==20.5; platform_machine=='arm64'", # macos M1
"setuptools<49.2.0",
"wheel==0.36.2",
- "Cython>=0.29.21,<3.0", # Note: keep in sync with tools/cythonize.py
+ "Cython>=0.29.24,<3.0", # Note: keep in sync with tools/cythonize.py
]
'--single-version-externally-managed',
'--record=' + dst_dir + 'tmp_install_log.txt']
- from distutils.sysconfig import get_python_lib
- site_dir = get_python_lib(prefix=dst_dir, plat_specific=True)
- site_dir_noarch = get_python_lib(prefix=dst_dir, plat_specific=False)
+ py_v_s = sysconfig.get_config_var('py_version_short')
+ platlibdir = getattr(sys, 'platlibdir', '') # Python3.9+
+ site_dir_template = os.path.normpath(sysconfig.get_path(
+ 'platlib', expand=False
+ ))
+ site_dir = site_dir_template.format(platbase=dst_dir,
+ py_version_short=py_v_s,
+ platlibdir=platlibdir,
+ base=dst_dir,
+ )
+ noarch_template = os.path.normpath(sysconfig.get_path(
+ 'purelib', expand=False
+ ))
+ site_dir_noarch = noarch_template.format(base=dst_dir,
+ py_version_short=py_v_s,
+ platlibdir=platlibdir,
+ )
+
# easy_install won't install to a path that Python by default cannot see
# and isn't on the PYTHONPATH. Plus, it has to exist.
if not os.path.exists(site_dir):
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
+Programming Language :: Python :: 3.10
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development
test_suite='pytest',
version=versioneer.get_version(),
cmdclass=cmdclass,
- python_requires='>=3.7',
+ python_requires='>=3.7,<3.11',
zip_safe=False,
entry_points={
'console_scripts': f2py_cmds
-cython==0.29.23
+cython==0.29.24
wheel<0.36.3
setuptools<49.2.0
hypothesis==6.12.0
# other fixes in the 0.29 series that are needed even for earlier
# Python versions.
# Note: keep in sync with that in pyproject.toml
- required_version = LooseVersion('0.29.21')
+ # Update for Python 3.10
+ required_version = LooseVersion('0.29.24')
if LooseVersion(cython_version) < required_version:
cython_path = Cython.__file__