Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37635716
en ru br
Репозитории ALT

Группа :: Development/Python3
Пакет: python3-module-numpy

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: numpy-1.20.2-Remove-strict-dependency-on-testing-package.patch
Скачать


From 59cd28358eb169ff13b16d350eb2ce92c7053e7b Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Tue, 11 Jun 2019 11:06:24 +0300
Subject: [PATCH] tests: Remove strict dependency on testing package
This is a bad practice to require internal testing/tests packages
in the main package. This results in all the clients of `numpy`
have parasitic dependencies on numpy-testing/tests and their deps.
This is something we don't want.
---
 numpy/__init__.py            | 29 +++++++++++++++++++----------
 numpy/core/__init__.py       |  9 ++++++---
 numpy/f2py/__init__.py       | 32 ++++++++++++++++++++------------
 numpy/fft/__init__.py        |  9 ++++++---
 numpy/lib/__init__.py        |  9 ++++++---
 numpy/linalg/__init__.py     |  9 ++++++---
 numpy/ma/__init__.py         |  9 ++++++---
 numpy/matrixlib/__init__.py  |  9 ++++++---
 numpy/polynomial/__init__.py |  9 ++++++---
 numpy/random/__init__.py     |  9 ++++++---
 numpy/typing/__init__.py     |  9 ++++++---
 11 files changed, 93 insertions(+), 49 deletions(-)
diff --git a/numpy/__init__.py b/numpy/__init__.py
index 6021e6d8f..30812a736 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -293,12 +293,15 @@ else:
             #
             # The previous way Tester was imported also had a side effect of adding
             # the full `numpy.testing` namespace
-            if attr == 'testing':
-                import numpy.testing as testing
-                return testing
-            elif attr == 'Tester':
-                from .testing import Tester
-                return Tester
+            try:
+                if attr == 'testing':
+                    import numpy.testing as testing
+                    return testing
+                elif attr == 'Tester':
+                    from .testing import Tester
+                    return Tester
+            except ImportError:
+                pass
 
             raise AttributeError("module {!r} has no attribute "
                                  "{!r}".format(__name__, attr))
@@ -309,7 +312,10 @@ else:
     else:
         # We don't actually use this ourselves anymore, but I'm not 100% sure that
         # no-one else in the world is using it (though I hope not)
-        from .testing import Tester
+        try:
+            from .testing import Tester
+        except ImportError:
+            pass
 
         # We weren't able to emit a warning about these, so keep them around
         globals().update({
@@ -319,9 +325,12 @@ else:
 
 
     # Pytest testing
-    from numpy._pytesttester import PytestTester
-    test = PytestTester(__name__)
-    del PytestTester
+    try:
+        from numpy._pytesttester import PytestTester
+        test = PytestTester(__name__)
+        del PytestTester
+    except ImportError:
+        pass
 
 
     def _sanity_check():
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py
index 2534e5fb9..0dd96f605 100644
--- a/numpy/core/__init__.py
+++ b/numpy/core/__init__.py
@@ -161,6 +161,9 @@ del copyreg
 del _ufunc_reduce
 del _DType_reduce
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py
index 07ab6cd7d..8c451d853 100644
--- a/numpy/f2py/__init__.py
+++ b/numpy/f2py/__init__.py
@@ -130,24 +130,32 @@ if sys.version_info[:2] >= (3, 7):
         # Avoid importing things that aren't needed for building
         # which might import the main numpy module
         if attr == "f2py_testing":
-            import numpy.f2py.f2py_testing as f2py_testing
-            return f2py_testing
+            try:
+                import numpy.f2py.f2py_testing as f2py_testing
+                return f2py_testing
+            except ImportError:
+                pass
 
         elif attr == "test":
-            from numpy._pytesttester import PytestTester
-            test = PytestTester(__name__)
-            return test
+            try:
+                from numpy._pytesttester import PytestTester
+                test = PytestTester(__name__)
+                return test
+            except ImportError:
+                pass
 
-        else:
-            raise AttributeError("module {!r} has no attribute "
-                                 "{!r}".format(__name__, attr))
+        raise AttributeError("module {!r} has no attribute "
+                             "{!r}".format(__name__, attr))
 
     def __dir__():
         return list(globals().keys() | {"f2py_testing", "test"})
 
 else:
-    from . import f2py_testing
+    try:
+        from . import f2py_testing
 
-    from numpy._pytesttester import PytestTester
-    test = PytestTester(__name__)
-    del PytestTester
+        from numpy._pytesttester import PytestTester
+        test = PytestTester(__name__)
+        del PytestTester
+    except ImportError:
+        pass
diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py
index a86bb3ac0..adc182345 100644
--- a/numpy/fft/__init__.py
+++ b/numpy/fft/__init__.py
@@ -203,6 +203,9 @@ For examples, see the various functions.
 from ._pocketfft import *
 from .helper import *
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py
index ad88ba347..2065fb94f 100644
--- a/numpy/lib/__init__.py
+++ b/numpy/lib/__init__.py
@@ -56,6 +56,9 @@ __all__ += npyio.__all__
 __all__ += nanfunctions.__all__
 __all__ += histograms.__all__
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/linalg/__init__.py b/numpy/linalg/__init__.py
index 3a53ac6ec..e47673926 100644
--- a/numpy/linalg/__init__.py
+++ b/numpy/linalg/__init__.py
@@ -72,6 +72,9 @@ Exceptions
 # To get sub-modules
 from .linalg import *
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/ma/__init__.py b/numpy/ma/__init__.py
index 870cc4ef2..5705cd5e4 100644
--- a/numpy/ma/__init__.py
+++ b/numpy/ma/__init__.py
@@ -49,6 +49,9 @@ __all__ = ['core', 'extras']
 __all__ += core.__all__
 __all__ += extras.__all__
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/matrixlib/__init__.py b/numpy/matrixlib/__init__.py
index 54154d11f..d183e70bd 100644
--- a/numpy/matrixlib/__init__.py
+++ b/numpy/matrixlib/__init__.py
@@ -5,6 +5,9 @@ from .defmatrix import *
 
 __all__ = defmatrix.__all__
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/polynomial/__init__.py b/numpy/polynomial/__init__.py
index c832094e2..8280a6df0 100644
--- a/numpy/polynomial/__init__.py
+++ b/numpy/polynomial/__init__.py
@@ -171,6 +171,9 @@ def set_default_printstyle(style):
     ABCPolyBase._use_unicode = _use_unicode
 
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py
index 7efa5c07f..e91e73f97 100644
--- a/numpy/random/__init__.py
+++ b/numpy/random/__init__.py
@@ -208,6 +208,9 @@ def __RandomState_ctor():
     return RandomState(seed=0)
 
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py
index 87235a418..165268148 100644
--- a/numpy/typing/__init__.py
+++ b/numpy/typing/__init__.py
@@ -227,6 +227,9 @@ if __doc__ is not None:
     __doc__ += '\n.. autoclass:: numpy.typing.NBitBase\n'
     del _docstrings
 
-from numpy._pytesttester import PytestTester
-test = PytestTester(__name__)
-del PytestTester
+try:
+    from numpy._pytesttester import PytestTester
+    test = PytestTester(__name__)
+    del PytestTester
+except ImportError:
+    pass
-- 
2.29.3
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin