Skip to content

Commit 39e3e7f

Browse files
authored
Merge pull request #21 from willingc/update-structure
Update README for recent template updates
2 parents 3665ff0 + 18408cc commit 39e3e7f

File tree

1 file changed

+192
-46
lines changed

1 file changed

+192
-46
lines changed

README.md

Lines changed: 192 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,203 @@
11
# napari-plugin-template
22

3-
[Copier](https://copier.readthedocs.io/en/stable/) template for authoring ([npe2](https://github.com/napari/npe2)-based) [napari](https://napari.org/) plugins.
3+
[![Test plugin template](https://github.com/napari/napari-plugin-template/actions/workflows/test.yml/badge.svg)](https://github.com/napari/napari-plugin-template/actions/workflows/test.yml)
4+
[![Supported Python versions](https://img.shields.io/pypi/pyversions/napari.svg)](https://python.org) <!-- Use the versions supported by napari core -->
5+
[![License](https://img.shields.io/pypi/l/napari.svg)](https://github.com/napari/napari-plugin-template/raw/main/LICENSE)
46

5-
**NOTE: This repo is not meant to be cloned/forked directly! Please read "Getting Started" below**
7+
**napari-plugin-template** is a convenient [copier](https://copier.readthedocs.io/en/stable/) template for authoring ([npe2](https://github.com/napari/npe2)-based) [napari](https://napari.org/) plugins.
8+
9+
Creating a plugin is a great way to extend napari's functionality. This repo provides a template to
10+
simplify the development and distribution your plugin. After creating a new plugin, we encourage you to send a
11+
post on our [Zulip forum](napari.zulipchat.com) to notify the napari community.
12+
13+
---
14+
15+
📣 **NOTE: This repo is not meant to be cloned/forked directly!** Instead, the copier application will be used to execute
16+
the template and ask you for configuration information (or you may accept the template's sensible defaults).
17+
Please read [Getting Started](#getting-started) below. 📣
18+
19+
---
20+
21+
## Features
22+
23+
Using the napari-plugin-template offers the following benefits:
24+
25+
- 🚀Installable [PyPI] package
26+
- 🧪[tox] test suite, testing various python versions and platforms.
27+
- 🗒️`README.md` file that contains useful information about your plugin
28+
- ⚙️Continuous integration configuration for [github actions] that handles testing
29+
and deployment of tagged releases
30+
- 🔋git-tag-based version management with [setuptools_scm]
31+
- 🪪Choose from several licenses, including [BSD-3], [MIT], [MPL v2.0], [Apache
32+
v2.0], [GNU GPL v3.0], or [GNU LGPL v3.0]
633

734
## Getting Started
835

9-
### Create your plugin package
36+
These instructions will walk you through how to create a napari plugin. It uses an application called copier
37+
to prompt you for configuration input and does the work of creating a functioning, distributable plugin from your
38+
source code.
39+
40+
### Step 1: Install the template tools.
41+
42+
This step installs the [Copier](https://copier.readthedocs.io/en/stable/) application and the [jinja2-time](https://pypi.org/project/jinja2-time/) extension.
43+
It also installs the napari plugin engine [npe2](https://github.com/napari/npe2), to help validate your new plugin is configured correctly.
1044

11-
Install [Copier](https://copier.readthedocs.io/en/stable/) and the [jinja2-time](https://pypi.org/project/jinja2-time/) extension.
12-
Optionally install the napari plugin engine [npe2](https://github.com/napari/npe2), to help validate your new plugin is configured correctly.
45+
Using `pip`:
1346

14-
Then you can generate a new napari plugin project:
47+
```bash
48+
python -m venv .venv
49+
source .venv/bin/activate
50+
python -m pip install copier jinja2-time npe2
51+
```
52+
53+
### Step 2: Create a new napari plugin project.
54+
55+
The next command will use copier to use the napari-plugin-template to generate a new napari plugin project:
1556

1657
```bash
17-
python -m pip install copier jinja2-time
18-
python -m pip install npe2
19-
copier copy --trust https://github.com/napari/napari-plugin-template new-plugin-name
58+
copier copy --trust https://github.com/napari/napari-plugin-template <new-plugin-name>
2059
```
2160

22-
Copier prompts you for information regarding your plugin
23-
(A new folder will be created in your current working directory):
61+
For example, if you want to create a new plugin with the name, `napari-growth-cone-finder`, you would enter:
2462

2563
```bash
26-
full_name [Napari Developer]: Ramon y Cajal
27-
email [yourname@example.com]: ramon@cajal.es
28-
github_username_or_organization [githubuser]: neuronz52
29-
# NOTE: for packages whose primary purpose is to be a napari plugin, we
30-
# recommend using the 'napari-' prefix in the package name.
31-
# If your package provides functionality outside of napari, you may
32-
# choose to leave napari out of the name.
33-
plugin_name [napari-foobar]: napari-growth-cone-finder
34-
Select github_repository_url:
35-
1 - https://github.com/neuronz52/napari-growth-cone-finder
36-
2 - provide later
37-
Choose from 1, 2 [1]:
38-
module_name [growth_cone_finder]: napari_growth_cone_finder
39-
display_name [napari FooBar]: Growth Cone Finder
40-
short_description [A simple plugin to use with napari]:
41-
# you can select from various plugin template examples
42-
include_reader_plugin [y]:
43-
include_writer_plugin [y]:
44-
include_sample_data_plugin [y]:
45-
include_dock_widget_plugin [y]:
46-
use_git_tags_for_versioning [y]:
64+
copier copy --trust https://github.com/napari/napari-plugin-template napari-growth-cone-finder
65+
```
66+
67+
Copier will create a new folder in your current working directory named `napari-growth-cone-finder`.
68+
It will also prompt you to begin entering configuration information.
69+
70+
### Step 3: Enter plugin configuration information.
71+
72+
Copier prompts you to enter information about your plugin. For more detailed information on each prompt see
73+
the [prompts reference](./PROMPTS.md).
74+
75+
<details open>
76+
<summary>Configuration prompts</summary>
77+
78+
```sh
79+
copier copy --trust https://github.com/napari/napari-plugin-template napari-growth-cone-finder
80+
81+
🎤 The name of your plugin
82+
napari-growth-cone-finder
83+
🎤 Display name for your plugin
84+
Growth Cone Finder
85+
🎤 Plugin module name
86+
napari_growth_cone_finder
87+
🎤 Short description of what your plugin does
88+
A simple plugin for napari
89+
🎤 Email address
90+
creator@example.com
91+
🎤 Developer name
92+
Ramon y Cajal
93+
🎤 Github user or organisation name
94+
creator
95+
🎤 Github repository URL
96+
https://github.com/creator/napari-growth-cone-finder
97+
🎤 Include reader plugin?
98+
Yes
99+
🎤 Include writer plugin?
100+
Yes
101+
🎤 Include sample data plugin?
102+
Yes
103+
🎤 Include widget plugin?
104+
Yes
105+
🎤 Use git tags for automatic versioning?
106+
Yes
107+
🎤 Install pre-commit? (Code formatting checks)
108+
Yes
109+
🎤 Install dependabot? (Automatic security updates of dependency versions)
110+
Yes
111+
🎤 Which licence do you want your plugin code to have?
112+
BSD-3
113+
47114
Select license:
48115
1 - BSD-3
49116
2 - MIT
50117
3 - Mozilla Public License 2.0
51118
4 - Apache Software License 2.0
52119
5 - GNU LGPL v3.0
53120
6 - GNU GPL v3.0
54-
Choose from 1, 2, 3, 4, 5, 6 (1, 2, 3, 4, 5, 6) [1]:
121+
Choose from 1, 2, 3, 4, 5, 6 (1, 2, 3, 4, 5, 6) [1]: 1
122+
```
55123

124+
</details>
125+
126+
After entering the configuration information, the following output will be displayed:
127+
128+
<details open>
129+
<summary>Output</summary>
130+
131+
```sh
132+
Copying from template version 0.0.0.post126.dev0+95d5ece
133+
create .napari-hub
134+
create .napari-hub/DESCRIPTION.md
135+
create .napari-hub/config-yml
136+
create .pre-commit-config.yaml
137+
create README.md
138+
create MANIFEST.in
139+
create LICENSE
140+
create .gitignore
141+
create .github
142+
create .github/workflows
143+
create .github/workflows/test_and_deploy
144+
create .github/dependabot.yml
145+
create tox.ini
146+
create pyproject.toml
147+
create src
148+
create src/napari_growth_cone_finder
149+
create src/napari_growth_cone_finder/_writer.py
150+
create src/napari_growth_cone_finder/_tests
151+
create src/napari_growth_cone_finder/_tests/test_sample_data.py
152+
create src/napari_growth_cone_finder/_tests/test_writer.py
153+
create src/napari_growth_cone_finder/_tests/__init__.py
154+
create src/napari_growth_cone_finder/_tests/test_widget.py
155+
create src/napari_growth_cone_finder/_tests/test_reader.py
156+
create src/napari_growth_cone_finder/_sample_data.py
157+
create src/napari_growth_cone_finder/napari.yaml
158+
create src/napari_growth_cone_finder/__init__.py
159+
create src/napari_growth_cone_finder/_reader.py
160+
create src/napari_growth_cone_finder/_widget.py
161+
162+
> Running task 1 of 1: ['/Users/creator/Code/repos-napari/.venv/bin/python3', '/private/var/folders/hg/l3v3xynd45sbvd141f3rqh600000gn/T/copier.vcs.clone.i5ou6e_q/_tasks.py', '--plugin_name=napari-growth-cone-finder', '--module_name=napari_growth_cone_finder', '--project_directory=napari-growth-cone-finder', '--install_precommit=True', '--github_repository_url=https://github.com/creator/napari-growth-cone-finder', '--github_username_or_organization=creator']
163+
INFO:pre_gen_project:b"\xe2\x9c\x94 Manifest for 'Growth Cone Finder' valid!"
164+
Switched to a new branch 'main'
165+
install pre-commit ...
166+
/Users/creator/Code/repos-napari/.venv/bin/python: No module named pip
167+
updating pre-commit...
168+
install pre-commit hook...
169+
pre-commit installed at .git/hooks/pre-commit
170+
171+
Your plugin template is ready! Next steps:
172+
1. `cd` into your new directory
173+
cd napari-growth-cone-finder
174+
# you probably want to install your new package into your env
175+
pip install -e .
176+
177+
2. Create a github repository with the name 'napari-growth-cone-finder':
178+
https://github.com/creator/napari-growth-cone-finder.git
179+
3. Add your newly created github repo as a remote and push:
180+
git remote add origin https://github.com/creator/napari-growth-cone-finder.git
181+
git push -u origin main
182+
4. The following default URLs have been added to `setup.cfg`:
183+
Bug Tracker = https://github.com/creator/napari-growth-cone-finder/issues
184+
Documentation = https://github.com/creator/napari-growth-cone-finder#README.md
185+
Source Code = https://github.com/creator/napari-growth-cone-finder
186+
User Support = https://github.com/creator/napari-growth-cone-finder/issues
187+
These URLs will be displayed on your plugin's napari hub page.
188+
You may wish to change these before publishing your plugin!
189+
5. Read the README for more info: https://github.com/napari/napari-plugin-template
190+
6. We've provided a template description for your plugin page on the napari hub at `.napari-hub/DESCRIPTION.md`.
191+
You'll likely want to edit this before you publish your plugin.
192+
7. Consider customizing the rest of your plugin metadata for display on the napari hub:
193+
https://github.com/chanzuckerberg/napari-hub/blob/main/docs/customizing-plugin-listing.md
56194
```
57195
58-
You just created a minimal napari plugin, complete with tests
59-
and ready for automatic deployment!
196+
</details>
197+
198+
:tada: You just created a minimal napari plugin, complete with tests
199+
and ready for automatic deployment! :tada:
60200
61-
For more detailed information on each prompt see the [prompts reference](./PROMPTS.md).
62201
63202
```no-highlight
64203
napari-growth-cone-finder/
@@ -83,6 +222,7 @@ napari-growth-cone-finder/
83222
└── tox.ini
84223
```
85224
225+
86226
### Initialize a git repository in your package
87227
88228
NOTE: This is important not only for version management, but also if you want to
@@ -224,16 +364,7 @@ This template also includes a default yaml configuration for [Dependabot](https:
224364

225365
You will still need to enable Dependabot in your github settings, [see the instructions at this link](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates#managing-dependabot-security-updates-for-your-repositories). Your Dependabot configuration file is located at `.github/dependabot.yml`.
226366

227-
## Features
228-
229-
- Installable [PyPI] package
230-
- [tox] test suite, testing various python versions and platforms.
231-
- `README.md` file that contains useful information about your plugin
232-
- Continuous integration configuration for [github actions] that handles testing
233-
and deployment of tagged releases
234-
- git-tag-based version management with [setuptools_scm]
235-
- Choose from several licenses, including [BSD-3], [MIT], [MPL v2.0], [Apache
236-
v2.0], [GNU GPL v3.0], or [GNU LGPL v3.0]
367+
---
237368

238369
## Resources
239370

@@ -254,6 +385,21 @@ along with a detailed description.
254385
Distributed under the terms of the [BSD-3] license, `napari-plugin-template`
255386
is free and open source software.
256387

388+
## Using uv for getting started
389+
390+
:bulb: **Optional** :bulb:
391+
392+
[uv](https://docs.astral.sh/uv/) can reduce complexity since it will automatically install and manage a version of Python.
393+
394+
If you prefer using uv, the following commands are used for getting started:
395+
396+
```bash
397+
uv venv
398+
source .venv/bin/activate
399+
uv pip install copier jinja2-time npe2
400+
copier copy --trust https://github.com/napari/napari-plugin-template <new-plugin-name>
401+
```
402+
257403
[napari organization]: https://github.com/napari/
258404
[gitter_badge]: https://badges.gitter.im/Join%20Chat.svg
259405
[gitter]: https://gitter.im/napari/napari-plugin-template?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge "Join Chat on Gitter.im"

0 commit comments

Comments
 (0)