8000 Merge pull request #24249 from rgommers/fix-entrypoint · numpy/numpy@1c51f77 · GitHub
[go: up one dir, main page]

Skip to content
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 1c51f77

Browse files
authored
Merge pull request #24249 from rgommers/fix-entrypoint
TST: enable test that checks for `numpy.array_api` entry point
2 parents 374e73d + 21fac69 commit 1c51f77

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

numpy/tests/test_public_api.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,7 @@ def check_importable(module_name):
488488

489489

490490
@pytest.mark.xfail(
491-
reason = "meson-python doesn't install this entrypoint correctly yet",
492-
)
493-
@pytest.mark.xfail(
494-
sysconfig.get_config_var("Py_DEBUG") is not None,
491+
sysconfig.get_config_var("Py_DEBUG") not in (None, 0, "0"),
495492
reason=(
496493
"NumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, "
497494
"which does not expose the `array_api` entry point. "
@@ -503,6 +500,11 @@ def test_array_api_entry_point():
503500
Entry point for Array API implementation can be found with importlib and
504501
returns the numpy.array_api namespace.
505502
"""
503+
# For a development install that did not go through meson-python,
504+
# the entrypoint will not have been installed. So ensure this test fails
505+
# only if numpy is inside site-packages.
506+
numpy_in_sitepackages = sysconfig.get_path('platlib') in np.__file__
507+
506508
eps = importlib.metadata.entry_points()
507509
try:
508510
xp_eps = eps.select(group="array_api")
@@ -512,12 +514,19 @@ def test_array_api_entry_point():
512514
# Array API entry points so that running this test in <=3.9 will
513515
# still work - see https://github.com/numpy/numpy/pull/19800.
514516
xp_eps = eps.get("array_api", [])
515-
assert len(xp_eps) > 0, "No entry points for 'array_api' found"
517+
if len(xp_eps) == 0:
518+
if numpy_in_sitepackages:
519+
msg = "No entry points for 'array_api' found"
520+
raise AssertionError(msg) from None
521+
return
516522

517523
try:
518524
ep = next(ep for ep in xp_eps if ep.name == "numpy")
519525
except StopIteration:
520-
raise AssertionError("'numpy' not in array_api entry points") from None
526+
if numpy_in_sitepackages:
527+
msg = "'numpy' not in array_api entry points"
528+
raise AssertionError(msg) from None
529+
return
521530

522531
xp = ep.load()
523532
msg = (

0 commit comments

Comments
 (0)
0