Permalink
Browse files

deploy-ng: Fix for finding Python extension modules when not running …

…the frozen binary in the binary's directory
  • Loading branch information...
Moguri committed Aug 20, 2017
1 parent 894fe56 commit dcef0c3c5d08f2a21370ea3ec5518a6b08b0246b
Showing with 2 additions and 1 deletion.
  1. +2 −1 direct/src/showutil/FreezeTool.py
@@ -1658,7 +1658,8 @@ def make_forbidden_module_list_entry(modulename):
# trouble importing it as a builtin module. Synthesize a frozen
# module that loads it dynamically.
if '.' in moduleName:
code = compile('import sys;del sys.modules["%s"];import imp;imp.load_dynamic("%s", "%s%s")' % (moduleName, moduleName, moduleName, modext), moduleName, 'exec')
code = 'import sys;import os;del sys.modules["%s"];import imp;imp.load_dynamic("%s",os.path.join(os.path.dirname(sys.executable), "%s%s"))' % (moduleName, moduleName, moduleName, modext)
code = compile(code, moduleName, 'exec')
code = marshal.dumps(code)
moduleList.append(make_module_list_entry(code, codeOffset, moduleName, module))
moduleBlob += code

0 comments on commit dcef0c3

Please sign in to comment.