diff --git a/scripts/addons_core/bl_pkg/__init__.py b/scripts/addons_core/bl_pkg/__init__.py index 827bc69e201..9fc4317fcc6 100644 --- a/scripts/addons_core/bl_pkg/__init__.py +++ b/scripts/addons_core/bl_pkg/__init__.py @@ -39,14 +39,12 @@ def _local_module_reload(): import importlib from . import ( bl_extension_cli, - bl_extension_local, bl_extension_notify, bl_extension_ops, bl_extension_ui, bl_extension_utils, ) importlib.reload(bl_extension_cli) - importlib.reload(bl_extension_local) importlib.reload(bl_extension_notify) importlib.reload(bl_extension_ops) importlib.reload(bl_extension_ui) diff --git a/scripts/addons_core/bl_pkg/bl_extension_local.py b/scripts/addons_core/bl_pkg/bl_extension_local.py deleted file mode 100644 index 75fed97bc63..00000000000 --- a/scripts/addons_core/bl_pkg/bl_extension_local.py +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Blender Foundation -# -# SPDX-License-Identifier: GPL-2.0-or-later - -""" -High level API for managing an extension local site-packages and wheels. - -NOTE: this is a standalone module. -""" - -__all__ = ( - "sync", -) - - -import os -import sys - -from typing import ( - List, -) - -from .wheel_manager import WheelSource - - -def sync( - *, - local_dir: str, - wheel_list: List[WheelSource], -) -> None: - from . import wheel_manager - local_dir_site_packages = os.path.join( - local_dir, - "lib", - "python{:d}.{:d}".format(sys.version_info.major, sys.version_info.minor), - "site-packages", - ) - - wheel_manager.apply_action( - local_dir=local_dir, - local_dir_site_packages=local_dir_site_packages, - wheel_list=wheel_list, - ) - if os.path.exists(local_dir_site_packages): - if local_dir_site_packages not in sys.path: - sys.path.append(local_dir_site_packages) diff --git a/scripts/addons_core/bl_pkg/bl_extension_ops.py b/scripts/addons_core/bl_pkg/bl_extension_ops.py index ba5487a9c3e..d5c5565dc23 100644 --- a/scripts/addons_core/bl_pkg/bl_extension_ops.py +++ b/scripts/addons_core/bl_pkg/bl_extension_ops.py @@ -824,7 +824,7 @@ def _extensions_repo_sync_wheels(repo_cache_store): This function collects all wheels from all packages and ensures the packages are either extracted or removed when they are no longer used. """ - from .bl_extension_local import sync + import addon_utils repos_all = extension_repos_read() @@ -864,7 +864,8 @@ def _extensions_repo_sync_wheels(repo_cache_store): extensions = bpy.utils.user_resource('EXTENSIONS') local_dir = os.path.join(extensions, ".local") - sync( + # WARNING: bad level call, avoid making this a public function just now. + addon_utils._extension_sync_wheels( local_dir=local_dir, wheel_list=wheel_list, ) diff --git a/scripts/addons_core/bl_pkg/wheel_manager.py b/scripts/modules/_bpy_internal/extensions/wheel_manager.py similarity index 100% rename from scripts/addons_core/bl_pkg/wheel_manager.py rename to scripts/modules/_bpy_internal/extensions/wheel_manager.py diff --git a/scripts/modules/addon_utils.py b/scripts/modules/addon_utils.py index 860538e50d4..c064ab6f71a 100644 --- a/scripts/modules/addon_utils.py +++ b/scripts/modules/addon_utils.py @@ -765,6 +765,32 @@ def _fake_module_from_extension(mod_name, mod_path): return mod +def _extension_sync_wheels( + *, + local_dir, # `str` + wheel_list, # `List[WheelSource]` +): # `-> None` + import os + import sys + from _bpy_internal.extensions.wheel_manager import apply_action + + local_dir_site_packages = os.path.join( + local_dir, + "lib", + "python{:d}.{:d}".format(*sys.version_info[0:2]), + "site-packages", + ) + + apply_action( + local_dir=local_dir, + local_dir_site_packages=local_dir_site_packages, + wheel_list=wheel_list, + ) + if os.path.exists(local_dir_site_packages): + if local_dir_site_packages not in sys.path: + sys.path.append(local_dir_site_packages) + + # ----------------------------------------------------------------------------- # Extensions diff --git a/tools/check_source/check_mypy_config.py b/tools/check_source/check_mypy_config.py index 4c6a74f8ac6..4fb311f66e3 100644 --- a/tools/check_source/check_mypy_config.py +++ b/tools/check_source/check_mypy_config.py @@ -14,6 +14,9 @@ PATHS: Tuple[Tuple[str, Tuple[Any, ...], Dict[str, str]], ...] = ( ("build_files/utils/", (), {'MYPYPATH': "modules"}), ("doc/manpage/blender.1.py", (), {}), ("release/datafiles/", (), {}), + ("scripts/modules/_bpy_internal/extensions/junction_module.py", (), {}), + ("scripts/modules/_bpy_internal/extensions/wheel_manager.py", (), {}), + ("scripts/modules/_bpy_internal/freedesktop.py", (), {}), ("tools/check_blender_release/", (), {}), ("tools/check_docs/", (), {}), ("tools/check_source/", (), {'MYPYPATH': "modules"}),