summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-04-18 08:14:46 +0100
committerMichael Williamson <mike@zwobble.org>2020-04-18 11:21:14 +0100
commitcbfb3e115c028b307327a153a89dbf0448984526 (patch)
tree8af8fbbf53d431e20cb7916d3a5282e6e628708f /setup.py
parent024dcaf4450e9db0d66f1ae8b28efbf618156f92 (diff)
Use requests to fetch tarballs from GitHub in setup.py
This hopefully avoids issues with SSL certificates, since requests uses certifi.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index 30f4c50..ca5d246 100644
--- a/setup.py
+++ b/setup.py
@@ -5,17 +5,20 @@ import platform
import subprocess
import tarfile
import shutil
-
import sysconfig
+import requests
from setuptools import setup
-from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
+from setuptools.extension import Extension
+
+
+def urlretrieve(source_url, destination_path):
+ response = requests.get(source_url, stream=True)
-try:
- from urllib import urlretrieve
-except ImportError:
- from urllib.request import urlretrieve
+ with open(destination_path, "wb") as fileobj:
+ for chunk in response.iter_content(chunk_size=128):
+ fileobj.write(chunk)
def path_in_dir(relative_path):
return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path))
@@ -77,7 +80,9 @@ class jq_build_ext(build_ext):
def _download_tarball(self, source_url, tarball_path):
if os.path.exists(tarball_path):
os.unlink(tarball_path)
+ print("Downloading {}".format(source_url))
urlretrieve(source_url, tarball_path)
+ print("Downloaded {}".format(source_url))
if os.path.exists(jq_lib_dir):
shutil.rmtree(jq_lib_dir)