Skip to content
Snippets Groups Projects
Commit 7cb9d80a authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

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
parent cfa95732
Branches
Tags
No related merge requests found
...@@ -698,7 +698,7 @@ def copy_attributes(a, b): ...@@ -698,7 +698,7 @@ def copy_attributes(a, b):
def get_rig_type(rig_type): def get_rig_type(rig_type):
""" Fetches a rig module by name, and returns it. """ 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) submod = importlib.import_module(name, package=MODULE_NAME)
importlib.reload(submod) importlib.reload(submod)
return submod return submod
...@@ -707,7 +707,7 @@ def get_rig_type(rig_type): ...@@ -707,7 +707,7 @@ def get_rig_type(rig_type):
def get_metarig_module(metarig_name): def get_metarig_module(metarig_name):
""" Fetches a rig module by name, and returns it. """ 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) submod = importlib.import_module(name, package=MODULE_NAME)
importlib.reload(submod) importlib.reload(submod)
return submod return submod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment