Commit Graph

34 Commits

Author SHA1 Message Date
Campbell Barton
0b13d1f31a Extensions: suppress noisy "bl_info" prints unless --debug-python is set
Ref !119521
2024-03-20 15:43:40 +11:00
Campbell Barton
4ed06c648d Fix #119664: Persistent state not set when disabling add-ons
The wrong persistent attribute was set when disabling an add-on,
also correct the message when disabling an already disabled add-on.
2024-03-20 11:56:25 +11:00
Campbell Barton
adb304f0ed Extensions: improve UI for adding/removing repositories
- Adding new repositories now differentiates between "Online" & "Local"
  where adding a local repository doesn't prompt for a URL.
- Support removing repositories and their files (uses confirmation
  defaulting to "Cancel" to avoid accidents).
- Show an error icon next to repositories that have invalid settings,
  these repositories are now ignored until the settings are corrected,
  required fields are highlighted red when they're unset & required.
- Rename "directory" to "custom_directory" since an automatic path is
  used when not set - created in the users scripts directory.
- Use toggles for custom-directory & remote URL instead of relying on
  the value to be left an empty string for alternative behavior.
2024-02-02 20:46:45 +11:00
Campbell Barton
c9ad858d9d Extensions: update manifest to bl_info conversion
Update extension to bl_info conversion to account for recent changes.
2024-02-01 22:42:24 +11:00
Campbell Barton
fb29925158 Extensions: support addon_utils.module_bl_info() for enabled extensions
Add-ons "bl_info" was supported for add-ons which weren't registered,
however the real modules weren't handled causing module_bl_info()
to return dummy values when an extensions add-ons module was passed in.

This caused the minimum Blender version check after enabling an add-on
to do nothing.

Now the "bl_info" from extension modules is ignored and the bl_info
is created on demand from the manifest.
2024-02-01 17:11:15 +11:00
Campbell Barton
355fd2313d Extensions: detect time-stamp changes to extensions manifest on refresh
- Add a warning when an extensions meta-data is missing.
- Remove the time-stamps from message that time-stamps have changes
  since knowing the exact times isn't helpful.
2024-02-01 17:03:47 +11:00
Campbell Barton
a8e73616b9 Cleanup: rename add-on related variables for clarity
- Rename info to bl_info, to avoid confusion with extensions manifest,
  which should eventually be accessible in a similar way.
- Rename module_name to addon_module_name to avoid confusion with
  extension repositories name-spaced modules.
- Clarify naming for TOML manifest.
2024-02-01 17:03:40 +11:00
Campbell Barton
fb16dbf9ae Extensions: support authors as a list from the TOML manifest
Also fix blank errors caused by catching assertions which resulted
in empty strings.
2024-01-31 17:43:44 +11:00
Campbell Barton
73214e9b26 Extensions: change the manifest filename
Use the name "blender_manifest.toml" for clarity.
2024-01-30 09:42:01 +11:00
Campbell Barton
8841990764 Extensions: use the TOML manifest as a source for extensions bl_info 2024-01-25 14:36:20 +11:00
Campbell Barton
b686f2a536 UI: show the version as a string for extensions
Extensions use SEMVER, not a tuple of numbers.
2024-01-25 14:36:20 +11:00
Campbell Barton
6aede44fb7 PyAPI: remove checks for add-ons pre 2.8x
This made sense when migrating from 2.7x, now 2.8x add-ons may also
have issues in 4.1 so this check isn't so relevant.
2024-01-25 13:00:48 +11:00
Campbell Barton
b8b1189bc4 Cleanup: assign a variable for the extension module with a trailing "."
This is used in enough places to simplify checks.
2024-01-25 13:00:48 +11:00
Campbell Barton
9cc6ee75e7 Extensions: support using a default local user directory
This is needed so extensions repositories can reference
user-script directories without them having hard-coded paths
which will be invalid when upgrading a Blender version.
2024-01-24 16:50:32 +11:00
Campbell Barton
53a8570aec Extensions: enable the package management add-on when enabled
Package management has been moved into addons_contrib so the addon
can be enabled when enabling extension repositories.

This means users can test extension repositories without having to
install a separate add-on.

Additional work is still needed with the server before this is ready
for general testing though.

Part of #117286.
2024-01-24 13:25:27 +11:00
Campbell Barton
7daf900181 Cleanup: spelling in comments, remote debug print 2024-01-19 17:28:14 +11:00
Campbell Barton
665472a18b Extensions: changes to repositories are now accounted for by add-ons
Add-ons using the extension API now follow changes to their
repositories.

- Removing a repository disables and removes associated add-ons.
- Disabling a repository disables the add-on but keeps add-on &
  its preferences.
- Enabling a repository re-enables add-ons that use it.
- Renaming a repository updates the names of associated add-ons &
  it's preferences.
