diff --git a/spec/conf.py b/spec/conf.py index 308ba52d2..ffb1e94a2 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -143,4 +143,5 @@ ), "durole": ("http://docutils.sourceforge.net/docs/ref/rst/" "roles.html#%s", ""), "dudir": ("http://docutils.sourceforge.net/docs/ref/rst/" "directives.html#%s", ""), + "pypa": ("https://packaging.python.org/%s", ""), } diff --git a/spec/purpose_and_scope.md b/spec/purpose_and_scope.md index 56046a277..3ef3bc611 100644 --- a/spec/purpose_and_scope.md +++ b/spec/purpose_and_scope.md @@ -369,6 +369,31 @@ recommended not to add other functions or objects, because that may make it harder for users to write code that will work with multiple array libraries. +### Discoverability + +To assist array-consuming libraries which need to create arrays originating from multiple conforming array implementations, conforming implementations may provide an {pypa}`entry point ` in order to make an array API namespace discoverable. For example, + +```python +from importlib.metadata import entry_points + +try: + eps = entry_points()['array_api'] + ep = next(ep for ep in eps if ep.name == 'package_name') +except TypeError: + # The dict interface for entry_points() is deprecated in py3.10, + # supplanted by a new select interface. + ep = entry_points(group='array_api', name='package_name') + +xp = ep.load() +``` + +An entry point must have the following properties: + +- **group**: equal to `array_api`. +- **name**: equal to the package name. +- **object reference**: equal to the array API namespace import path. + + * * * ## Conformance