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

DOC: add some documentation on how to use entry points #502

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

daknuett
Copy link

This fixes #500 and discussion #501.

I have tested the example code.

Thanks to @dnicolodi .

@dnicolodi
Copy link
Member

docs/tutorials/entrypoints.rst is not linked to the documentation index, thus the proposed changes have no effect. Anyhow, I find the proposed addition way to heavy to describe the use of entry points, for which I'm pretty sure we don't need a whole tutorial. I think that a simple paragraph somewhere stating that meson-python implements https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata is enough.

@daknuett
Copy link
Author

@FFY00 what are your thoughts? I just implemented parts of the stub.

@rgommers
Copy link
Contributor

rgommers commented Oct 7, 2023

Entrypoints were not completely trivial to figure out when I needed them for NumPy, and the upstream docs are not very good for a user (and painfully formatted). So a small worked example would be nice to have in my opinion. I'd be happy to review this PR and get it merged.

This is a bit long on boilerplate though, and too short on the different types of entry points. TOML is also a bit weird here in that there's not a single [project.entry-points] table but that you must repeat it. E.g., for numpy:

[project.scripts]
f2py = 'numpy.f2py.f2py2e:main'

[project.entry-points.array_api]
numpy = 'numpy.array_api'

[project.entry-points.pyinstaller40]
hook-dirs = 'numpy:_pyinstaller_hooks_dir'

I'll add an initial review.

@rgommers rgommers added the documentation Improvements or additions to documentation label Oct 7, 2023
Copy link
Contributor

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks for writing this @daknuett. I added some suggestions. In addition, you have to uncomment the entry for this file in doc/index.rst so the doc build includes it.

docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Show resolved Hide resolved
docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Outdated Show resolved Hide resolved
docs/tutorials/entrypoints.rst Show resolved Hide resolved
docs/tutorials/entrypoints.rst Show resolved Hide resolved

[project.scripts]
simpleapp = "simpleapp.console:main"

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest adding two project.entry-points.NAME entries, that will be instructive. I suggest using the actual ones from numpy (pyinstaller40 and array_api), because those are real-world things. The actual implementation can be a one-liner, something like:

print("You discovered the PyInstaller plugin for simpleapp")

@rgommers rgommers changed the title added some documentation on how to use entry points DOC: add some documentation on how to use entry points Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to define entry points
4 participants