Better output on errors.
This commit is contained in:
parent
03383c48eb
commit
60b6652006
@ -106,18 +106,28 @@ def get_lib_path(executable, name, required=True):
|
|||||||
code = [
|
code = [
|
||||||
'try:',
|
'try:',
|
||||||
' import {}'.format(name),
|
' import {}'.format(name),
|
||||||
'except ImportError:',
|
'except ImportError as e:',
|
||||||
' print("")',
|
' print("ImportError: " + str(e))',
|
||||||
'else:',
|
'else:',
|
||||||
' print({}.__file__)'.format(name)
|
' print("path: " + {}.__file__)'.format(name)
|
||||||
]
|
]
|
||||||
path = run_py(executable, *code)
|
output = run_py(executable, *code)
|
||||||
if path:
|
|
||||||
return path
|
try:
|
||||||
elif required:
|
prefix, data = output.split(': ')
|
||||||
raise Error("Did not find {} with {}!".format(name, executable))
|
except ValueError:
|
||||||
|
raise ValueError("Unexpected output: {!r}".format(output))
|
||||||
|
|
||||||
|
if prefix == 'path':
|
||||||
|
return data
|
||||||
|
elif prefix == 'ImportError':
|
||||||
|
if required:
|
||||||
|
raise Error("Could not import {} with {}: {}!".format(
|
||||||
|
name, executable, data))
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
else:
|
||||||
|
raise ValueError("Unexpected output: {!r}".format(output))
|
||||||
|
|
||||||
|
|
||||||
def link_pyqt(executable, venv_path):
|
def link_pyqt(executable, venv_path):
|
||||||
|
Loading…
Reference in New Issue
Block a user