Commit Graph

322 Commits

Author SHA1 Message Date
Campbell Barton
5e61fbe1c1 Cleanup: correct subtype for extensions operators
Use DIR_PATH for directories.
2025-04-25 10:25:42 +10:00
Campbell Barton
ab5875b2d5 Fix #135979: Extensions refresh does nothing for local repositories
Support refreshing the active repository for "local" repositories.

Co-authored-by: Nika Kutsniashvili <nickberckley@gmail.com>
2025-04-10 15:44:38 +10:00
YimingWu
68a0e68bcd Fix #135999: Extensions: Remove emails in bl_info['author']
Previously when an addon is expanded on the UI, the "Maintainer" string
would be cut short until a `<` character, to prevent showing e-mail on the
UI, however there could be more than one person/email entries in there
so to prevent cutting short the string, now we use regex to take out the
email part only, so full maintainer string is displayed.

Pull Request: https://projects.blender.org/blender/blender/pulls/136031
2025-03-24 07:35:44 +01:00
Campbell Barton
bf3297aefd Correct error accessing current tags in last commit 2025-03-21 16:30:30 +11:00
Campbell Barton
9789dc8426 Fix #132636: Showing updates doesn't show available theme updates
When updates are available, clicking on the button in the status bar
was only showing "Add-on" updates.

Restore the ability to show "All" extension types which is
set when showing updates.
2025-03-21 16:00:33 +11:00
Campbell Barton
302532921f Docs: add docs & code comments for extensions 2025-03-04 15:58:21 +11:00
Campbell Barton
57abd173bb Extensions: remove unused operators
Remove:
- EXTENSIONS_OT_dummy_progress it was mainly useful for development.
- EXTENSIONS_OT_package_enable_not_installed as it's no longer used.
2025-02-26 16:16:54 +11:00
Campbell Barton
900eed683f Extensions: add progress test to "test_cli"
Add a low level test that progress reporting works as expected in
preparation for removing the Blender operator outputting dummy progress.
2025-02-26 16:10:04 +11:00
Campbell Barton
9a11291eea Extensions: add "help" target for the makefile 2025-02-26 15:24:44 +11:00
Campbell Barton
89251ca11e Cleanup: remove "pep8" target from extensions makefile
Also remove file exclusions that no longer exist.
2025-02-26 15:14:05 +11:00
Campbell Barton
fdb8bc837f Cleanup: remove redundant assignment in extensions file dropping logic
The EXTENSIONS_OT_package_install_files instance had its _drop_variables
was temporarily set to True before being storing the extension values.

This value was never read so the assignment can be removed.
2025-02-26 14:22:06 +11:00
Campbell Barton
1ed27184c1 Cleanup: correct Python type hint
The `mypy --strict` command I used for checking wasn't reporting this.
Thanks to Sybren for pointing it out.
2025-02-26 10:53:40 +11:00
Campbell Barton
cd9156bb32 Extensions: use dynamically created link to the manual
The literal URL was used before extensions was included in a release.
2025-02-25 15:14:10 +11:00
Campbell Barton
07340e1093 Docs: add code-comments to clarify bad-level include & developer only UI 2025-02-12 10:59:16 +11:00
Campbell Barton
e9dd4853f6 Fix #131947: Error closing prefs while installing extensions on WIN32
Using `signal.SIGINT` to send a signal to a sub-process isn't supported
on WIN32, replace with `signal.CTRL_BREAK_EVENT`.
2025-02-07 23:07:30 +11:00
Campbell Barton
fb3fe458bf Extensions: forward any errors setting up wheels to reports
When actions on extensions failed setup extensions, errors weren't
forwarded to the user and were only visible in the terminal.
2025-02-07 20:30:02 +11:00
Pablo Vazquez
6ea8297477 Extensions: Quick access to add-on folder
When developing and testing add-ons it can be useful to get to the
folder containing such add-on.

When Developer Extras is enabled, show a folder icon next to the
extension's path to quickly open it using the system file browser.

Also display it in the list of duplicate add-ons, if any, so user can
access them more conveniently.

Pull Request: https://projects.blender.org/blender/blender/pulls/128474
2025-01-30 11:18:53 +01:00
Campbell Barton
89d51c7535 Extensions: add an error when building an add-on without an init file
- Add a check that the file list includes an `__init__.*` path.
- Normalize paths so they can can be compared with string literals.
2025-01-23 15:28:02 +11:00
Campbell Barton
104c655fb7 Refactor: adjust the URL/file-system data iterators for extensions
The logic to generalize over downloading a URL or reading data from
the file-system included static values in the iterator along with the
data being read - so the caller could access the total expected size of
the data being read. While this worked, the result didn't read well.

Now these iterators yield the data being read, a new type has been
added for the caller to read the size hint from.

Also correct invalid doc-string.
2025-01-07 17:51:04 +11:00
Campbell Barton
2f309c10c5 Cleanup: replace Generator type with Iterator where appropriate 2025-01-07 10:10:25 +11:00
Campbell Barton
8a9bdeb943 Extensions: suppress resource leak warning on WIN32
Accessing the internal extensions command would warn that the processes
stdout wasn't closed on completion. While it's harmless at the moment,
ensure it's closed using a context manager.
2025-01-04 19:52:18 +11:00
Campbell Barton
d63dc070ef Fix error enabling extensions with an empty wheel list
Regression in [0] caused extensions with an empty wheel list
to raise an unhandled exception when extracting the Python
version from the wheel list.

Besides resolving this error, account for errors using the wheel
list since it isn't type checked in this code-path.

