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'
]
# dependencies can also be a path to a file. This does not follow the same rules as requirements.txt
# It instead follows the same rules as dependencies as a list, just with each line being a dependency.
# This can be used if you have some local paths you don't want sharing to the public.
dependencies = 'dependencies.txt'

# 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.5.0.tar.gz (49.8 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.5.0-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for blender_extension_builder-1.5.0.tar.gz
Algorithm Hash digest
SHA256 2509de8e19af202ac232cda9cf549105f0b2fc32bf359364ccb982615b3993b7
MD5 12572e8b237b7ca9ac28b4033bde39d5
BLAKE2b-256 273a1078ed2c5745314ac9aff4bac3939eae947fa9ff4b81f0277a807ec91d05

See more details on using hashes here.

Provenance

The following attestation bundles were made for blender_extension_builder-1.5.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.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blender_extension_builder-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba320530431cfea5e933b8b35b91a286ebe2e5f53086a43b61cfe01a99a9fa60
MD5 c84acb81cf9691863e511a212d8496f6
BLAKE2b-256 e059c4e120cfb5311ba3004ab9a42fdd72facf0c37b5a0049297af27b1a59e5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for blender_extension_builder-1.5.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