diff options
Diffstat (limited to 'bootstrap.py')
-rwxr-xr-x | bootstrap.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/bootstrap.py b/bootstrap.py index 9df0761df6..51b81f5e8e 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -1,14 +1,14 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # This script simply downloads waf to the current directory -from __future__ import print_function import os, sys, stat, hashlib, subprocess +from urllib.request import urlopen, URLError -WAFRELEASE = "waf-2.0.9" +WAFRELEASE = "waf-2.0.20" WAFURLS = ["https://waf.io/" + WAFRELEASE, "http://www.freehackers.org/~tnagy/release/" + WAFRELEASE] -SHA256HASH = "2a8e0816f023995e557f79ea8940d322bec18f286917c8f9a6fa2dc3875dfa48" +SHA256HASH = "bf971e98edc2414968a262c6aa6b88541a26c3cd248689c89f4c57370955ee7f" if os.path.exists("waf"): wafver = subprocess.check_output([sys.executable, './waf', '--version']).decode() @@ -20,11 +20,6 @@ if "--no-download" in sys.argv[1:]: print("Did not find {} and no download was requested.".format(WAFRELEASE)) sys.exit(1) -try: - from urllib.request import urlopen, URLError -except: - from urllib2 import urlopen, URLError - waf = None for WAFURL in WAFURLS: @@ -32,8 +27,8 @@ for WAFURL in WAFURLS: print("Downloading {}...".format(WAFURL)) waf = urlopen(WAFURL).read() break - except URLError: - print("Download failed.") + except URLError as err: + print("Download failed! ({})".format(err)) if not waf: print("Could not download {}.".format(WAFRELEASE)) @@ -41,6 +36,12 @@ if not waf: sys.exit(1) if SHA256HASH == hashlib.sha256(waf).hexdigest(): + # Upstream waf is not changing the default interpreter during + # 2.0.x line due to compatibility reasons apparently. So manually + # convert it to use python3 (the script works with both). + expected = b"#!/usr/bin/env python\n" + assert waf.startswith(expected) + waf = b"#!/usr/bin/env python3\n" + waf[len(expected):] with open("waf", "wb") as wf: wf.write(waf) |