Skip to content

Commit c1bfa36

Browse files
committed
upip: Factor out install() function.
1 parent ce843f3 commit c1bfa36

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

upip/upip.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,28 @@ def install_pkg(pkg_spec, install_path):
155155
f1.close()
156156
return meta
157157

158+
def install(to_install, install_path):
159+
# sets would be perfect here, but don't depend on them
160+
installed = []
161+
try:
162+
while to_install:
163+
if debug:
164+
print("Queue:", to_install)
165+
pkg_spec = to_install.pop(0)
166+
if pkg_spec in installed:
167+
continue
168+
meta = install_pkg(pkg_spec, install_path)
169+
installed.append(pkg_spec)
170+
if debug:
171+
print(meta)
172+
deps = meta.get("deps", "").rstrip()
173+
if deps:
174+
deps = deps.decode("utf-8").split("\n")
175+
to_install.extend(deps)
176+
except NotFoundError:
177+
print("Error: cannot find '%s' package (or server error), packages may be partially installed" \
178+
% pkg_spec, file=sys.stderr)
179+
158180
def cleanup():
159181
for fname in cleanup_files:
160182
try:
@@ -224,26 +246,7 @@ def main():
224246
if not to_install:
225247
help()
226248

227-
# sets would be perfect here, but don't depend on them
228-
installed = []
229-
try:
230-
while to_install:
231-
if debug:
232-
print("Queue:", to_install)
233-
pkg_spec = to_install.pop(0)
234-
if pkg_spec in installed:
235-
continue
236-
meta = install_pkg(pkg_spec, install_path)
237-
installed.append(pkg_spec)
238-
if debug:
239-
print(meta)
240-
deps = meta.get("deps", "").rstrip()
241-
if deps:
242-
deps = deps.decode("utf-8").split("\n")
243-
to_install.extend(deps)
244-
except NotFoundError:
245-
print("Error: cannot find '%s' package (or server error), packages may be partially installed" \
246-
% pkg_spec, file=sys.stderr)
249+
install(to_install, install_path)
247250

248251
if not debug:
249252
cleanup()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy