File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Original file line number Diff line number Diff line change @@ -65,9 +65,8 @@ class KnownFailureException(Exception):
65
65
NUMPY_ROOT = pathlib .Path (np .__file__ ).parent
66
66
67
67
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 :
71
70
IS_INSTALLED = IS_EDITABLE = False
72
71
else :
73
72
IS_INSTALLED = True
@@ -76,6 +75,15 @@ class KnownFailureException(Exception):
76
75
except AttributeError :
77
76
IS_EDITABLE = False
78
77
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
+
79
87
IS_WASM = platform .machine () in ["wasm32" , "wasm64" ]
80
88
IS_PYPY = sys .implementation .name == 'pypy'
81
89
IS_PYSTON = hasattr (sys , "pyston_version_info" )
You can’t perform that action at this time.
0 commit comments