mirror of
https://github.com/blender/blender
synced 2026-11-22 03:45:13 +03:00
An extension can define a remote asset library, added to the preferences when installed. This allows asset libraries to be distributed & updated using the extensions system, optionally sharing the repository's access token. UI: - Dropping a ZIP file into Blender installs & enables the extension with its asset library. - The preferences group libraries under the repository which defines them (collapsible, with a new "extension" icon), showing the access token when it's inherited. Their name & URL are read-only, uninstall the extension to remove them. - The asset library menus are grouped by owner (user, project & extension). - "View Details" in the extension menu switches to the asset view and selects the library in the preferences. - "View Extension..." from the asset context menu shows the extension from the asset listing, so it's possible to look up the extension from any asset. CLI: - Building & installing asset-library extensions, writing the preferences when a library is registered. - `server-generate --assetlib-auth-method=FROM_REPOSITORY` sets `assetlib_auth_method` in the listing, sharing the repository's access token with the asset libraries of its extensions. `PER_LIBRARY` (the default) leaves each library to authenticate on its own. - A new `repo-info` sub-command shows high level repository information, including this method. Python API: - `asset_libraries.new()` supports remote & extension defined libraries. - `UserAssetLibrary.extension_id` exposes the defining extension. - `asset_libraries.active` is the library shown in the preferences. - `UserAssetLibrary.is_available()` has been added which checks the library is both enabled and it's extension repository is enabled (if it's from an extension). - `AssetLibrary.user_library` is exposed to support "View Extensions". Tests: - `test_cli`: `repo-info` & the listings authentication method. - `test_cli_blender`: building, validating & installing asset-library extensions. - `test_blender_asset_auth`: syncing a repository & downloading an asset listing which require a token, checking which libraries resolve the repository's token under each authentication method. Details: - The manifest supports `type = "asset-library"` with an `[asset_library]` table defining the `remote_url`, optionally `[asset_library.auth]` declaring `auth_method = "TOKEN"` & whether a token is `required`. - Only the `scripts` permission applies to asset libraries. - Installing adds the library, uninstalling removes it, upgrading applies the name & URL from the manifest. Enabling & disabling the extension toggles the library's "enabled" setting, keeping its entry so it can be enabled again. - The extensions access token is forwarded when downloading the listing, assets & previews. - Libraries are synchronized on startup, following extensions installed or removed by other Blender instances, as well as repositories renamed or removed. - Disabling a repository doesn't change the "enabled" setting of its libraries, instead their is_available() method returns false, they're not available until the repository is enabled again, similar to add-ons. Ref !162621
224 lines
5.9 KiB
Makefile
224 lines
5.9 KiB
Makefile
# SPDX-FileCopyrightText: 2011-2023 Blender Authors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
# note: this isn't needed for building,
|
|
# its just for some convenience targets.
|
|
|
|
define HELP_TEXT
|
|
Checkers:
|
|
|
|
- check_mypy, watch_check_mypy
|
|
Runs the mypy checker, optionally watching files & re-running.
|
|
|
|
- check_ruff, watch_check_ruff
|
|
Runs the ruff checker, optionally watching files & re-running.
|
|
|
|
- check_pylint, watch_check_pylint
|
|
Runs the pylint checker, optionally watching files & re-running.
|
|
|
|
- check_flake8, watch_check_flake8
|
|
|
|
|
|
Tests:
|
|
|
|
- test, watch_test
|
|
Runs all tests listed below.
|
|
|
|
- test_cli
|
|
Test the command line program, "blender_ext.py" Blender is not used.
|
|
|
|
- test_blender
|
|
Test blender (currently only some limited tests).
|
|
|
|
- test_cli_blender
|
|
Runs tests that access & manipulate extensions via the command line.
|
|
|
|
- test_blender_asset_auth
|
|
Runs tests for authenticating asset libraries provided by extensions.
|
|
|
|
|
|
Environment Variables:
|
|
|
|
- BLENDER_BIN
|
|
The command used to run Blender, defaults to "blender"
|
|
|
|
- PYTHON_BIN
|
|
The command used to run PYthon, defaults to "python3"
|
|
|
|
endef
|
|
# HELP_TEXT (end)
|
|
|
|
# Needed for when tests are run from another directory: `make -C ./scripts/addons_core`
|
|
BASE_DIR := ${CURDIR}
|
|
|
|
PY_FILES=$(shell find ./ -type f -name '*.py')
|
|
# Filter out files which use `bpy`.
|
|
PY_FILES_MYPY=$(filter-out \
|
|
./__init__.py \
|
|
./bl_extension_cli.py \
|
|
./bl_extension_monkeypatch.py \
|
|
./bl_extension_notify.py \
|
|
./bl_extension_ops.py \
|
|
./bl_extension_ui.py \
|
|
./bl_extension_utils.py \
|
|
./extensions_map_from_legacy_addons.py \
|
|
./example_extension/__init__.py \
|
|
,$(PY_FILES))
|
|
|
|
PY_FILES_MYPY_STANDALONE= \
|
|
./bl_extension_utils.py \
|
|
./bl_extension_cli.py
|
|
|
|
EXTRA_WATCH_FILES=Makefile
|
|
|
|
# For tests that launch Blender directly.
|
|
BLENDER_BIN?=$(shell which blender)
|
|
PYTHON_BIN?=$(shell which python3)
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Help for build targets
|
|
|
|
export HELP_TEXT
|
|
help: FORCE
|
|
@echo "$$HELP_TEXT"
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Checking Utilities
|
|
|
|
# `--no-namespace-packages` is needed otherwise `./cli/blender_ext.py` loads in parent modules
|
|
# (the Blender add-on which imports `bpy`).
|
|
check_mypy: FORCE
|
|
@mypy --no-namespace-packages --strict $(PY_FILES_MYPY)
|
|
@mypy --strict --follow-imports=skip $(PY_FILES_MYPY_STANDALONE)
|
|
watch_check_mypy:
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) check_mypy; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
|
|
$(PY_FILES_MYPY) \
|
|
./bl_extension_utils.py ; \
|
|
tput clear; \
|
|
done
|
|
|
|
check_ruff: FORCE
|
|
@cd "$(BASE_DIR)" && ruff check $(PY_FILES_MYPY)
|
|
@cd "$(BASE_DIR)" && ruff check $(PY_FILES_MYPY_STANDALONE)
|
|
watch_check_ruff:
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) check_ruff; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
|
|
$(PY_FILES_MYPY) \
|
|
./bl_extension_utils.py ; \
|
|
tput clear; \
|
|
done
|
|
|
|
check_pylint:
|
|
@cd "$(BASE_DIR)" && \
|
|
pylint $(PY_FILES) \
|
|
--enable=useless-suppression \
|
|
--disable=C0103,C0111,C0201,C0301,C0302,C0415,R0401,R1702,R1705,R0902,R0903,R0913,E0611,E0401,I1101,R0801,C0209,W0511,W0718,W0719,C0413,R0911,R0912,R0914,R0915 \
|
|
--msg-template='{abspath}:{line}:{column}: {msg_id}: {msg} ({symbol})'
|
|
watch_check_pylint:
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) check_pylint; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Tests (All)
|
|
|
|
test: FORCE
|
|
@$(MAKE) -C "$(BASE_DIR)" test_cli;
|
|
@$(MAKE) -C "$(BASE_DIR)" test_blender;
|
|
@$(MAKE) -C "$(BASE_DIR)" test_cli_blender;
|
|
@$(MAKE) -C "$(BASE_DIR)" test_blender_asset_auth;
|
|
@$(MAKE) -C "$(BASE_DIR)" test_path_pattern_match;
|
|
watch_test: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) test; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Tests (Individual)
|
|
|
|
# python3 ./tests/test_cli.py
|
|
test_cli: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
USE_HTTP=0 \
|
|
$(PYTHON_BIN) ./tests/test_cli.py
|
|
@cd "$(BASE_DIR)" && \
|
|
USE_HTTP=1 \
|
|
$(PYTHON_BIN) ./tests/test_cli.py
|
|
watch_test_cli: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) test_cli; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
|
|
# NOTE: these rely on the blender binary.
|
|
test_blender: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
ASAN_OPTIONS=check_initialization_order=0:leak_check_at_exit=0 \
|
|
$(BLENDER_BIN) \
|
|
--background --factory-startup --online-mode -noaudio \
|
|
--python ./tests/test_blender.py -- --verbose
|
|
watch_test_blender: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) test_blender; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
test_cli_blender: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
env BLENDER_BIN=$(BLENDER_BIN) \
|
|
$(PYTHON_BIN) ./tests/test_cli_blender.py
|
|
watch_test_cli_blender: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
env BLENDER_BIN=$(BLENDER_BIN) \
|
|
$(MAKE) test_cli_blender; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
test_blender_asset_auth: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
env BLENDER_BIN=$(BLENDER_BIN) \
|
|
$(PYTHON_BIN) ./tests/test_blender_asset_auth.py
|
|
watch_test_blender_asset_auth: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
env BLENDER_BIN=$(BLENDER_BIN) \
|
|
$(MAKE) test_blender_asset_auth; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
test_path_pattern_match: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
$(PYTHON_BIN) ./tests/test_path_pattern_match.py
|
|
watch_test_path_pattern_match: FORCE
|
|
@cd "$(BASE_DIR)" && \
|
|
while true; do \
|
|
$(MAKE) test_path_pattern_match; \
|
|
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
|
|
tput clear; \
|
|
done
|
|
|
|
FORCE:
|