summaryrefslogtreecommitdiff
path: root/buildlibxml.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildlibxml.py')
-rw-r--r--buildlibxml.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/buildlibxml.py b/buildlibxml.py
index 0c57936f..d385217e 100644
--- a/buildlibxml.py
+++ b/buildlibxml.py
@@ -33,7 +33,12 @@ sys_platform = sys.platform
def download_and_extract_windows_binaries(destdir):
url = "https://api.github.com/repos/lxml/libxml2-win-binaries/releases?per_page=5"
- releases, _ = read_url(url, accept="application/vnd.github+json", as_json=True)
+ releases, _ = read_url(
+ url,
+ accept="application/vnd.github+json",
+ as_json=True,
+ github_api_token=os.environ.get("GITHUB_API_TOKEN"),
+ )
max_release = {'tag_name': ''}
for release in releases:
@@ -169,10 +174,12 @@ def _list_dir_ftplib(url):
return parse_text_ftplist("\n".join(data))
-def read_url(url, decode=True, accept=None, as_json=False):
+def read_url(url, decode=True, accept=None, as_json=False, github_api_token=None):
headers = {'User-Agent': 'https://github.com/lxml/lxml'}
if accept:
headers['Accept'] = accept
+ if github_api_token:
+ headers['authorization'] = "Bearer " + github_api_token
request = Request(url, headers=headers)
with closing(urlopen(request)) as res: