Commit Graph

281 Commits

Author SHA1 Message Date
Campbell Barton
c6df05c471 Merge branch 'blender-v4.3-release' 2024-10-10 23:29:13 +11:00
Campbell Barton
b0fb6a1b2c Fix #128840: extension build asserts when "type" is missing
Building an extension when the manifest didn't define a "type"
would assert instead of reporting the missing field.

Return earlier when there are errors to prevent the assertion.
2024-10-10 23:28:11 +11:00
Campbell Barton
8fb258be0c Cleanup: format 2024-10-10 22:39:02 +11:00
YimingWu
4c57c171b3 Fix #128838: Extension: Support _universal2 suffix for Mac
Some python wheels can have `_universal2` suffixes which are built for
both intel and arm architectures. This fix takes care of that.
2024-10-10 19:15:27 +08:00
Jordan Henshaw
70a429bb18 UI: Fix missing hyphen in "Addon Tags" label
Add missing hyphen for consistency with rest of UI,
following the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/127822
2024-10-08 18:23:58 +02:00
Campbell Barton
1563ba7e6c Fix #128175: Updating extension can remove the extension on WIN32
On Windows an entire directory may be locked when any files inside it
are opened by another process. This can cause operations that
recursively remove a directory (uninstalling & updating) to fail
with a partially removed extension.

The case of uninstalling was already handled, where failure to remove
a directory would stage the extension for later removal.
In the case of updating however, the user could be left with a broken
(partially removed) extension where some files were removed, as the
directory was locked, the update would fail to extract new files.

Address this issue by renaming the directory before recursive removal.

The following logic has been implemented:

- If any files in the directory are locked, renaming will fail.
  So even though the operation fails the extension is left intact.

- If renaming succeeds, it's possible to apply the update.

  While it's possible (albeit unlikely) recursive removal fails,
  which could be caused by file-system permissions issues corruption or
  a process could open a file between rename & removal.

  In this case the renamed directory is staged for later removal.

Other changes:

- Resolve a related problem where the user could install an
  extension previously staged for removal, now installing an extension
  ensured it's not removed later.

  This would occur if uninstalling failed, the user resolves
  directory-lock, uninstalls again, then re-installs the extension.

- When an extension fails to be removed, don't attempt to remove
  user configuration for that extension.

  Prefer to keep the extension & it's settings in their "current state"
  if it can't be removed.
2024-10-03 12:15:27 +10:00
Campbell Barton
729004390d Cleanup: quiet pylint warnings for extensions 2024-10-01 16:07:05 +10:00
Campbell Barton
38c30c5c43 Extensions: resolve test failing
Enable the extensions add-on by default, without this, it's enabled
on startup, causing the preferences to be tagged as modified.
2024-10-01 15:36:54 +10:00
Campbell Barton
22cdf8da1e Extensions: only apply SSL workaround for Python older than 3.12.6
Skip the workaround for versions of Python that contain the fix.
2024-10-01 13:06:05 +10:00
Mateusz Grzeliński
6822e61c6f Fix #126792: "extension install" sub-command fails to install
Do not report error when local repo does not have manifest and we are
asking for remote repositories.
If the errors list is filled with any error the operation is considered
failure.

Ref: !127360
2024-09-13 16:43:49 +10:00
Campbell Barton
54153629f4 Fix #127329: Keyboard interrupt doesn't work from Python 2024-09-11 14:30:51 +10:00
Andrej730
798fbe7dbd Fix: Typo in extensions repository lock info message
`Fore` -> `Force`

Pull Request: https://projects.blender.org/blender/blender/pulls/126778
2024-08-26 12:28:52 +02:00
Campbell Barton
8a7ff41a85 Cleanup: wrap long lines in Python scripts 2024-08-19 10:48:07 +10:00
Campbell Barton
f8e06a5f5f Fix #125763: Uninitialized extension repos printing warnings on startup
Since [0] missing repository directories printed a warning on startup.

When checking for blocked extensions on startup, skip directories
that don't exist & don't print any warnings if the repository data
hasn't been downloaded.

[0]: 656fe6d3e4
2024-08-06 20:53:41 +10:00
Campbell Barton
fc6a99e0d2 Fix #77837: Error removing addons/extension/wheels on WIN32
When deleting files on WIN32, open files cannot be removed.
This is especially a problem for compiled Python modules which
remain open once imported.

