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

docs: added documentaion on how to define entry-points for ape plugin #2183

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 12 additions & 0 deletions docs/userguides/developing_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ entry_points={
...
```

If you're using `pyproject.toml` you can register the entry_point like this

`pyproject.toml`:

```yml
[...]
# Make it work with cli like ape myplugin
[project.entry-points.ape_cli_subcommands]
Copy link
Contributor

Choose a reason for hiding this comment

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

I needed to register the entry-point using [<project-name>.entry-points.ape_cli_subcommands] in order for it to register properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's strange. I believe it has to be a property of the project. What env management tool are you using? Have you tried installing it using pip?

Copy link
Contributor

Choose a reason for hiding this comment

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

I installed using pip install -e .. It actually gave me an error when I tried using what you have.

ValueError: invalid pyproject.toml config: `project`.
      configuration error: `project` must contain ['name'] properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm that's odd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I think you need to define the project name like this

[project]
name = "ape-utils"
[...]

[project.entry-points.ape_cli_subcommands]

[...]

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably need to add a new documentation section for using only a pyproject.toml for an ape project since it'll need more configuration than just this. Definitely something to keep in mind when we start development on this later @bitwise-constructs

ape_myplugin = "ape_myplugin._cli:cli"
[...]
```

```{note}
Typically, a `_cli.py` module is used instead of a `__init__.py` module for the location of the Click CLI group because it is logically separate from the Python module loading process.
```
Expand Down
Loading