summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2022-02-08 10:53:21 -0700
committerGitHub <noreply@github.com>2022-02-08 10:53:21 -0700
commita6f55fe293502dd94eccb3799efdbaaa1d5ff1df (patch)
tree7de5a6bd467439d3c96c610b2529c2abb562b026 /numpy/core
parent9d3735a6c0781585a4a6cd767f68967d3897b38b (diff)
parentdf8d1fd3c2077ca785b0948912162e03727ace6c (diff)
downloadnumpy-a6f55fe293502dd94eccb3799efdbaaa1d5ff1df.tar.gz
Merge pull request #21000 from charris/replace-looseversion
MAINT: Replace LooseVersion by _pep440.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/setup.py3
-rw-r--r--numpy/core/setup_common.py11
-rw-r--r--numpy/core/tests/test_cython.py8
-rw-r--r--numpy/core/tests/test_scalarmath.py10
4 files changed, 11 insertions, 21 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index f087c8826..9704cff0a 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -422,12 +422,13 @@ def configuration(parent_package='',top_path=None):
exec_mod_from_location)
from numpy.distutils.system_info import (get_info, blas_opt_info,
lapack_opt_info)
+ from numpy.version import release as is_released
config = Configuration('core', parent_package, top_path)
local_dir = config.local_path
codegen_dir = join(local_dir, 'code_generators')
- if is_released(config):
+ if is_released:
warnings.simplefilter('error', MismatchCAPIWarning)
# Check whether we have a mismatch between the set C API VERSION and the
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 772c87c96..20d44f4ec 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -50,17 +50,6 @@ C_API_VERSION = 0x0000000f
class MismatchCAPIWarning(Warning):
pass
-def is_released(config):
- """Return True if a released version of numpy is detected."""
- from distutils.version import LooseVersion
-
- v = config.get_version('../_version.py')
- if v is None:
- raise ValueError("Could not get version")
- pv = LooseVersion(vstring=v).version
- if len(pv) > 3:
- return False
- return True
def get_api_versions(apiversion, codegen_dir):
"""
diff --git a/numpy/core/tests/test_cython.py b/numpy/core/tests/test_cython.py
index 9896de0ec..a9df9c9b6 100644
--- a/numpy/core/tests/test_cython.py
+++ b/numpy/core/tests/test_cython.py
@@ -13,14 +13,14 @@ try:
except ImportError:
cython = None
else:
- from distutils.version import LooseVersion
+ from numpy.compat import _pep440
- # Cython 0.29.21 is required for Python 3.9 and there are
+ # Cython 0.29.24 is required for Python 3.10 and there are
# other fixes in the 0.29 series that are needed even for earlier
# Python versions.
# Note: keep in sync with the one in pyproject.toml
- required_version = LooseVersion("0.29.21")
- if LooseVersion(cython_version) < required_version:
+ required_version = "0.29.24"
+ if _pep440.parse(cython_version) < _pep440.Version(required_version):
# too old or wrong cython, skip the test
cython = None
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index 8a77eca00..e58767d56 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -4,7 +4,7 @@ import warnings
import itertools
import operator
import platform
-from distutils.version import LooseVersion as _LooseVersion
+from numpy.compat import _pep440
import pytest
from hypothesis import given, settings, Verbosity
from hypothesis.strategies import sampled_from
@@ -684,8 +684,8 @@ class TestAbs:
if (
sys.platform == "cygwin" and dtype == np.clongdouble and
(
- _LooseVersion(platform.release().split("-")[0])
- < _LooseVersion("3.3.0")
+ _pep440.parse(platform.release().split("-")[0])
+ < _pep440.Version("3.3.0")
)
):
pytest.xfail(
@@ -698,8 +698,8 @@ class TestAbs:
if (
sys.platform == "cygwin" and dtype == np.clongdouble and
(
- _LooseVersion(platform.release().split("-")[0])
- < _LooseVersion("3.3.0")
+ _pep440.parse(platform.release().split("-")[0])
+ < _pep440.Version("3.3.0")
)
):
pytest.xfail(