fix: support AstrBot host package imports
这个提交存在于:
父节点
82d2519bb5
当前提交
96813f0048
共有 6 个文件被更改,包括 32 次插入 和 6 次删除
|
|
@ -1,7 +1,7 @@
|
|||
plugin:
|
||||
name: astrbot_plugin_imagestudio
|
||||
display_name: ImageStudio
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
|
||||
features:
|
||||
quick_profile: true
|
||||
|
|
|
|||
4
frontend/package-lock.json
自动生成
4
frontend/package-lock.json
自动生成
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "astrbot-plugin-imagestudio-frontend",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "astrbot-plugin-imagestudio-frontend",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"dependencies": {
|
||||
"@vitejs/plugin-vue": "^5.2.0",
|
||||
"pinia": "^2.3.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "astrbot-plugin-imagestudio-frontend",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
28
main.py
28
main.py
|
|
@ -23,6 +23,32 @@ if str(PLUGIN_ROOT) not in sys.path:
|
|||
# AstrBot may import the plugin entrypoint without adding the plugin root.
|
||||
sys.path.insert(0, str(PLUGIN_ROOT))
|
||||
|
||||
|
||||
def _prepend_plugin_package_path(package_name: str) -> None:
|
||||
"""Let absolute legacy imports resolve inside the plugin package.
|
||||
|
||||
AstrBot itself may already have imported a top-level package named
|
||||
``core``. In that case, merely adding the plugin root to ``sys.path`` is
|
||||
insufficient because Python reuses the existing package from
|
||||
``sys.modules``. Prepending our package directory to that package's
|
||||
search path keeps the host package intact while allowing imports such as
|
||||
``core.config_service`` to resolve to ImageStudio's implementation.
|
||||
"""
|
||||
|
||||
package_dir = PLUGIN_ROOT / package_name
|
||||
loaded_package = sys.modules.get(package_name)
|
||||
search_path = getattr(loaded_package, "__path__", None)
|
||||
if search_path is None or not package_dir.is_dir():
|
||||
return
|
||||
package_path = str(package_dir)
|
||||
if package_path in search_path:
|
||||
search_path.remove(package_path)
|
||||
search_path.insert(0, package_path)
|
||||
|
||||
|
||||
for _package_name in ("core", "adapters", "backend", "database", "engines"):
|
||||
_prepend_plugin_package_path(_package_name)
|
||||
|
||||
from adapters.astrbot_adapter import (
|
||||
dispatch_extension_request,
|
||||
normalize_extension_path,
|
||||
|
|
@ -72,7 +98,7 @@ load_database_settings = _database_db_helper.load_database_settings
|
|||
|
||||
PLUGIN_NAME = "astrbot_plugin_imagestudio"
|
||||
PLUGIN_DESC = "AstrBot ImageStudio role asset production and image-generation workspace."
|
||||
PLUGIN_VERSION = "3.1.0"
|
||||
PLUGIN_VERSION = "1.0.1"
|
||||
BRIDGE_PERMISSIONS = frozenset(
|
||||
{"can_write", "can_manage_config", "can_manage_materials", "can_retry_tasks"}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ name: astrbot_plugin_imagestudio
|
|||
display_name: ImageStudio
|
||||
desc: AstrBot >=4.25 ImageStudio role asset and image-generation workspace for Windows, Linux, macOS and Docker.
|
||||
short_desc: AstrBot 内的角色资产、工作流与图片生成管理工作台。
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
author: YokiiroBW
|
||||
repo: "http://192.168.31.210:18085/YokiiroBW/astrbot_plugin_imagestudio"
|
||||
astrbot_version: ">=4.25.0,<5"
|
||||
|
|
|
|||
二进制文件未显示。
正在加载…
添加表格
在新工单中引用