summaryrefslogtreecommitdiff
path: root/tools/upip.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/upip.py')
-rw-r--r--tools/upip.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/upip.py b/tools/upip.py
index 7ecf61e54..e3b888516 100644
--- a/tools/upip.py
+++ b/tools/upip.py
@@ -16,6 +16,7 @@ gc.collect()
debug = False
+index_urls = ["https://micropython.org/pi", "https://pypi.org/pypi"]
install_path = None
cleanup_files = []
gzdict_sz = 16 + 15
@@ -156,11 +157,16 @@ def url_open(url):
def get_pkg_metadata(name):
- f = url_open("https://pypi.org/pypi/%s/json" % name)
- try:
- return json.load(f)
- finally:
- f.close()
+ for url in index_urls:
+ try:
+ f = url_open("%s/%s/json" % (url, name))
+ except NotFoundError:
+ continue
+ try:
+ return json.load(f)
+ finally:
+ f.close()
+ raise NotFoundError("Package not found")
def fatal(msg, exc=None):
@@ -261,6 +267,7 @@ for installation, upip does not support arbitrary code in setup.py.
def main():
global debug
+ global index_urls
global install_path
install_path = None
@@ -294,6 +301,9 @@ def main():
if l[0] == "#":
continue
to_install.append(l.rstrip())
+ elif opt == "-i":
+ index_urls = [sys.argv[i]]
+ i += 1
elif opt == "--debug":
debug = True
else: