diff options
| author | Michael Williamson <mike@zwobble.org> | 2020-04-18 08:14:46 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2020-04-18 11:21:14 +0100 |
| commit | cbfb3e115c028b307327a153a89dbf0448984526 (patch) | |
| tree | 8af8fbbf53d431e20cb7916d3a5282e6e628708f | |
| parent | 024dcaf4450e9db0d66f1ae8b28efbf618156f92 (diff) | |
Use requests to fetch tarballs from GitHub in setup.py
This hopefully avoids issues with SSL certificates, since
requests uses certifi.
| -rw-r--r-- | pyproject.toml | 8 | ||||
| -rw-r--r-- | setup.py | 17 | ||||
| -rw-r--r-- | tox.ini | 1 |
3 files changed, 20 insertions, 6 deletions
diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e9a46a2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = [ + "setuptools>=43", + "wheel", + "requests", + "certifi" +] +build-backend = "setuptools.build_meta" @@ -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) @@ -1,5 +1,6 @@ [tox] envlist = py27,py34,py35,py36,py37,py38,pypy,pypy3 +isolated_build = True [testenv] changedir = {envtmpdir} deps=-r{toxinidir}/test-requirements.txt |
