mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Pass module name and set __file__ on module to avoid AttributeErrors saying module has no __file__ attribute
This commit is contained in:
parent
574f8d2c6d
commit
c41a3b1cb8
2 changed files with 2 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ def import_filepath(filepath, module_name=None):
|
|||
|
||||
# Prepare module object where content of file will be parsed
|
||||
module = types.ModuleType(module_name)
|
||||
module.__file__ = filepath
|
||||
|
||||
if six.PY3:
|
||||
# Use loader so module has full specs
|
||||
|
|
@ -41,7 +42,6 @@ def import_filepath(filepath, module_name=None):
|
|||
# Execute content and store it to module object
|
||||
six.exec_(_stream.read(), module.__dict__)
|
||||
|
||||
module.__file__ = filepath
|
||||
return module
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ def publish_plugins_discover(paths=None):
|
|||
continue
|
||||
|
||||
try:
|
||||
module = import_filepath(abspath)
|
||||
module = import_filepath(abspath, mod_name)
|
||||
|
||||
# Store reference to original module, to avoid
|
||||
# garbage collection from collecting it's global
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue