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().
pull/1/head
Damien George 2018-04-23 16:11:27 +10:00
parent b5ee3b2f21
commit f7be5f9bfa
2 changed files with 13 additions and 6 deletions

View File

@ -17,7 +17,7 @@ fi
# Remove any stale old version
rm -rf micropython-upip-*
wget -nd -r -l1 https://pypi.python.org/pypi/micropython-upip/ --accept-regex ".*pypi.python.org/packages/source/.*.gz" --reject=html
wget -nd -rH -l1 -D files.pythonhosted.org https://pypi.org/project/micropython-upip/ --reject=html
tar xfz micropython-upip-*.tar.gz
tmpd="$PWD"

View File

@ -1,3 +1,10 @@
#
# upip - Package manager for MicroPython
#
# Copyright (c) 2015-2018 Paul Sokolovsky
#
# Licensed under the MIT license.
#
import sys
import gc
import uos as os
@ -110,16 +117,16 @@ def url_open(url):
proto, _, host, urlpath = url.split('/', 3)
try:
ai = usocket.getaddrinfo(host, 443)
ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM)
except OSError as e:
fatal("Unable to resolve %s (no Internet?)" % host, e)
#print("Address infos:", ai)
addr = ai[0][4]
ai = ai[0]
s = usocket.socket(ai[0][0])
s = usocket.socket(ai[0], ai[1], ai[2])
try:
#print("Connect address:", addr)
s.connect(addr)
s.connect(ai[-1])
if proto == "https:":
s = ussl.wrap_socket(s, server_hostname=host)
@ -149,7 +156,7 @@ def url_open(url):
def get_pkg_metadata(name):
f = url_open("https://pypi.python.org/pypi/%s/json" % name)
f = url_open("https://pypi.org/pypi/%s/json" % name)
try:
return json.load(f)
finally: