kopia lustrzana https://github.com/micropython/micropython-lib
Merge 7657232b7c
into 913498ef05
commit
f5d46df8cc
|
@ -168,6 +168,12 @@ def _install_package(package, index, target, version, mpy):
|
||||||
return _install_json(package, index, target, version, mpy)
|
return _install_json(package, index, target, version, mpy)
|
||||||
|
|
||||||
|
|
||||||
|
class InstallError(RuntimeError):
|
||||||
|
"""
|
||||||
|
Raised when an installation fails.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def install(package, index=None, target=None, version=None, mpy=True):
|
def install(package, index=None, target=None, version=None, mpy=True):
|
||||||
if not target:
|
if not target:
|
||||||
for p in sys.path:
|
for p in sys.path:
|
||||||
|
@ -175,8 +181,7 @@ def install(package, index=None, target=None, version=None, mpy=True):
|
||||||
target = p
|
target = p
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("Unable to find lib dir in sys.path")
|
raise InstallError("Unable to find lib dir in sys.path")
|
||||||
return
|
|
||||||
|
|
||||||
if not index:
|
if not index:
|
||||||
index = _PACKAGE_INDEX
|
index = _PACKAGE_INDEX
|
||||||
|
@ -184,4 +189,4 @@ def install(package, index=None, target=None, version=None, mpy=True):
|
||||||
if _install_package(package, index.rstrip("/"), target, version, mpy):
|
if _install_package(package, index.rstrip("/"), target, version, mpy):
|
||||||
print("Done")
|
print("Done")
|
||||||
else:
|
else:
|
||||||
print("Package may be partially installed")
|
raise InstallError("Package may be partially installed")
|
||||||
|
|
Ładowanie…
Reference in New Issue