Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a4a3c0

Browse filesBrowse files
committed
TST: find numpy distribution from the import path
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 8e4d9ba commit 3a4a3c0
Copy full SHA for 3a4a3c0

File tree

Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed

‎numpy/testing/_private/utils.py

Copy file name to clipboardExpand all lines: numpy/testing/_private/utils.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ class KnownFailureException(Exception):
6262
KnownFailureTest = KnownFailureException # backwards compat
6363
verbose = 0
6464

65+
NUMPY_ROOT = pathlib.Path(np.__file__).parent
66+
6567
try:
66-
np_dist = importlib_metadata.distribution('numpy')
67-
except importlib_metadata.PackageNotFoundError:
68+
# Make sure we find the distibution in the path where the module was loaded from.
69+
np_dist = next(importlib_metadata.distributions(name='numpy', path=[NUMPY_ROOT.parent]))
70+
except StopIteration:
6871
IS_INSTALLED = IS_EDITABLE = False
6972
else:
7073
IS_INSTALLED = True
@@ -90,8 +93,6 @@ class KnownFailureException(Exception):
9093

9194
NOGIL_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
9295

93-
NUMPY_ROOT = pathlib.Path(np.__file__).parent
94-
9596
def assert_(val, msg=''):
9697
"""
9798
Assert that works in release mode.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.