Skip to content

Commit 6a97c97

Browse files
authored
Merge pull request #18225 from QuLogic/certifi-freetype
Use certifi when downloading bundled build requirements.
2 parents 89d13c3 + 9b1a9b1 commit 6a97c97

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def build_extensions(self):
275275

276276
python_requires='>={}'.format('.'.join(str(n) for n in min_version)),
277277
setup_requires=[
278+
"certifi>=2020.06.20",
278279
"numpy>=1.15",
279280
],
280281
install_requires=[

setupext.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def _get_hash(data):
4242
return hasher.hexdigest()
4343

4444

45+
@functools.lru_cache()
46+
def _get_ssl_context():
47+
import certifi
48+
import ssl
49+
return ssl.create_default_context(cafile=certifi.where())
50+
51+
4552
def download_or_cache(url, sha):
4653
"""
4754
Get bytes from the given url or local cache.
@@ -73,7 +80,8 @@ def download_or_cache(url, sha):
7380
# default User-Agent, but not (for example) wget; so I don't feel too
7481
# bad passing in an empty User-Agent.
7582
with urllib.request.urlopen(
76-
urllib.request.Request(url, headers={"User-Agent": ""})) as req:
83+
urllib.request.Request(url, headers={"User-Agent": ""}),
84+
context=_get_ssl_context()) as req:
7785
data = req.read()
7886

7987
file_sha = _get_hash(data)

0 commit comments

Comments
 (0)