diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2022-12-27 10:22:37 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2022-12-27 10:25:16 +0100 |
commit | 9e3ec4767f9c4766a0919c15ffe019c9d8b31499 (patch) | |
tree | 04a3b8855a5827f6e644dbca048b26acc6d8a7b7 | |
parent | 67d4856adeebf34ab58963c7ad82ec83a8fdda84 (diff) | |
download | python-lxml-9e3ec4767f9c4766a0919c15ffe019c9d8b31499.tar.gz |
Pass GitHub token into API call when listing library releases.
-rw-r--r-- | .github/workflows/ci.yml | 2 | ||||
-rw-r--r-- | buildlibxml.py | 11 | ||||
-rw-r--r-- | tools/ci-run.sh | 6 |
3 files changed, 15 insertions, 4 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65d873c3..2d960a28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -175,7 +175,7 @@ jobs: - name: Run CI continue-on-error: ${{ matrix.allowed_failure || false }} env: ${{ matrix.env }} - run: bash ./tools/ci-run.sh + run: GITHUB_API_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./tools/ci-run.sh - name: Build docs if: contains( matrix.env.EXTRA_DEPS, 'sphinx') 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: diff --git a/tools/ci-run.sh b/tools/ci-run.sh index db3c7e87..893e73b2 100644 --- a/tools/ci-run.sh +++ b/tools/ci-run.sh @@ -5,6 +5,8 @@ set -x GCC_VERSION=${GCC_VERSION:=9} TEST_CFLAGS= EXTRA_CFLAGS= +SAVED_GITHUB_API_TOKEN="${GITHUB_API_TOKEN}" +unset GITHUB_API_TOKEN # remove from env # Set up compilers if [ -z "${OS_NAME##ubuntu*}" ]; then @@ -62,7 +64,9 @@ if [[ "$COVERAGE" == "true" ]]; then fi # Build -CFLAGS="$CFLAGS $EXTRA_CFLAGS" python -u setup.py build_ext --inplace \ +CFLAGS="$CFLAGS $EXTRA_CFLAGS" \ + GITHUB_API_TOKEN="${SAVED_GITHUB_API_TOKEN}" \ + python -u setup.py build_ext --inplace \ $(if [ -n "${PYTHON_VERSION##2.*}" ]; then echo -n " -j7 "; fi ) \ $(if [[ "$COVERAGE" == "true" ]]; then echo -n " --with-coverage"; fi ) \ || exit 1 |