kopia lustrzana https://github.com/micropython/micropython-lib
upip: Factor out install() function.
rodzic
ce843f3ffc
commit
c1bfa36dbf
43
upip/upip.py
43
upip/upip.py
|
@ -155,6 +155,28 @@ def install_pkg(pkg_spec, install_path):
|
||||||
f1.close()
|
f1.close()
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
def install(to_install, install_path):
|
||||||
|
# sets would be perfect here, but don't depend on them
|
||||||
|
installed = []
|
||||||
|
try:
|
||||||
|
while to_install:
|
||||||
|
if debug:
|
||||||
|
print("Queue:", to_install)
|
||||||
|
pkg_spec = to_install.pop(0)
|
||||||
|
if pkg_spec in installed:
|
||||||
|
continue
|
||||||
|
meta = install_pkg(pkg_spec, install_path)
|
||||||
|
installed.append(pkg_spec)
|
||||||
|
if debug:
|
||||||
|
print(meta)
|
||||||
|
deps = meta.get("deps", "").rstrip()
|
||||||
|
if deps:
|
||||||
|
deps = deps.decode("utf-8").split("\n")
|
||||||
|
to_install.extend(deps)
|
||||||
|
except NotFoundError:
|
||||||
|
print("Error: cannot find '%s' package (or server error), packages may be partially installed" \
|
||||||
|
% pkg_spec, file=sys.stderr)
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
for fname in cleanup_files:
|
for fname in cleanup_files:
|
||||||
try:
|
try:
|
||||||
|
@ -224,26 +246,7 @@ def main():
|
||||||
if not to_install:
|
if not to_install:
|
||||||
help()
|
help()
|
||||||
|
|
||||||
# sets would be perfect here, but don't depend on them
|
install(to_install, install_path)
|
||||||
installed = []
|
|
||||||
try:
|
|
||||||
while to_install:
|
|
||||||
if debug:
|
|
||||||
print("Queue:", to_install)
|
|
||||||
pkg_spec = to_install.pop(0)
|
|
||||||
if pkg_spec in installed:
|
|
||||||
continue
|
|
||||||
meta = install_pkg(pkg_spec, install_path)
|
|
||||||
installed.append(pkg_spec)
|
|
||||||
if debug:
|
|
||||||
print(meta)
|
|
||||||
deps = meta.get("deps", "").rstrip()
|
|
||||||
if deps:
|
|
||||||
deps = deps.decode("utf-8").split("\n")
|
|
||||||
to_install.extend(deps)
|
|
||||||
except NotFoundError:
|
|
||||||
print("Error: cannot find '%s' package (or server error), packages may be partially installed" \
|
|
||||||
% pkg_spec, file=sys.stderr)
|
|
||||||
|
|
||||||
if not debug:
|
if not debug:
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
Ładowanie…
Reference in New Issue