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 12f69e0

Browse filesBrowse files
committed
TST: fix editable check with spin workaround
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 68a501c commit 12f69e0
Copy full SHA for 12f69e0

File tree

Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed

‎numpy/testing/_private/utils.py

Copy file name to clipboardExpand all lines: numpy/testing/_private/utils.py
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ class KnownFailureException(Exception):
6565
NUMPY_ROOT = pathlib.Path(np.__file__).parent
6666

6767
try:
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:
68+
np_dist = importlib_metadata.distribution('numpy')
69+
except importlib_metadata.PackageNotFoundError:
7170
IS_INSTALLED = IS_EDITABLE = False
7271
else:
7372
IS_INSTALLED = True
@@ -76,6 +75,15 @@ class KnownFailureException(Exception):
7675
except AttributeError:
7776
IS_EDITABLE = False
7877

78+
# spin installs numpy directly via meson, instead of using meson-python, and
79+
# runs the module by setting PYTHONPATH. This is problematic because the
80+
# resulting installation lacks the Python metadata (.dist-info), and numpy
81+
# might already be installed on the environment, causing us to find its
82+
# metadata, even though we are not actually loading that package.
83+
# Work around this issue by checking if the numpy root matches.
84+
if not IS_EDITABLE and np_dist.locate_file('numpy') != NUMPY_ROOT:
85+
IS_INSTALLED = False
86+
7987
IS_WASM = platform.machine() in ["wasm32", "wasm64"]
8088
IS_PYPY = sys.implementation.name == 'pypy'
8189
IS_PYSTON = hasattr(sys, "pyston_version_info")

0 commit comments

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