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
Campbell Barton 1868f1d92a Extensions: improve the method of extracting text from operators
Instead of relying on exceptions, temporarily override the stdout
to capture from & warning reports.

This allows multiple reports to be forwarded and not all reports
need to be errors.
2024-02-06 21:00:22 +11:00
..
cli Extensions: remove redundant function 2024-02-04 22:39:50 +11:00
example_extension Extensions: remove description, use tagline 2024-02-02 09:58:31 +11:00
tests Extensions: update test 2024-02-03 15:15:50 +11:00
__init__.py Extensions: improve the method of extracting text from operators 2024-02-06 21:00:22 +11:00
bl_extension_ops.py Extensions: improve the method of extracting text from operators 2024-02-06 21:00:22 +11:00
bl_extension_ui.py Extensions: use 90% of the header width for error message titles 2024-02-06 20:35:14 +11:00
bl_extension_utils.py Extensions: fix error upgrading a single active repository 2024-02-06 20:23:30 +11:00
Makefile Extensions: add check_ruff & watch_check_ruff makefile targets 2024-01-25 16:06:45 +11:00
readme.rst Add "Blender Extensions" experimental add-on 2024-01-24 13:24:08 +11:00

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.