You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69-10Lines changed: 69 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,10 @@ If an error occurs at any state of the lifecycle, the `PluginManager` informs th
39
39
40
40
### Discovering entrypoints
41
41
42
+
Plux supports two modes for building entry points: **build-hooks mode** (default) and **manual mode**.
43
+
44
+
#### Build-hooks mode (default)
45
+
42
46
To build a source distribution and a wheel of your code with your plugins as entrypoints, simply run `python setup.py plugins sdist bdist_wheel`.
43
47
If you don't have a `setup.py`, you can use the plux build frontend and run `python -m plux entrypoints`.
44
48
@@ -49,6 +53,42 @@ When a setuptools command is used to create the distribution (e.g., `python setu
49
53
The `plux.json` file becomes a part of the distribution, s.t., the plugins do not have to be discovered every time your distribution is installed elsewhere.
50
54
Discovering at build time also works when using `python -m build`, since it calls registered setuptools scripts.
51
55
56
+
#### Manual mode
57
+
58
+
Manual mode is useful for isolated build environments where dependencies cannot be installed, or when build hooks are not suitable for your build process.
59
+
60
+
To enable manual mode, add the following to your `pyproject.toml`:
61
+
62
+
```toml
63
+
[tool.plux]
64
+
entrypoint_build_mode = "manual"
65
+
```
66
+
67
+
In manual mode, plux does not use build hooks. Instead, you manually generate entry points by running:
68
+
69
+
```bash
70
+
python -m plux entrypoints
71
+
```
72
+
73
+
This creates a `plux.ini` file in your working directory with the discovered plugins. You can then include this file in your distribution by configuring your `pyproject.toml`:
74
+
75
+
```toml
76
+
[project]
77
+
dynamic = ["entry-points"]
78
+
79
+
[tool.setuptools.package-data]
80
+
"*" = ["plux.ini"]
81
+
82
+
[tool.setuptools.dynamic]
83
+
entry-points = {file = ["plux.ini"]}
84
+
```
85
+
86
+
You can also manually control the output format and location:
87
+
88
+
```bash
89
+
python -m plux discover --format ini --output plux.ini
You can pass additional configuration to Plux, either via the command line or your project `pyproject.toml`.
244
+
You can pass additional configuration to Plux, either via the command line or your project `pyproject.toml`.
205
245
206
-
### Excluding Python packages during discovery
246
+
### Configuration options
247
+
248
+
The following options can be configured in the `[tool.plux]` section of your `pyproject.toml`:
249
+
250
+
```toml
251
+
[tool.plux]
252
+
# The build mode for entry points: "build-hooks" (default) or "manual"
253
+
entrypoint_build_mode = "manual"
254
+
255
+
# The file path to scan for plugins (optional)
256
+
path = "mysrc"
257
+
258
+
# Python packages to exclude during discovery (optional)
259
+
exclude = ["**/database/alembic*"]
260
+
```
261
+
262
+
#### `entrypoint_build_mode`
263
+
264
+
Controls how plux generates entry points:
265
+
-`build-hooks` (default): Plux automatically hooks into the build process to generate entry points
266
+
-`manual`: You manually control when and how entry points are generated (see [Manual mode](#manual-mode))
267
+
268
+
#### `path`
269
+
270
+
Specifies the file path to scan for plugins. By default, plux scans the entire project.
271
+
272
+
#### `exclude`
207
273
208
274
When [discovering entrypoints](#discovering-entrypoints), Plux will try importing your code to discover Plugins.
209
275
Some parts of your codebase might have side effects, or raise errors when imported outside a specific context like some database
@@ -212,14 +278,7 @@ migration scripts.
212
278
You can ignore those Python packages by specifying the `--exclude` flag to the entrypoints discovery commands (`python -m plux entrypoints` or `python setup.py plugins`).
213
279
The option takes a list of comma-separated values that can be paths or package names.
214
280
215
-
You can also specify those values in the `tool.plux` section of your `pyproject.toml`:
216
-
217
-
```toml
218
-
# ...
219
-
220
-
[tool.plux]
221
-
exclude = ["**/database/alembic*"]
222
-
```
281
+
You can also specify those values in the `tool.plux` section of your `pyproject.toml` as shown above.
0 commit comments