Previously it was not as common for add-ons to include compiled Python
modules however with extensions supporting Python-wheels,
it's increasingly likely users run into this.

Workaround the problem by:
- Scheduling the files for removal next time Blender starts.
- Rename paths that cannot be removed to avoid collisions when
  the paths is reused (re-installing for example).

This is supported for:
- Extensions.
- Python wheels.
- Legacy user add-ons.
- App-templates.

Details:
- On startup, a file exists that indicates cleanup is needed.
  In the common case the file doesn't exist.
  Otherwise module paths are scanned for files to remove.
- Since errors resolving paths to remove could result in user data loss,
  ensure the paths are always within the (extension/addon/app-template)
  directory.
- File locking isn't used, if multiple Blender instances start at the
  same time and try to remove the same files, this won't cause errors.
  Even so, remove the checking file immediately avoid unnecessary
  file-system access overhead for other Blender instances.

Also resolves #125049.
2024-08-05 09:49:14 +10:00
Campbell Barton
805f66c5c4 Extensions: restore fix for removing extensions with symlinks
Regression from [0], removed the fix for #123827.

[0]: 08b75549e3
2024-08-04 20:52:00 +10:00
Campbell Barton
ef505727c6 Fix error where upgrading an extension always enabled it
Upgrading disabled extensions should never enable them.
2024-07-31 13:50:22 +10:00
Campbell Barton
14b03fca3c PyAPI: add bpy.app.python_args, use when calling Python from Blender
Expose arguments to use when creating a Python sub-process.

Python could fail to start when loaded in a customized environment,
with PYTHONPATH set for e.g. Blender ignores these and loads but a
Python sub-process attempts to use these environment variables which
may point to incompatible Python versions.

Resolve the root cause of #124731.
2024-07-31 11:59:23 +10:00
Campbell Barton
3a88af5402 Fix #125660: Extensions fail to sync HTTPS repositories on WIN32
Workaround: `[ASN1] nested asn1 error` error when making HTTPS
connections on systems with certificates that OpenSSL cannot parse
are installed.

This is a general issue with Python, resolve by applying a proposed
fix [0] to the extensions Python process at run-time.
(this doesn't impact Blender's Python run-time).

The down side is HTTPS connections will only work for extensions
on systems with this problem so this needs to be resolved by Python
long term.

While any changes to Python's SSL checks is worth avoiding,
this simply skips SSL certificates in the windows store that OpenSSL
can't parse instead of failing all SSL connections.

See related issues:

- https://github.com/python/cpython/issues/79846
- https://github.com/openssl/openssl/issues/25023

[0]: https://github.com/python/cpython/pull/91740

Ref !124943.
2024-07-30 22:49:21 +10:00
Campbell Barton
656fe6d3e4 Extensions: support "blocklist" in the remote repository
Support blocking extensions so there is a way for the maintainers of
the remote repository to notify the user if one of their installed
extensions blocked along with a reason for blocking.

Blocked extensions cannot be installed from the preferences or by
dropping a URL.

When an installed & blocked extension is found:

- An icon int the status bar shows an alert,
  clicking on the icon shows the blocked extensions.
- The extensions preferences show a warning.
- The extensions & add-ons UI shows an alert icon
  and "details" section shows the reason.

Details:

- Blocked & installed extensions are shown first in the installed
  extensions panel.
- The internal "install" logic prevents downloading & installing
  blocked extensions.
- Blocked extensions can still be downloaded & installed from disk.
- The "list" command includes an error message if any installed
  extensions are blocked.
- The "server-generate" command can optionally take a configuration
  file that includes the blocklist for the generated JSON.

See design #124954.
2024-07-26 16:05:34 +10:00
Campbell Barton
8019ad8912 Fix unhandled exception for non dictionary items in extensions repo
Ensure items in the repository list are dictionaries.
2024-07-26 11:50:26 +10:00
Campbell Barton
8da807684c Fix #122754: Extensions empty when filtering addons in the workspace 2024-07-24 14:09:50 +10:00
Campbell Barton
4cf9f53946 Cleanup: remove unused BUG_ADDON URL preset 2024-07-24 13:35:41 +10:00
Dalai Felinto
13f27ea0ae Fix #122858: Core extensions report bugs to add-on repository
Core extensions should have their bugs reported as any other issue in
Blender.

