mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #20843 from matdrapeau/16556/ImportError_custom_dep
Adding current module directory to the sys.path when loading a module
This commit is contained in:
commit
90994722f0
@ -895,6 +895,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
||||
fpath, suffix = self.file_mapping[name]
|
||||
self.loaded_files.append(name)
|
||||
try:
|
||||
sys.path.append(os.path.dirname(fpath))
|
||||
if suffix == '.pyx':
|
||||
mod = self.pyximport.load_module(name, fpath, tempfile.gettempdir())
|
||||
else:
|
||||
@ -948,6 +949,8 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
||||
exc_info=True
|
||||
)
|
||||
return mod
|
||||
finally:
|
||||
sys.path.pop()
|
||||
|
||||
if hasattr(mod, '__opts__'):
|
||||
mod.__opts__.update(self.opts)
|
||||
|
Loading…
Reference in New Issue
Block a user