Skip to content

Commit f7be5f9

Browse files
committed
tools/upip: Upgrade upip to 1.2.4.
Uses new pypi.org URL, and now creates a socket with the address parameters returned by getaddrinfo().
1 parent b5ee3b2 commit f7be5f9

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

tools/bootstrap_upip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fi
1717

1818
# Remove any stale old version
1919
rm -rf micropython-upip-*
20-
wget -nd -r -l1 https://pypi.python.org/pypi/micropython-upip/ --accept-regex ".*pypi.python.org/packages/source/.*.gz" --reject=html
20+
wget -nd -rH -l1 -D files.pythonhosted.org https://pypi.org/project/micropython-upip/ --reject=html
2121

2222
tar xfz micropython-upip-*.tar.gz
2323
tmpd="$PWD"

tools/upip.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#
2+
# upip - Package manager for MicroPython
3+
#
4+
# Copyright (c) 2015-2018 Paul Sokolovsky
5+
#
6+
# Licensed under the MIT license.
7+
#
18
import sys
29
import gc
310
import uos as os
@@ -110,16 +117,16 @@ def url_open(url):
110117

111118
proto, _, host, urlpath = url.split('/', 3)
112119
try:
113-
ai = usocket.getaddrinfo(host, 443)
120+
ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM)
114121
except OSError as e:
115122
fatal("Unable to resolve %s (no Internet?)" % host, e)
116123
#print("Address infos:", ai)
117-
addr = ai[0][4]
124+
ai = ai[0]
118125

119-
s = usocket.socket(ai[0][0])
126+
s = usocket.socket(ai[0], ai[1], ai[2])
120127
try:
121128
#print("Connect address:", addr)
122-
s.connect(addr)
129+
s.connect(ai[-1])
123130

124131
if proto == "https:":
125132
s = ussl.wrap_socket(s, server_hostname=host)
@@ -149,7 +156,7 @@ def url_open(url):
149156

150157

151158
def get_pkg_metadata(name):
152-
f = url_open("https://pypi.python.org/pypi/%s/json" % name)
159+
f = url_open("https://pypi.org/pypi/%s/json" % name)
153160
try:
154161
return json.load(f)
155162
finally:

0 commit comments

Comments
 (0)