[0]: cfc10b0232565642afbfdc5a867f027640ce8274
2024-12-02 12:34:31 +11:00
Campbell Barton
b295fc9a9c Extensions: use replace exists with lexists to check a path can be used
Without this, a broken symbolic-link wasn't removed, causing renaming
to fail.
2024-11-29 13:01:03 +11:00
Campbell Barton
5fa0be491e Extensions: suppress noisy prints for extension wheel filtering
These messages could flood the output even when extension installation
succeeded. Only show them when Python debugging is enabled.
2024-11-29 10:27:03 +11:00
Campbell Barton
00255b9421 Correct error printing error in f03fba614d 2024-11-29 10:26:57 +11:00
Campbell Barton
f03fba614d Fix #130211: Unhandled error installing extensions when renaming fails
Add error handling for rare but possible failures on installation.

- Account for the destination extension directory being a file.
- Handle the exception if renaming the temporary directory fails.
2024-11-29 09:56:08 +11:00
Campbell Barton
76f9a08963 Fix failure to reinstall an extension uninstalling the extension
When an extension could could be removed but it's directory could be
renamed, the install operation would fail anyway.

Resolve by completing the installation when the directory can be moved.

Report as part of #129884.
2024-11-28 21:28:30 +11:00
Campbell Barton
d9891aa6ad Fix #130561: incorrect Python compatibility checks for wheels
Regression in [0] caused wheels with an older Python version
that used CPython's stable ABI to be considered incompatible.

Resolve using the stable ABI for version checks.

[0]: cfc10b0232565642afbfdc5a867f027640ce8274
2024-11-27 15:44:58 +11:00
Campbell Barton
093cb8bf43 Extensions: fix building packages containing macos universal wheels 2024-11-26 17:32:11 +11:00
Campbell Barton
64b9dbe198 Tests: correct hard coded version string in extensions test 2024-11-26 17:19:52 +11:00
Campbell Barton
cd07e729a2 Fix #130024: addon_utils.enable(..) doesn't setup extensions wheels
addon_utils.enable/disable now handle wheels so that the functions can
be used with extension add-ons.

A new argument `refresh_handled` supports scripts handing refresh
themselves which is needed to avoid refreshing many times in cases
when there are multiple calls to enable/disable.

This is mostly useful for internal operations.
2024-11-09 11:44:34 +11:00
Campbell Barton
08693d05c1 Fix missing wheel refresh after updating extensions
Applying all available updates wasn't re-synchronizing wheels.
2024-11-09 00:41:23 +11:00
Campbell Barton
ec22e967ad Fix error installing extensions with wheels
Error in [0] caused versions not to match when enabling
extensions after installation or upgrade.

[0]: a3a3dda563
2024-11-09 00:41:21 +11:00
Campbell Barton
67865cb73a Tests: add tests to ensure literal paths are properly handled
Add tests to ensure literal paths are handled properly
(created as part of the fix for #129724).
2024-11-08 16:08:38 +11:00
Campbell Barton
4be66511de Extensions: quote paths in error messages, improve missing file error 2024-11-08 16:08:38 +11:00
Campbell Barton
ae5f5c5bca Fix #129724: building extensions fails with non empty paths 2024-11-08 16:08:38 +11:00
Campbell Barton
a3a3dda563 Extensions: support for filtering based on Python versions
Support multiple extensions with different Python versions in a similar
way to how "platforms" are handled now.

This will be needed when Blender upgrades to a newer version of Python
so extensions which have a binary dependency on Python 3.11 don't
attempt to install in a Blender built with a newer Python version.

Details:

- Extensions from incompatible Python versions are not listed.
- Python versions are extracted from wheel names.
- An extension may include wheels for multiple Python versions,
  only the compatible wheels will be installed.
- Links may include a "python_versions" field which is checked
  when dropping into Blender.
- JSON generated by the "server-generate" command include the:
  "python_versions" field for extensions that include wheels.
- The "python_versions" field is optional, when omitted no version
  checks are performed.

Also correct watch_test make target.

Ref #128750.
2024-11-07 18:16:11 +11:00
Campbell Barton
3d76e43e4a Extensions: exclude "wheels" from the static JSON package listing
While relatively harmless, it's unnecessary bloat.
2024-11-06 11:47:51 +11:00
Campbell Barton
e3e6dd8fdb Fix #125958: Disable/uninstall an add-on can keep its dependencies
Python wheels from extensions were not being removed after
install/uninstall in some cases - although installing an extension
afterwards that used wheels would recalculate deps & remove them.

- Installing an extension didn't include the extension in the
  compatibility-cache, causing uninstalling not to remove deps.
- Uninstalling an extension wasn't re-calculating the deps,
  leaving them as-is.

Always write the compatibility-cache after installing and uninstalling
so changes are detected & handled.
2024-10-24 20:53:07 +11:00
Campbell Barton
21457db162 Cleanup: remove deprecated typing use for extensions utility
Also replace some uses of Generator with Iterator.
2024-10-23 15:44:06 +11:00
Campbell Barton
f4f50fa2c5 Cleanup: replace typing.Union/Option with logical OR for extensions
Also remove use of deprecated typing.Sequence.
2024-10-18 10:08:12 +11:00
Campbell Barton
a66601ee95 Cleanup: remove deprecated typing built-ins for extension logic
Deprecated since Python 3.9 but still used in many docs/examples.
2024-10-17 19:11:40 +11:00
Campbell Barton
3f7e14295f Cleanup: format 2024-10-11 11:00:24 +11:00
YimingWu
87f227ef7a 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 21:15:33 +08: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
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