This guide provides technical details for developing, testing, and troubleshooting the boot-python plugin.
Prerequisites:
- Python 3.9+
- Poetry
-
Clone the repository and navigate into the directory.
-
Install dependencies: This command will create a virtual environment and install all necessary packages from
pyproject.toml.poetry install
-
Compile Protobufs: The gRPC code is not checked into version control. You must generate it after installing the dependencies.
poetry run python -m grpc_tools.protoc -I./proto --python_out=./src/generated --grpc_python_out=./src/generated ./proto/plugin.proto
boot-code discovers and communicates with plugins based on a simple, strict contract:
- First line on
stdout: Must be the handshake string in the format1|1|tcp|HOST:PORT|grpc. - All other output: All logs, warnings, and errors must be sent to
stderr. This keepsstdoutclean so the handshake is not corrupted. Themain.pyfile is already configured to do this.
You can quickly test that the binary is producing the correct handshake and that logs are properly sent to stderr.
# From the boot-python project root, run the executable and grab the first line of stdout
poetry run boot-python 2>/dev/null | head -1Expected Output:
1|1|tcp|127.0.0.1:<PORT>|grpc
(The port number will be different each time)
boot-code discovers the plugin by finding an executable named boot-python on its PATH.
From the boot-code directory, run this command to see which boot-python executable its environment will use:
poetry run which boot-pythonIf this command returns nothing, it means the boot-python executable is not in the PATH that the boot-code environment is using.
The most common issue is that the plugin's virtual environment is not in your shell's PATH.
-
Find the virtual environment's path from within your
boot-pythondirectory:poetry env info --path
-
Add the
binsubdirectory of that path to your shell's configuration file (e.g.,~/.zshrcor~/.bash_profile).# Example for ~/.zshrc export PATH="/path/from/previous/command/bin:$PATH"
-
Restart your terminal for the changes to take effect.
-
Format Code:
poetry run ruff format . -
Lint Code:
poetry run ruff check . --fix -
Run Unit Tests (if you add any):
poetry run pytest
-
Plugin executable not found: This is aPATHissue.boot-codecannot find theboot-pythonbinary. See the "How to Fix PATH Issues" section above. -
Invalid handshake/not enough values to unpack: This means the plugin wrote something tostdoutbefore the handshake string. Ensure all logging and print statements in the Python code useloggingor write tosys.stderr. -
ModuleNotFoundError: If the plugin fails with this error, it's likely an issue with relative vs. absolute imports within thesrcdirectory. Ensure all intra-package imports use the relative.syntax (e.g.,from .server import ...).
Unlike the Rust plugin which is a compiled binary, the Python plugin is an interpreted package. The standard way to create a release is to build a source distribution (sdist) and a wheel (.whl).
-
Run the Poetry build command: From the root of your
boot-pythonproject, run:poetry build
-
Find the artifacts: This command will create a
dist/directory containing two files:boot-python-0.1.0.tar.gz(the source distribution)boot_python-0.1.0-py3-none-any.whl(the wheel)
Create a new release on your plugin's GitHub repository and upload both the .tar.gz and .whl files from your dist/ directory as the release assets.
Note: The boot plugin install command is designed to download compiled binaries and will not use these Python artifacts. This release process is the standard way to version and distribute Python packages for sharing and potential future installation via pip.