A batteries included task runner that works well with poetry and uv
—
Seamless integration with Poetry's plugin system, enabling poethepoet tasks to be executed through Poetry commands with shared environment and configuration.
The Poetry plugin enables poethepoet tasks to be executed directly through Poetry commands, providing unified environment management and configuration sharing.
class PoetryPlugin:
def activate(self, application: Application) -> None:
"""
Activate the poethepoet plugin within Poetry.
Args:
application: Poetry application instance
Registers the 'poe' command with Poetry's command system,
enabling 'poetry poe task_name' execution.
"""The PoeCommand class provides the Poetry command interface for executing poethepoet tasks.
class PoeCommand:
def handle(self) -> int:
"""
Handle Poetry poe command execution.
Returns:
Exit code (0 for success)
Processes Poetry command arguments and delegates to
poethepoet for task execution within Poetry's environment.
"""
def get_poe(self, application, io, poe_config) -> PoeThePoet:
"""
Create PoeThePoet instance configured for Poetry integration.
Args:
application: Poetry application instance
io: Poetry IO handler
poe_config: Poethepoet configuration
Returns:
Configured PoeThePoet instance
"""The plugin can be installed and managed through Poetry's plugin system.
# Install poethepoet with plugin support
pip install poethepoet[poetry_plugin]
# Or install as Poetry plugin directly
poetry self add poethepoet[poetry_plugin]
# Verify plugin installation
poetry --pluginsThe plugin is registered through the Poetry entry point system:
# Entry point configuration (in pyproject.toml)
[project.entry-points."poetry.application.plugin"]
poethepoet = "poethepoet.plugin:PoetryPlugin"Once installed, poethepoet tasks can be executed through Poetry commands.
# Execute poethepoet task through Poetry
poetry poe test
# Pass arguments to tasks
poetry poe serve --port 8080
# Use Poetry's environment management
poetry poe build # Runs in Poetry's virtual environment# Standalone poethepoet (requires separate installation)
poe test
# Poetry plugin (uses Poetry's environment)
poetry poe test
# Both execute the same tasks but with different environment contextsThe plugin provides seamless integration with Poetry's virtual environment and dependency management.
# Environment integration features
class PoetryIntegration:
# Automatic virtual environment detection
virtual_env_path: str
# Poetry configuration sharing
poetry_config: dict
# Dependency resolution integration
dependencies: dict
# Build system integration
build_backend: strThe plugin shares configuration and environment settings between Poetry and poethepoet:
The plugin can be configured through Poetry's configuration system and poethepoet's own configuration.
# pyproject.toml - Shared configuration
[tool.poetry]
name = "my-project"
version = "0.1.0"
[tool.poetry.dependencies]
python = "^3.9"
requests = "^2.25.0"
# Poethepoet tasks available to both standalone and plugin usage
[tool.poe.tasks]
test = "pytest"
lint = "flake8 ."
build = {script = "build:main"}# Optional plugin-specific configuration
[tool.poe.poetry_hooks]
# Hooks to run before/after Poetry commands
pre_install = "poe clean"
post_install = "poe setup"# Environment variables available in plugin context
POETRY_ACTIVE = "1" # Indicates Poetry environment
POETRY_VIRTUAL_ENV = "path" # Virtual environment path
POETRY_PROJECT_ROOT = "path" # Project root directory
POETRY_PYPROJECT_TOML = "path" # pyproject.toml locationThe plugin can access Poetry's dependency information:
# Dependency integration capabilities
class PoetryDependencyIntegration:
def get_installed_packages(self) -> dict[str, str]:
"""Get Poetry's installed packages."""
def get_project_dependencies(self) -> dict[str, str]:
"""Get project dependencies from pyproject.toml."""
def get_dev_dependencies(self) -> dict[str, str]:
"""Get development dependencies."""The plugin handles various Poetry versions and configuration scenarios.
# Compatibility and error handling
class PluginCompatibility:
min_poetry_version: str = "1.2.0"
max_poetry_version: str = "3.0.0"
def check_compatibility(self) -> bool:
"""Check Poetry version compatibility."""
def handle_config_conflicts(self) -> None:
"""Resolve configuration conflicts."""
def migrate_legacy_config(self) -> None:
"""Migrate from legacy configuration formats."""# Install project with Poetry
poetry install
# Install poethepoet plugin
poetry self add poethepoet[poetry_plugin]
# Run tasks through Poetry
poetry poe test
poetry poe lint
poetry poe build# Poetry + poethepoet integrated workflow
poetry install # Install dependencies
poetry poe format # Format code
poetry poe lint # Lint code
poetry poe test # Run tests
poetry build # Build package
poetry poe deploy # Deploy application# GitHub Actions example with Poetry plugin
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install Poetry
run: pip install poetry
- name: Install dependencies and plugin
run: |
poetry install
poetry self add poethepoet[poetry_plugin]
- name: Run tasks via plugin
run: |
poetry poe lint
poetry poe test
poetry poe build# Developers can use both approaches
poe test # Standalone poethepoet
poetry poe test # Through Poetry plugin
# Environment differences
poe --executor simple test # Custom executor
poetry poe test # Poetry's virtual environment
# Configuration sharing
poe -C other_project test # Different project
poetry poe test # Current Poetry project only# Custom plugin extension example
from poethepoet.plugin import PoetryPlugin
class CustomPoetryPlugin(PoetryPlugin):
def activate(self, application):
super().activate(application)
# Add custom Poetry integration features
self.add_custom_commands()
def add_custom_commands(self):
# Extend plugin functionality
passInstall with Tessl CLI
npx tessl i tessl/pypi-poethepoet