Skip to content

Commit 45771c9

Browse files
honnokgryte
andauthored
Include entry points as an optional feature (#297)
* Entry points as an optional feature when adoption * Update copy * Fix grammar * Revert change * Update copy Co-authored-by: Athan <kgryte@gmail.com>
1 parent 4294f43 commit 45771c9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

spec/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,5 @@
143143
),
144144
"durole": ("http://docutils.sourceforge.net/docs/ref/rst/" "roles.html#%s", ""),
145145
"dudir": ("http://docutils.sourceforge.net/docs/ref/rst/" "directives.html#%s", ""),
146+
"pypa": ("https://packaging.python.org/%s", ""),
146147
}

spec/purpose_and_scope.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,31 @@ recommended not to add other functions or objects, because that may make it
369369
harder for users to write code that will work with multiple array libraries.
370370

371371

372+
### Discoverability
373+
374+
To assist array-consuming libraries which need to create arrays originating from multiple conforming array implementations, conforming implementations may provide an {pypa}`entry point <specifications/entry-points/>` in order to make an array API namespace discoverable. For example,
375+
376+
```python
377+
from importlib.metadata import entry_points
378+
379+
try:
380+
eps = entry_points()['array_api']
381+
ep = next(ep for ep in eps if ep.name == 'package_name')
382+
except TypeError:
383+
# The dict interface for entry_points() is deprecated in py3.10,
384+
# supplanted by a new select interface.
385+
ep = entry_points(group='array_api', name='package_name')
386+
387+
xp = ep.load()
388+
```
389+
390+
An entry point must have the following properties:
391+
392+
- **group**: equal to `array_api`.
393+
- **name**: equal to the package name.
394+
- **object reference**: equal to the array API namespace import path.
395+
396+
372397
* * *
373398

374399
## Conformance

0 commit comments

Comments
 (0)