This PR removes their "Rrport a Bug" link.

I left the link only for glTF since it has its own tracker. But I
wouldn't mind removing it as well.

Ref: !125218
2024-07-24 13:28:48 +10:00
Campbell Barton
1aa37c8df2 Extensions: require 3 numbers for blender_version_{min/max}
When validating the manifest, require 3 numbers to match the official
extensions web-site which expects this.

See #124885.
2024-07-23 17:06:57 +10:00
Campbell Barton
bc2e47622f Extensions: minor wording tweak (v -> version)
Consistent with other errors when the versions mismatch.
2024-07-23 15:59:01 +10:00
Campbell Barton
dc74a98b9e Cleanup: remove unused imports 2024-07-23 15:58:21 +10:00
Campbell Barton
38766fd018 Extensions: tweak wording when dropping an unknown extension
When dropping an extension from extensions.blender.org which is
still in the review queue - an error was shown making it seem like
the extension was not compatible with the system.

Adjust wording to clarify that it was not found in the remote repo
which can be caused by it not being part of the repository or when
it's incompatible.

Resolves #125046.
2024-07-23 15:28:48 +10:00
Campbell Barton
f3a0ecb4e2 Fix #124885: unable to use manifest with "X.X" blender version
Allow `blender_version_{min/max}` to contain 1..3 numbers.
2024-07-23 14:30:15 +10:00
Campbell Barton
68c2c9cb26 Fix #125142: Legacy add-ons don't install when "bl_info" is first
When "bl_info" was on the first line, the legacy add-on would not
install. Correct the check which would also incorrectly detect legacy
add-ons when "bl_info" wasn't found at all.
2024-07-22 13:03:36 +10:00
Campbell Barton
9a568f2227 Fix #124769: Startup notification error with multiple remote repos
Regression in [0] caused extensions checks used the same directory & URL
for all remote repositories when checking for updates on startup.

[0]: d2049f0aa7
2024-07-22 12:07:05 +10:00
Campbell Barton
c7a26cf5c2 Fix #124850: Add-on legacy replacement fails without remote repo data
When the user attempted to install a previously enabled add-on as an
extension after enabling online access and *without* viewing extensions,
installation would fail.

Resolve by adding a check that the remote repository data is available,
adding a button to refresh remote repositories if it's not.
2024-07-17 22:42:16 +10:00
Campbell Barton
b5145d6889 Fix #121469: "Enable Add-on" ignored when already installed
The logic to handle disabling, upgrading & re-enabling extensions
incorrectly assumed all installed add-ons were enabled.

Resolve by only using this logic on installed & enabled add-ons.
2024-07-14 21:14:14 +10:00
Campbell Barton
3358f427dd Fix #124457: Error enabling installed extension after failure to load
When Blender started with an extension enabled from a repository that
referenced a directory that didn't exist - creating the directory
and extensions would fail to import the extension.

This happened because the missing state of the module was cached.

Resolve by clearing Python's path cache for the repository after
running install actions which may have created the directory.

Also run importlib.invalidate_caches() when manually refreshing local
extensions to ensure modules cached as missing can be imported if
they have become available.
2024-07-12 16:22:09 +10:00
Campbell Barton
319684d8f6 Extensions: warn when extensions violate module policies
As each extension has it's own package, any modules it includes must be
imported as sub-modules. Warn if extensions are including themselves
in the sys.path as this breaks name-spacing of extensions.

Show these warnings in the add-on & extensions UI.
2024-07-11 17:50:30 +10:00
Campbell Barton
0bfea7caea Extensions: fix error it tests where the local repo wasn't cleared
Tests interfered with each other because the local repo path wasn't
cleared between different tests.
2024-07-11 17:37:31 +10:00
Campbell Barton
69fd60b41a Extensions: update tests from changes to repo-list 2024-07-11 11:22:30 +10:00
Campbell Barton
0c01a01133 Extensions: add command line "repo-add --access-token" support 2024-07-11 11:06:57 +10:00
Campbell Barton
f59e872b3b Extensions: show "source" & access-token in the repo-list sub-command 2024-07-11 11:06:21 +10:00
Campbell Barton
375b173d67 Extensions: correct help text for the "build" command 2024-07-11 10:18:45 +10:00
Campbell Barton
7ee6451a51 Extensions: support adding system repositories via the command line 2024-07-10 17:39:06 +10:00
Campbell Barton
3a29e25d21 Extensions: expand on the error report when a repository is locked
- Include the repository name.
- Add a hint for force-unlocking the repository.
2024-07-09 20:39:23 +10:00
Campbell Barton
b44d5cb5af Fix unhandled exception when updating legacy add-ons to extensions 2024-07-09 19:45:18 +10:00
Campbell Barton
f4231418e9 Extensions: limit the size of the data read from the lock-file
Avoid reading a large amount of data if the lock file
inexplicably contains large amounts of data.
2024-07-09 19:37:12 +10:00
Campbell Barton
1ffde9338d Extensions: support force unlocking a repository
When the repository is owned by another Blender session,
support removing the file-system lock.

