3
11
This repository has been archived on 2024-05-16. You can view files and clone it, but cannot push or open issues or pull requests.
blender-addons-contrib/bl_pkg/readme.rst
Campbell Barton d5ec3dd4c5 Add "Blender Extensions" experimental add-on
This add-on implements installing/upgrading extensions and remains
experimental (depends on extension repositories).

Move to a addons_contrib add-on so users can test more easily.

See #117286.
2024-01-24 13:24:08 +11:00

3.7 KiB
Raw Permalink Blame History

Blender Extensions

Directory Layout

./blender_addon/bl_pkg/cli/

The stand-alone command line utility to manage extensions.

./blender_addon/bl_pkg/

The Blender add-on which wraps the command line utility (abstracts details of interacting with the package manager & repositories).

./tests/

Automated tests.

To run tests via the Makefile.

Test the command line application.

make test PYTHON_BIN=/path/to/bin/python3.11

If your system Python is v3.11 or newer you may omit PYTHON_BIN.

make test_blender BLENDER_BIN=/path/to/blender

GUI

This GUI is work-in-progress, currently its been made to work with an un-modified Blender 4.1.

  • Link blender_addon/bl_pkg into your add-ons directly.

  • Enable the blender extensions add-on from Blender.

  • Enable the blender extensions checkbox in the add-ons preference (this is a temporary location).

  • Repositories can be added/removed from the “Files” section in the preferences.

Hacking

Some useful hints.

When developing the command line interface, these tests can be setup to run on file-change, run:

make watch_test

To run Blender tests.

make watch_test_blender BLENDER_BIN=/path/to/blender

How to Setup a Test Environment

Most of the options here are using the command-line tools. For a comprehensive list of commands check the help:

./blender_addon/bl_pkg/cli/blender_ext.py --help

Dummy server

The simple way to get started is by creating a dummy asset library.

./blender_addon/bl_pkg/cli/blender_ext.py dummy-repo \
   --repo-dir=/path/to/host/my/repo/files \
   --package-names="blue,red,green,purple,orange"

This will populate the directory specified as --repo-dir with dummy assets packages (.txz), and an index (bl_ext_repo.json).

Setup an Extensions Repository

First you need to create individual packages for the individual extension:

  • Go to the directory of the extension you want to package.

  • Create a bl_ext_pkg.toml file with your configuration.

  • Run the command blender_ext.py pkg-build.

You can look at an example of a dummy extension in the example_extension directory.

cd ./example_extension
../blender_addon/bl_pkg/cli/blender_ext.py pkg-build

This will create a my_example_package.txz (as specified in the .toml file).

Now you can move all your *.txz packages to where they will be hosted in the server. The final step is to create an index file to serve all your packages.

mkdir -p /path/to/host/my/repo/files
cp ./example_extension/my_example_package.txz /path/to/host/my/repo/files
./blender_addon/bl_pkg/cli/blender_ext.py server-generate --repo-dir /path/to/host/my/repo/files

This will generate a new file bl_ext_repo.json in your repository directory. This file is to be used the entry point to your remote server.

Alternatively, if you are doing tests locally, you can point the directory containing this file as the Remote Path to your Extensions Repository.

Requirement: Add-Ons

Add-ons packaged as extensions must use relative imports when importing its own sub-modules. This is a requirement of Python module name-spacing.

Requirement: Blender 4.1

This add-on requires an yet-to-be released version of Blender.

You can download a daily build of Blender 4.1 for testing and development purposes.