blender/scripts/modules/_bpy_internal
Campbell Barton 67ddb0e1a5 Extensions: detect external changes on startup & loading preferences
Changes to an extensions manifest weren't accounted for.
This was particularly a problem for "System" extensions which aren't
intended to be managed inside Blender however the problem existed for
any changes made outside of Blender.

Now enabled extensions are checked on startup to ensure:

- They are compatible with Blender.
- The Python wheels are synchronized.

Resolves #123645.

Details:

- Any extension incompatibilities prevent the add-on being enabled
  with a message printing the reason for it being disabled.

- Incompatible add-ons are kept enabled in the preferences to avoid
  loosing their own preferences and allow for an upgrade to restore
  compatibility.

- To avoid slowing down Blender's startup:

  - Checks are skipped when no extensions are enabled
    (as is the case for `--factory-startup` & running tests).
  - Compatibility data is cached so in common case,
    the cache is loaded and all enabled extensions `stat` their
    manifests to detect changes without having to parse them.
  - The cache is re-generated if any extensions change or the
    Blender/Python version changes.

- Compatibility data is updated:

  - On startup (when needed).
  - On an explicit "Refresh Local"
    (mainly for developers who may edit the manifest).
  - When refreshing extensions after install/uninstall etc.
    since an incompatible extensions may become compatible
    after an update.
  - When reloading preferences.

- Additional info is shown when the `--debug-python` is enabled,
  if there are ever issues with the extension compatibility cache
  generation not working as expected.

- The behavior for Python wheels has changed so they are only setup
  when the extension is enabled. This was done to simplify startup
  checks and has the benefit that an installed but disabled extension
  never runs code - as the ability to install wheels means it could
  have been imported from other scripts. It also means users can disable
  an extension to avoid wheel version conflicts.

  This does add the complication however that enabling add-on which is
  an extension must first ensure it's wheels are setup.
  See `addon_utils.extensions_refresh(..)`.

See code-comments for further details.
2024-07-01 15:08:14 +10:00
..
addons Extensions: detect external changes on startup & loading preferences 2024-07-01 15:08:14 +10:00
extensions Extensions: move the wheel_manager out of the extensions add-on 2024-07-01 10:07:16 +10:00
__init__.py Linux: freedesktop support for file type association 2024-04-18 11:19:00 +10:00
freedesktop.py Cleanup: Python script formatting 2024-06-06 11:26:28 +10:00