Skip to content

Latest commit

 

History

History
100 lines (84 loc) · 5.13 KB

File metadata and controls

100 lines (84 loc) · 5.13 KB

Extension package lifecycle

Takes templates/extension-addon-template through what an extension meets after its first run: validate, build, a repository listing, install, an upgrade over the top, removal, and the online-access gate. Every step runs a child Blender against a throwaway user directory (BLENDER_USER_RESOURCES), so the real install is never touched. Check-only: the witnesses are exit codes, zip members and paths, so a render would look the same whether the contract held or broke.

Follows extension-runtime-and-packaging, whose snippet is extension-user-data.py. Scaffolding matches eval-mesh-datablock-name (check() steps return codes, argparse falsifier flags, FATAL wrapper).

What it witnesses:

  • blender --command extension validate and build accept the template, and the zip carries blender_manifest.toml and __init__.py at its root.
  • validate is not a release gate. With wheels = ["./wheels/not_shipped-1.0-py3-none-any.whl"] appended and no such file, validate exits 0 and build exits 1 with no zip. Only the build opens the files the manifest names.
  • extension server-generate --repo-dir writes index.json listing the package with archive_url ./example_addon-0.1.0.zip.
  • Installed with extension install-file -r user_default, the add-on imports as bl_ext.user_default.example_addon, and bpy.utils.extension_path_user(__package__) names extensions/.user/user_default/example_addon, beside the install tree extensions/user_default/example_addon, not inside it.
  • Installing 0.2.0 over 0.1.0 replaces the install tree (a file written beside __file__ is gone) and keeps the user directory (settings.json survives). extension remove deletes the user directory too.
  • bpy.app.online_access is False in a factory-startup child and True under --online-mode.

What failure each check would catch:

  • exit 3 — the template stopped validating or building, or the zip lost its manifest
  • exit 4 — a package whose wheel does not exist passed the release gate (--validate-only lands here: it gates on validate alone); also exit 4 if validate starts rejecting the missing wheel, because the trap this example names would then be gone
  • exit 5 — server-generate wrote no listing, or the listing does not name the package
  • exit 6 — install, import, upgrade or remove failed, or __package__ is not bl_ext.user_default.example_addon
  • exit 7 — user data lives inside the install tree, did not survive the upgrade, or survived removal (--data-next-to-file lands here: it stores data beside __file__)
  • exit 8 — online_access is not False by default and True under --online-mode

Re-verified

Measurement 4.5.11 5.1.2 5.2.1
validate / build, template 0 / 0 0 / 0 0 / 0
validate / build, missing wheel 0 / 1 0 / 1 0 / 1
__package__ bl_ext.user_default.example_addon same same
user data kept by 0.2.0 upgrade yes yes yes
file beside __file__ kept by upgrade no no no
user data after remove deleted deleted deleted
online_access default / --online-mode False / True False / True False / True
default exit 0 0 0
--validate-only / --data-next-to-file exit 4 / 7 4 / 7 4 / 7

API reference

Run

blender --background --python extension_package_lifecycle.py --
blender --background --python extension_package_lifecycle.py -- --validate-only
blender --background --python extension_package_lifecycle.py -- --data-next-to-file

The script starts about a dozen child Blender processes, so it takes longer than most examples.

Exit codes

Code Meaning
0 Success
1 Uncaught exception (FATAL wrapper)
2 argparse / usage
3 Template does not validate or build, or the zip lacks its manifest
4 Missing-wheel package passed the release gate (--validate-only lands here)
5 server-generate listing missing or wrong
6 Install, import, upgrade or remove failed, or __package__ wrong
7 User data inside the install tree, lost on upgrade, or kept after removal (--data-next-to-file lands here)
8 online_access default or --online-mode value wrong

The blender-smoke workflow runs the check on Blender 5.2 LTS and 4.5 LTS (5.1 on the weekly cron, the needs-5.1 PR label, or manual dispatch). Smoke passes no extra flags on the happy path. Its catalog falsifiers are --validate-only (expects exit 4) and --data-next-to-file (expects exit 7).