Группа :: Development/Python3
Пакет: python3-module-numpy
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: numpy-1.20.2-Remove-strict-dependency-on-testing-package.patch
Скачать
Скачать
From 01e08238544e1cd059a1c0626621fdca1e5f750a Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Thu, 9 Mar 2023 19:00:54 +0300
Subject: [PATCH] tests: Remove strict dependency on testing package
It's 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 must be avoided in distro packaging.
---
numpy/__init__.py | 6 ++++++
numpy/__pytesttester.py | 25 +++++++++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100644 numpy/__pytesttester.py
diff --git a/numpy/__init__.py b/numpy/__init__.py
index e20a83ab1..3c6328109 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -111,6 +111,12 @@
_NoValue, _CopyMode
)
+try:
+ from . import _pytesttester
+except ImportError:
+ from . import __pytesttester as _pytesttester
+ sys.modules["numpy._pytesttester"] = _pytesttester
+
# We first need to detect if we're being called as part of the numpy setup
# procedure itself in a reliable manner.
try:
diff --git a/numpy/__pytesttester.py b/numpy/__pytesttester.py
new file mode 100644
index 000000000..316cd25ab
--- /dev/null
+++ b/numpy/__pytesttester.py
@@ -0,0 +1,25 @@
+"""
+numpy._pytesttester is shipped with numpy-testing RPM package while some of
+numpy RPM package's modules unconditionally import it. This module mocks
+behaviour of numpy._pytestteste to avoid patching of every client.
+
+Typical usage that actually should be optional:
+```python
+from numpy._pytesttester import PytestTester
+test = PytestTester(__name__)
+del PytestTester
+```
+
+Typical actual usage:
+```python
+from numpy._pytesttester import PytestTester
+test = PytestTester(__name__)
+test()
+```
+"""
+class PytestTester:
+ def __init__(self, *args, **kwargs):
+ """Mock numpy._pytesttester.PytestTester"""
+
+ def __call__(self, *args, **kwargs):
+ raise ImportError("numpy.testing")
--
2.33.7