@@ -488,10 +488,7 @@ def check_importable(module_name): |
488 | 488 |
|
489 | 489 |
|
490 | 490 | @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"), |
495 | 492 | reason=( |
496 | 493 | "NumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, " |
497 | 494 | "which does not expose the `array_api` entry point. " |
@@ -503,6 +500,11 @@ def test_array_api_entry_point(): |
503 | 500 | Entry point for Array API implementation can be found with importlib and |
504 | 501 | returns the numpy.array_api namespace. |
505 | 502 | """ |
| 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 | + |
506 | 508 | eps = importlib.metadata.entry_points() |
507 | 509 | try: |
508 | 510 | xp_eps = eps.select(group="array_api") |
@@ -512,12 +514,19 @@ def test_array_api_entry_point(): |
512 | 514 | # Array API entry points so that running this test in <=3.9 will |
513 | 515 | # still work - see https://github.com/numpy/numpy/pull/19800. |
514 | 516 | 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 |
516 | 522 |
|
517 | 523 | try: |
518 | 524 | ep = next(ep for ep in xp_eps if ep.name == "numpy") |
519 | 525 | 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 |
521 | 530 |
|
522 | 531 | xp = ep.load() |
523 | 532 | msg = ( |
|