Skip to main content

Build Blender extensions.

Project description

blender-extension-builder

A builder for blender extensions.

Blender allows you to add dependencies via packaging wheels with the extension, however you have to manually grab the wheels and put the filenames in the blender_manifest.toml file. This can be cumbersome, especially with many dependencies, and dependencies of dependencies that you don't control. This project aims to aid in that, and make it all a lot easier.

Installation

Install via pip

pip install blender-extension-builder

You also need Blender available on the PATH in order to build the extension.

Usage

You can use the command

build-blender-extension -h
# or
bbext -h
# or
python -m build_blender_extension -h

You can specify the manifest file with the -m argument, however if you run the command with no arguments, it will assume that the blender manifest is blender_manifest.toml.

bbext -m blender_manifest.toml

If you have any dependencies that have wheels that are built for multiple platforms, then you may want to grab them all.

bbext --all-wheels

However it may take a while to download all the wheels, so this should only be used for distribution.

This can be used in conjunction with --split-platforms to generate builds for each platform.

bbext -a --split-platforms

Setting up blender_manifest.toml

Since this aims to make managing dependencies easier, there are a couple things added to the blender_manifest.toml file. The file will be structured like any blender_manifest.toml file, just with a few new options.

schema_version = "1.0.0"
id = "my_example_extension"
version = "1.0.0"
name = "My Example Extension"
tagline = "This is another extension"
maintainer = "Developer name <email@address.com>"
type = "add-on"
blender_version_min = "4.2.0"
license = [
  "SPDX:GPL-3.0-or-later",
]

# You can specify what platforms this can be used with.
platforms = ["windows-x64", "windows-arm64", "macos-arm64", "macos-x64" , "linux-x64"]
# NOTE: All wheels for all platforms will be downloaded in you specify `--all-wheels`
# no matter which platforms are specified here.
# NOTE: If `--all-wheels` is specified and the platforms are not specified, it will
# download all the platforms, and generate builds for all platforms.

# Place dependencies here. They have to be in the dependency format as specified in PEP 508.
# https://packaging.python.org/en/latest/specifications/dependency-specifiers/#dependency-specifiers
# (should be the same as in pyproject.toml files)
dependencies = [
    'numpy'
]
# Folder to store the wheels in the addon.
wheel-path = './wheels'

# If you would like to manually specify the wheels, you still can.
# This If you also specify dependencies, those will be appended into this.
wheels = [
  './wheels/pillow-10.3.0-cp311-cp311-win_amd64.whl',
]

# Use this if blender is skipping a wheel for python version
# incompatibility (even though it's compatible)
# This can also be enabled in the commandline with `--ensure-cp311` or `-cp311`
ensure-cp311 = true

[build]
# Some optional extra options were added to this table

# Folder containing the source code of the extension. Defaults to the current directory
source = './src'
# Folder for where the extension will be stored
# with all the files (to build the extension). Defaults to ./build
build = './build'
# Output folder for the built addon in the .zip file.
dist = './dist'

# This contains a list of files or folders to keep in the built extension.
paths = [
  'LICENSE',
  'README.md',
]

All you have to do is now run

build-blender-extension -m blender_manifest.toml

Note: if you don't specify any arguments, it will try to use blender_manifest.toml.

Installing

You can also auto install the extension after building directly with this command.

bbext --install

If you choose to also generate builds for all the platforms, it will install the universal build.

Other arguments

There are many other options you can use.

usage: bbext [-h] [-m MANIFEST] [-d DIST] [-cp311] [-a] [--split-platforms]
             [--python PYTHON_VERSION] [-I] [-r REPO] [-e] [--no-prefs]

Build blender extension with dependencies

options:
  -h, --help            show this help message and exit
  -m MANIFEST, --manifest MANIFEST
                        path to blender manifest
  -d DIST, --dist DIST  override dist folder
  -cp311, --ensure-cp311
                        Renames any instance of "cp##" in wheels to "cp311" to make blender  
                        not ignore it. You won't have to use this with blender 4.3.1, but    
                        is an issue in 4.3.0 and 4.2.4 LTS.
  -a, --all-wheels      Download all wheels packages for all platforms. May result in large  
                        file sizes.
  --split-platforms     Build a separate package for each platform. Adding the platform as   
                        a file name suffix (before the extension). This can be useful to     
                        reduce the upload size of packages that bundle large platform-       
                        specific modules (``*.whl`` files).
  --python PYTHON_VERSION
                        Python version to use. Defaults to the python version the minimum    
                        blender version uses (most likely 3.11).

Install options:
  Options for installing. If --install is omitted, all of these will be ignored.

  -I, --install         Install the extension.
  -r REPO, --repo REPO  The repository identifier.
  -e, --enable          Enable the extension after installation.
  --no-prefs            Treat the user-preferences as read-only, preventing updates for      
                        operations that would otherwise modify them. This means removing     
                        extensions or repositories for example, wont update the user-        
                        preferences.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blender_extension_builder-1.4.0.tar.gz (49.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blender_extension_builder-1.4.0-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file blender_extension_builder-1.4.0.tar.gz.

File metadata

File hashes

Hashes for blender_extension_builder-1.4.0.tar.gz
Algorithm Hash digest
SHA256 22116a494a1667a8283f62815fc5bc9348c3fbefea7d39a4009f1bf60d0dc79c
MD5 8342511fc370ea22eb99b428e49ffef3
BLAKE2b-256 1c8d5af5583c48b2139123a33bb89461b43071b200a6d026c25fa0525b760872

See more details on using hashes here.

Provenance

The following attestation bundles were made for blender_extension_builder-1.4.0.tar.gz:

Publisher: python-publish.yml on ego-lay-atman-bay/blender-extension-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file blender_extension_builder-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blender_extension_builder-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81cddc5294842f84cdd9a1ffa6c6bc2f5f0a86137cf652643abbb2c75ea6a5a1
MD5 8c093c89ff97848440b67df0772fc71c
BLAKE2b-256 fea03a10741ce75e2f98a29b3c40fac383aad5e116bef3755912469a4bbdf71d

See more details on using hashes here.

Provenance

The following attestation bundles were made for blender_extension_builder-1.4.0-py3-none-any.whl:

Publisher: python-publish.yml on ego-lay-atman-bay/blender-extension-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page