mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
utils/scanpypi: restore modules search path in case of error
We extend the modules search path to be able to load the package metadata. Currently, it is only restored when loading those succeeded, not when it failed. Restore it to its previous state also in case of error, to avoid leaking the path further. Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
committed by
Yann E. MORIN
parent
dbfc9f9f67
commit
69400611b2
@@ -296,6 +296,7 @@ class BuildrootPackage():
|
|||||||
current_dir = os.getcwd()
|
current_dir = os.getcwd()
|
||||||
os.chdir(self.tmp_extract)
|
os.chdir(self.tmp_extract)
|
||||||
sys.path.insert(0, self.tmp_extract)
|
sys.path.insert(0, self.tmp_extract)
|
||||||
|
try:
|
||||||
s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
|
s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
|
||||||
imp.load_module('__main__', s_file, s_path, s_desc)
|
imp.load_module('__main__', s_file, s_path, s_desc)
|
||||||
if self.metadata_name in self.setup_args:
|
if self.metadata_name in self.setup_args:
|
||||||
@@ -311,6 +312,7 @@ class BuildrootPackage():
|
|||||||
print('ERROR: Could not determine package metadata for {pkg}.\n'
|
print('ERROR: Could not determine package metadata for {pkg}.\n'
|
||||||
.format(pkg=self.real_name))
|
.format(pkg=self.real_name))
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
os.chdir(current_dir)
|
os.chdir(current_dir)
|
||||||
sys.path.remove(self.tmp_extract)
|
sys.path.remove(self.tmp_extract)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user