Skip to main content

Plugin Template

Plugins are features that extend Manim's core functionality. This is a template project that demonstrates how you can create and upload a manim plugin to PyPI using a PEP 517 compliant build system, Poetry.

Poetry is NOT required to create plugins, but is recommended because it provides build isolation and ensures users can reliably install your plugin without falling into dependency hell. You may use another build system (e.g. Flit, Setuptools, Pipenv, etc...) if you wish.

Creating Plugins

The only requirement of your preferred build system is that it specifies the manim.plugins entry point.

note

The plugin naming convention is to add the prefix manim-. This allows users to easily search for plugins on organizations like PyPi, but it is not required.

Installing Poetry

Poetry can be installed on Windows, MacOS and Linux. Please visit the official poetry website for installation instructions. You may want to see the official documentation for a list of all available commands.

Setting Up Your Plugin Directory Structure

To create a Python project suitable for poetry, run:

poetry new --src manim-YourPluginName 

note

--src is both optional and recomended in order to create a src directory where all of your plugin code should live.

This will create the following project structure: :

manim-YourPluginName
├── pyproject.toml
├── README.rst
├── src
│   └── manim_yourpluginname
│       └── __init__.py
└── tests
    ├── __init__.py
    └── test_manim_yourpluginname.py 

If you have already extended manim's functionality, you can instead run:

cd path/to/plugin
poetry init

This will prompt you for basic information regarding your plugin and help create and populate a pyproject.toml similar to the one in this template; however, you may wish to update your project directory structure similarly.

See the official documentation for more information on the init command.

From now on, when working on your plugin, ensure you are using the virtual environment by running the following at the root of your project:

poetry shell 

Updating Pyproject.toml

The pyproject.toml file is used by Poetry and other build systems to manage and configure your project. Manim uses the package's entry point metadata to discover available plugins. The entry point group, "manim.plugins", is REQUIRED and can be specified as follows:

[tool.poetry.plugins."manim.plugins"]
"manim_yourpluginname" = "module:object.attr"

note

The left hand side represents the entry point name which should be unique among other plugin names. This is the internal name Manim will use to identify and handle plugins.

The right hand side should reference a python object (i.e. module, class, function, method, etc...) and will be the first code run in your plugin. In the case of this template repository, the package name is used which Python interprets as the package's __init__.py module.

See the python packaging documentation for more information on entry points.

Testing Your Plugin Locally

poetry install

This command will read the pyproject.toml, install the dependencies of your plugin, and create a poetry.lock file to ensure everyone using your plugin gets the same version of dependencies. It is important that your dependencies are properly annotated with a version constraint (e.g. manim:^0.1.1, numpy:*, etc...). Equally important to the dependencies specified here is that they do not directly conflict with Manim's. If you want to update the dependencies specified in pyproject.toml, use:

poetry update

See the official documentation for more information on versioning or the install command.

Poetry allows for dependencies that are strictly for project developers. These are not installed by users. To add them to your project, update the pyproject.toml file with the section followed by the dependencies:

[tool.poetry.dev-dependencies]
pytest = "*"
pylint = "*"

The pytest package is a functional testing framework which you can use to run the test within the manim-YourPluginName/tests directory. You should create files which test the behavior and functionality of your plugin here. Test first development is a good practice to ensure your code behaves as intended before packaging and shipping your code publicly. Additionally, you can create Manimations that depend on your plugin which is another great way to ensure functionality.

Uploading Your Project

By default, poetry is set to register the package/plugin to PyPI. You'll need to register an account there to upload/update your plugin. As soon as your plugin is useful locally, run the following:

poetry publish --build

Your project should now be available on PyPI for users to install via pip install manim-YourPluginName and usable within their respective environments.

See the official documentation for more information on the publish command.

Code of Conduct

Our full code of conduct, and how we enforce it, can be read on our website.

Release files for manim-plugintemplate 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manim-plugintemplate 0.1.5
File Size Uploaded
manim-PluginTemplate-0.1.5.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for manim-plugintemplate 0.1.5
File Interpreter ABI Platform
manim_PluginTemplate-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / manim-PluginTemplate-0.1.5.tar.gz

Download URL manim-PluginTemplate-0.1.5.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8aa7090d5f02ac03e41a6d772b37838ca7ade3ed3a1ac61601ac68c25da4e25a
BLAKE2b-256 checksum
How to use checksums
bcab622f18dcdebae50c799aba1fcb3ef59c8608fa3ee320e8ade5775d176c40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure

Release files / manim_PluginTemplate-0.1.5-py3-none-any.whl

Download URL manim_PluginTemplate-0.1.5-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d881f161a9ab41d295b7fb8f3b182d4972b9e6c568a391c5e202dc8221655148
BLAKE2b-256 checksum
How to use checksums
a90cfc385075531a501e95ced88da183e176373f085ce1e2b288677e72ae1f95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page