This is accessible from a menu in the repository popover.

This is needed if Blender exits unexpectedly while a repository
is being modified (typically install/upgrade).

Addresses #122135.
2024-07-09 19:27:32 +10:00
Campbell Barton
912194390a Extensions: ensure generated strings in the TOML file are valid
While this wasn't likely to cause any problems in practice,
using the sub-command "build --split-platform" with a platform
containing any characters that need escaping would have produced a TOML
with invalid syntax.

Add a utility function that's guaranteed to create a valid TOML string.
2024-07-09 15:32:09 +10:00
Harley Acheson
987b781412 UI: Various Grammar Changes for Extensions
Various minimal grammar changes in the new Extensions system. For
example changing "Please turn Online Access on the System settings" to
"Please turn Online Access on in the System settings"

Pull Request: https://projects.blender.org/blender/blender/pulls/124262
2024-07-08 19:12:56 +02:00
Sybren A. Stüvel
9d3dc77e05 Anim: move Bone Selection Sets add-on into Blender
The functionality of the Bone Selection Sets add-on is now integrated
into Blender itself. Rigify has been updated to no longer check for the
add-on, but just assume that the functionality is available.

The keymap is still the same, and so are all the class names. This
ensures that there are no conflicts when people still have the old
add-on enabled somehow. And there is versioning code to remove the
'add-on enabled' state so that Blender won't complain it cannot find it
any more.

Compared to the add-on, the following changes are made:

- The 'bone' icon has been removed from the list of available selection
  sets. It was the same for each entry anyway, and thus didn't provide
  any information.
- The code has been split up into multiple files, with the UI elements
  in `scripts/startup/bl_ui/properties_data_armature.py` and the
  operators in `scripts/startup/bl_operators/bone_selection_sets.py`.
- Helper functions and classes are prefixed with `_` to indicate that
  they are not part of any public API.
- The `Operator` helper subclasses have been transformed to mix-in
  classes. This way the only subclasses of `Operator` are the actual
  operators.
- Comments & descriptions have been updated for clarity & consistency.

This commit contains code by the following authors, ordered by number of
commits in the original add-on repository, highest first:

Co-Authored By: Ines Almeida <britalmeida@gmail.com>
Co-Authored By: Sybren A. Stüvel <sybren@stuvel.eu>
Co-Authored By: Campbell Barton <ideasman42@gmail.com>
Co-Authored By: meta-androcto <meta.androcto1@gmail.com>
Co-Authored By: Demeter Dzadik <Mets>
Co-Authored By: lijenstina <lijenstina@gmail.com>
Co-Authored By: Brecht Van Lommel <brechtvanlommel@gmail.com>
Co-Authored By: Aaron Carlisle <carlisle.b3d@gmail.com>

For the full history see the original add-on at:
https://projects.blender.org/blender/blender-addons/commits/branch/main/bone_selection_sets.py

Reviewed On: https://projects.blender.org/blender/blender/pulls/124343
2024-07-08 16:28:42 +02:00
Campbell Barton
9bbf269fe3 Extensions: suppress all pylint warnings & handle add-on errors
- Suppress pylint warnings via comments or be minor changes.
- Any errors disabling add-ons before upgrading or uninstalling are now
  reported to the operators.
- Disable cyclic import warning is it's impractical to resolve.
- Enable useless-suppression warning.
2024-07-08 15:29:27 +10:00
Campbell Barton
05feac04fa Extensions: minor changes to error handling & uninstalling
- Any change that cases validate to fail reports a fatal_error.
- If removing a package fails, attempt to the remove cache.
2024-07-08 13:27:58 +10:00