From 7cb9d80af656e7a4abbb75c43b3ce669f86d0143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu> Date: Tue, 23 May 2017 12:21:32 +0200 Subject: [PATCH] Fix bad import of Rigify legacy modules There is an issue with the construction of module names. Since there is no top-level module "legacy", the `"legacy.%s.%s" % (RIG_DIR, rig_type)` construct fails. Without these fixes, a unittest fails: Start testing: May 23 12:19 CEST ---------------------------------------------------------- 3/18 Testing: script_load_modules 3/18 Test: script_load_modules Command: "/home/sybren/workspace/blender-git/build_linux/bin/blender" "--background" "-noaudio" "--factory-startup" "--env-system-scripts" "/home/sybren/workspace/blender-git/blender/release/scripts" "--python" "/home/sybren/workspace/blender-git/blender/tests/python/bl_load_py_modules.py" Directory: /home/sybren/workspace/blender-git/build_linux/tests/python "script_load_modules" start time: May 23 12:19 CEST Output: ---------------------------------------------------------- Traceback (most recent call last): File "/home/sybren/workspace/blender-git/blender/tests/python/bl_load_py_modules.py", line 231, in <module> main() File "/home/sybren/workspace/blender-git/blender/tests/python/bl_load_py_modules.py", line 226, in main load_modules() File "/home/sybren/workspace/blender-git/blender/tests/python/bl_load_py_modules.py", line 178, in load_modules __import__(mod_name_full) File "/home/sybren/workspace/blender-git/build_linux/bin/release/scripts/addons/rigify/legacy/__init__.py", line 42, in <module> from . import utils, rig_lists, generate, ui, metarig_menu File "/home/sybren/workspace/blender-git/build_linux/bin/release/scripts/addons/rigify/legacy/rig_lists.py", line 76, in <module> rig_list = get_rig_list("") File "/home/sybren/workspace/blender-git/build_linux/bin/release/scripts/addons/rigify/legacy/rig_lists.py", line 47, in get_rig_list rig = utils.get_rig_type(module_name) File "/home/sybren/workspace/blender-git/build_linux/bin/release/scripts/addons/rigify/legacy/utils.py", line 702, in get_rig_type submod = importlib.import_module(name, package=MODULE_NAME) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named 'legacy' Warning! '/home/sybren/.config/blender/2.78/scripts/startup/pillarsdk/__init__.py' has no register function, this is now a requirement for registerable scripts archimesh: Imported multifiles measureit: Imported multifiles Paths: '/home/sybren/workspace/blender-git/build_linux/bin/release/scripts/modules' '/home/sybren/workspace/blender-git/build_linux/bin/release/scripts' '/home/sybren/.config/blender/2.78/scripts' MeasureIt: Cleaning data ++++++++++++++++++++++++++++++ MeasureIt: Cleaning data Error: Not freed memory blocks: 1, total unfreed memory 0.000214 MB <end of output> Test time = 0.87 sec ---------------------------------------------------------- Test Failed. "script_load_modules" end time: May 23 12:19 CEST "script_load_modules" time elapsed: 00:00:00 ---------------------------------------------------------- End testing: May 23 12:19 CEST --- rigify/legacy/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rigify/legacy/utils.py b/rigify/legacy/utils.py index 57464f9de..65838b7d7 100644 --- a/rigify/legacy/utils.py +++ b/rigify/legacy/utils.py @@ -698,7 +698,7 @@ def copy_attributes(a, b): def get_rig_type(rig_type): """ Fetches a rig module by name, and returns it. """ - name = "legacy.%s.%s" % (RIG_DIR, rig_type) + name = "rigify.legacy.%s.%s" % (RIG_DIR, rig_type) submod = importlib.import_module(name, package=MODULE_NAME) importlib.reload(submod) return submod @@ -707,7 +707,7 @@ def get_rig_type(rig_type): def get_metarig_module(metarig_name): """ Fetches a rig module by name, and returns it. """ - name = "legacy.%s.%s" % (METARIG_DIR, metarig_name) + name = "rigify.legacy.%s.%s" % (METARIG_DIR, metarig_name) submod = importlib.import_module(name, package=MODULE_NAME) importlib.reload(submod) return submod -- GitLab