Package: manim-plugintemplate
Plugin TemplatePlugins 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 isNOTrequired 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 PluginsThe only requirement of your preferred build system is that it specifies
themanim.pluginsentry
point.noteThe plugin naming convention is to add the prefixmanim-. This
allows users to easily search for plugins on organizations like PyPi,
but it is not required.Installing PoetryPoetry can be installed on Windows, MacOS and Linux. Please visit the
official poetry website forinstallation
instructions. You may
want to see the official documentation for a list of allavailable
commands.Setting Up Your Plugin Directory StructureTo create a Python project suitable for poetry, run:poetry new --src manim-YourPluginNamenote--srcis 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.pyIf you have already extended manim's functionality, you can instead run:cd path/to/plugin
poetry initThis will prompt you for basic information regarding your plugin and
help create and populate apyproject.tomlsimilar 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 theinit
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 shellUpdating Pyproject.tomlThepyproject.tomlfile 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", isREQUIREDand can bespecified as
follows:[tool.poetry.plugins."manim.plugins"]
"manim_yourpluginname" = "module:object.attr"noteThe 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__.pymodule.See the python packagingdocumentationfor more information on entry points.Testing Your Plugin Locallypoetry installThis command will read thepyproject.toml, install the dependencies of
your plugin, and create apoetry.lockfile 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 withManim's.
If you want to update the dependencies specified inpyproject.toml,
use:poetry updateSee the official documentation for more information onversioningor theinstall command.Poetry allows for dependencies that are strictly for project developers.
These are not installed by users. To add them to your project, update
thepyproject.tomlfile with the section followed by the dependencies:[tool.poetry.dev-dependencies]
pytest = "*"
pylint = "*"Thepytestpackage is a functional testing framework which you can use
to run the test within themanim-YourPluginName/testsdirectory. 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 ProjectBy 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 --buildYour project should now be available on PyPI for users to install viapip install manim-YourPluginNameand usable within their respective
environments.See the official documentation for more information on thepublish
command.Code of ConductOur full code of conduct, and how we enforce it, can be read onour website.