Skip to content

Commit a11c82f

Browse files
committed
update README
1 parent 16d22ca commit a11c82f

1 file changed

Lines changed: 69 additions & 10 deletions

File tree

README.md

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ If an error occurs at any state of the lifecycle, the `PluginManager` informs th
3939

4040
### Discovering entrypoints
4141

42+
Plux supports two modes for building entry points: **build-hooks mode** (default) and **manual mode**.
43+
44+
#### Build-hooks mode (default)
45+
4246
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`.
4347
If you don't have a `setup.py`, you can use the plux build frontend and run `python -m plux entrypoints`.
4448

@@ -49,6 +53,42 @@ When a setuptools command is used to create the distribution (e.g., `python setu
4953
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.
5054
Discovering at build time also works when using `python -m build`, since it calls registered setuptools scripts.
5155

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
90+
```
91+
5292

5393
Examples
5494
--------
@@ -201,9 +241,35 @@ build-backend = "setuptools.build_meta"
201241
Additional configuration
202242
------------------------
203243

204-
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`.
205245

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`
207273

208274
When [discovering entrypoints](#discovering-entrypoints), Plux will try importing your code to discover Plugins.
209275
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.
212278
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`).
213279
The option takes a list of comma-separated values that can be paths or package names.
214280

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.
223282

224283
Install
225284
-------

0 commit comments

Comments
 (0)