Skip to content

Commit c63a486

Browse files
committed
Download xmlsec1 releases from GitHub
The server at www.aleksey.com (Cloudflare?) returns 403 Forbidden errors for some combination of: - missing User-Agent header - GitHub Actions CI runner IP address range - TLS settings (version, cipher suite) used by Python <= 3.9
1 parent bcd364c commit c63a486

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

setup.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,18 @@ def latest_release_from_gnome_org_cache(url, lib_name):
7070
return '{}/{}'.format(url, latest_source)
7171

7272

73-
def latest_release_from_github_api(repo):
74-
api_url = 'https://api.github.com/repos/{}/releases'.format(repo)
73+
def latest_release_json_from_github_api(repo):
74+
api_url = 'https://api.github.com/repos/{}/releases/latest'.format(repo)
7575

7676
# if we are running in CI, pass along the GH_TOKEN, so we don't get rate limited
7777
token = os.environ.get("GH_TOKEN")
7878
if token:
7979
log.info("Using GitHub token to avoid rate limiting")
80-
api_releases = make_request(api_url, token, json_response=True)
81-
releases = [r['tarball_url'] for r in api_releases if r['prerelease'] is False and r['draft'] is False]
82-
if not releases:
83-
raise DistutilsError('No release found for {}'.format(repo))
84-
return releases[0]
80+
return make_request(api_url, token, json_response=True)
8581

8682

8783
def latest_openssl_release():
88-
return latest_release_from_github_api('openssl/openssl')
84+
return latest_release_json_from_github_api('openssl/openssl')['tarball_url']
8985

9086

9187
def latest_zlib_release():
@@ -105,7 +101,9 @@ def latest_libxslt_release():
105101

106102

107103
def latest_xmlsec_release():
108-
return latest_release_from_html('https://www.aleksey.com/xmlsec/download/', re.compile('xmlsec1-(?P<version>.*).tar.gz'))
104+
assets = latest_release_json_from_github_api('lsh123/xmlsec')['assets']
105+
(tar_gz,) = [asset for asset in assets if asset['name'].endswith('.tar.gz')]
106+
return tar_gz['browser_download_url']
109107

110108

111109
class CrossCompileInfo:
@@ -381,7 +379,7 @@ def prepare_static_build(self, build_platform):
381379
url = latest_xmlsec_release()
382380
self.info('{:10}: {}'.format('xmlsec1', 'PYXMLSEC_XMLSEC1_VERSION unset, downloading latest from {}'.format(url)))
383381
else:
384-
url = 'https://www.aleksey.com/xmlsec/download/xmlsec1-{}.tar.gz'.format(self.xmlsec1_version)
382+
url = 'https://github.com/lsh123/xmlsec/releases/download/{v}/xmlsec1-{v}.tar.gz'.format(v=self.xmlsec1_version)
385383
self.info(
386384
'{:10}: {}'.format(
387385
'xmlsec1', 'PYXMLSEC_XMLSEC1_VERSION={}, downloading from {}'.format(self.xmlsec1_version, url)

0 commit comments

Comments
 (0)