2024-01-19 17:19:09 +11:00
Campbell Barton
5149aed4ac PyAPI: improve warnings when addons from extensions repos fail to load 2024-01-17 18:30:16 +11:00
Campbell Barton
e87b67398c Extensions: add/remove bl_ext sub-modules when repo.enabled is toggled
This disables any add-ons which are part of the disabled repository.
2023-12-19 18:41:37 +11:00
Campbell Barton
9a75c29bf8 Fix #113206: add-on unregister() not called on exit
Own regression in [0] caused add-ons not to run the unregister function
on exit.

[0]: e1b72e569decd4fdee87eb1ae2b43569d8c6bd26
2023-10-04 16:09:30 +11:00
Campbell Barton
4790c6ac61 addon_utils: don't print a traceback when the add-on isn't found
This was already done for ImportError but missed, ModuleNotFoundError.
2023-09-15 17:23:08 +10:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton
e1b72e569d Fix #111649: 3rd party Python modules can cause Python error on exit
Disabling all add-ons on exit could raise exceptions when `sys.modules`
contained modules that ran logic in their `__getattr__` function.

Resolve by accessing the modules name-space directly,
bypassing the `__getattr__` function.
2023-08-30 16:16:24 +10:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton
c61aa42f7d PyAPI: make addon_utils.paths_with_extension_repos an internal function
This is only needed for internal use at the moment, rename to make it
clear it's only for internal use.

Also remove unnecessary variable assignments.
2023-08-09 20:36:31 +10:00
Campbell Barton
49f342d742 Cleanup: rename addon_utils._initiazlize to _initiazlize_once
Make it clear this is only intended to be called once.
2023-08-09 20:29:33 +10:00
Campbell Barton
31cb31d736 PyAPI: add-on name-spacing for extension repositories
Support name-spaced add-ons, exposed via user configurable extension
repositories.

Directories for add-ons can be added at run-time and are name-spaced to
avoid name-collisions with Python modules or add-ons from other
repositories.

This is exposed as an experimental feature "Extension Repositories".

Details:

- A `bUserExtensionRepo` type which represents a repository which is
  listed in the add-ons repository.

- `JunctionModuleHandle` class to manage a package with sub-modules
  which can point to arbitrary locations.

- `bpy.app.handlers._extension_repos_update_{pre/post}` internal
  callbacks run before/after changes to extension repositories,
  callbacks are used to sync the changes to the Python package that
  exposes these to add-ons.

- The size of an add-on name has been increased so a user-defined package
  prefix can be included without enforcing shorter add-on names.

- Functionality relating to package management has been left out of this
  change and will be developed separately.

Further work:

- While a repository can be renamed, enabled add-ons aren't renamed.
  Eventually we might want to support this although we could also
  disallow renaming repositories with add-ons enabled as the name isn't
  all that significant.

- Removing a repository should remove all the add-ons located in this
  repository.

- Sub-module names are currently restricted to `[A-Za-z]+[A-Za-z0-9_]*`
  we might want to relax this to allow unicode characters (we might
  still want to disallow `-` or any characters that would prevent
  attribute access in code).

Ref !110869.

Reviewed By: brecht
2023-08-09 20:24:24 +10:00
Campbell Barton
58e4a7ae2b Cleanup: minor changes for add-on & module listing
Use list-comprehension for addon_utils.paths and other minor changes.
2023-08-07 10:46:45 +10:00
Campbell Barton
53e6803977 Cleanup: check for "BaseException" instead of "Exception"
Prefer the more generic exception type as it's possible exceptions
derive from this and not "Exception".

Also use the name 'ex' for exceptions instead of 'e'.
2023-07-30 16:14:13 +10:00
Campbell Barton
9f5be2a861 Cleanup: quiet pylint warnings using BaseException 2023-07-30 16:14:11 +10:00
Campbell Barton
52109ff7f0 Refactor: out addon_utils fake_module(..) into a top-level function
Even though it's private, it's useful to be able to access this for
prototyping support for scanning addons in other other locations.
2023-07-29 22:20:40 +10:00
Campbell Barton
6ff81c6505 PyAPI: internal changes needed to support sub-modules as add-ons
Apply minor changes needed for an add-on to be a sub-module.
2023-07-29 22:15:11 +10:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Sergey Sharybin
03806d0b67 Re-design of submodules used in blender.git
This commit implements described in the #104573.

The goal is to fix the confusion of the submodule hashes change, which are not
ideal for any of the supported git-module configuration (they are either always
visible causing confusion, or silently staged and committed, also causing
confusion).

This commit replaces submodules with a checkout of addons and addons_contrib,
covered by the .gitignore, and locale and developer tools are moved to the
main repository.

This also changes the paths:
- /release/scripts are moved to the /scripts
- /source/tools are moved to the /tools
- /release/datafiles/locale is moved to /locale

This is done to avoid conflicts when using bisect, and also allow buildbot to
automatically "recover" wgen building older or newer branches/patches.

Running `make update` will initialize the local checkout to the changed
repository configuration.

Another aspect of the change is that the make update will support Github style
of remote organization (origin remote pointing to thy fork, upstream remote
pointing to the upstream blender/blender.git).

Pull Request #104755
2023-02-21 16:39:58 +01:00