ExtensionsΒΆ
Extensions are features that are not part of the core pyApp framework but extend itβs functionality.
Available ExtensionsΒΆ
pyApp DevelopedΒΆ
π SQLAlchemy - pyapp.sqlalchemy
π Redis - pyapp.redis
In BetaΒΆ
π Rollbar - pyapp.rollbar
π§ AIO SMTPlib - pyapp.aiosmtplib Extension for aiosmtplib
β Boto3 - pyapp.boto3
β AIOBotocore - pyapp.aiobotocore
π¨ Messaging - pyapp.messaging - Extension to provide abstract interfaces for Message Queues.
- π¨ AWS Messaging - pyapp.messaging-aws - Messaging extension for AWS (SQS/SNS)
In developmentΒΆ
π§ SMTP - pyapp.SMTP
π¨ Aio-Pika - pyapp.aiopika - Messaging extension for pika (RabbitMQ/AMQP)
π PySpark - pyapp.pyspark - Extension for PySpark
π Elastic Search - pyapp.elasticsearch - Extension for Elasticsearch
Coming soonΒΆ
π¨ AMQP Messaging - Messaging extension for AMQP (RabbitMQ)
Note
The development status of these projects may have changed from when this documentation was generated, see the repository (or PyPi) of the extension package for up to date status.
Developing an ExtensionΒΆ
An extension is a standard Python package that exports a known entry point that pyApp uses to identify extensions. This entry point will reference a class with known attributes that pyApp recognises.
A Basic ProjectΒΆ
An extensions consists of a standard Python project structure eg:
βπ src
β βπ my_extension
β βπ __init__.py
βπ README.md
βπ pyproject.toml
The contents of which are:
my_extension/__init__.py
The package init file, this file contains the extension entry point. While a package must container an Extension class every attribute on the class is optional.
class Extension: """My pyApp Extension.""" default_settings = ".default_settings" checks = ".checks" @staticmethod def register_commands(root): """Register custom commands with pyApp.""" @staticmethod def ready(): """Method called once pyApp has configured environment."""
Tip
A gotcha when building extensions is attempting to access settings to early
this is the reason for the ready
event on the Extension class. Once ready
has been called settings are setup and ready for use.
README.md
While not strictly necessary a README document is highly recommended and is included in the package as the long description.
# My pyApp Extension Information about my extension
Using Setuptools with pyproject.toml
ΒΆ
Using Setuptools with setup.cfg
ΒΆ
setup.cfg
Defines the metadata and configuration used to build a package, this is also where the entry point used identify you extension is defined.
[metadata] name = my-extension version = "0.1" author = Author author-email = author@example.com description = Blurb about my extension long-description = file: README.rst url = https://github.com/author/my-extension platforms = any license = BSD-3-Clause [options] python_requires = >=3.6 packages = find: setup_requires = setuptools >=38.3 install_requires = pyapp >=4.3.0 [options.entry_points] # Used by pyApp to recognise my_extension pyapp.extensions = my-extension = my_extension:Extension
setup.py
Script that trigger
setuptools
to build a package.import setuptools setuptools.setup()
Using poetryΒΆ
pyproject.toml
Defines the metadata and configuration used to build a package, this is also where the entry point used identify you extension is defined.
[build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" [tool.poetry] name = "my-extension" version = "0.1" description = "Blurb about my extension" authors = ["Author <author@example.com>"] license = "BSD-3-Clause" packages = [ { include = "my_extension" }, ] readme = "README.rst" repository = "https://github.com/author/my-extension" [tool.poetry.dependencies] python = "^3.6" pyapp = "^4.3.0" [tool.poetry.dev-dependencies] pytest = "^5.4.3" pytest-cov = "^2.10.0" [tool.poetry.plugins."pyapp.extensions"] "my-extension" = "my_extension:Extension"