Skip to content

Include entry points as an optional feature #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spec/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""),
}
25 changes: 25 additions & 0 deletions spec/purpose_and_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit cryptic for a reader, like why does it exist? what goes wrong if an entrypoint is not implemented? The one word may is not enough, I'll try to add a note with rationale. Especially because this is in the "Purpose and scope" section, that is important.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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,

```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
Expand Down