This is a boilerplate template to make a Blender add-on that uses external python packages (from pip/PyPI). If you don't need any packages in your addon, you can use the simpler template that this one is based off by lunadigital.
The requested packages are downloaded into the _vendor
folder along with all it's other dependancies, which can then be imported into your code like any other local python module.
Ready to make your own Blender add-on? Make a new repository from this template, download, then get developing!
Note: This guide covers the general procedure for setting up this template as tested on Ubuntu Linux. The exact commands may vary depending on your OS and development environment, so some knowledge in python and pip is recommended before trying this. If you run into problems that you can't fix yourself, feel free to open an issue at the original repo for some help and to potentially improve the code.
For more detail on this process view the official docs page.
Clone your new repository to your computer using any method you prefer. If you don't know how to, GitHub has documentation on doing this.
Now open a terminal in the cloned project folder and run pip install -r build-requirements.txt
to install the build tools for your addon.
To build the addon, run the setup script python build.py
. That will download any new packages and create a zip file of your addon.
Then just import and enable the addon in Blender and the sample code should print "hello" to the blender console. If it does, it successfully called the required module.
To change the packages included in your addon, open vendorize.toml
and change the items under packages to your required ones.
To then import this new module, use the following line replacing module name with the name of your module. from ._vendor import <module name>
To remove the sample code and module, delete the hello-world-20200509
package from vendorize.toml
and remove the two lines of code from __init__.py
that are after comments with SAMPLE:
at the start.