summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames R. Barlow <james@purplerock.ca>2022-07-22 19:46:20 -0700
committerJames R. Barlow <james@purplerock.ca>2022-07-22 19:46:20 -0700
commitdb52846dda0bfd1419f7cb4d66d9bb097a8e73db (patch)
tree4869952602e411a123dc5a9b8cf1a25c995d481d
parentc432bd6207d24dcf5013e94f6c21e012603d07f1 (diff)
Revert "Trigger RTD with action instead of fragile scripting"
This reverts commit ec857696690c34d6f5978cb6a9abd636b76aafd9.
-rw-r--r--.github/workflows/build.yml15
-rw-r--r--docs/conf.py55
-rw-r--r--docs/requirements.txt4
-rw-r--r--setup.cfg1
4 files changed, 45 insertions, 30 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5f1daf3..0db5aea 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -233,7 +233,7 @@ jobs:
name: Trigger ReadTheDocs
runs-on: ubuntu-latest
needs: [wheels_linux]
- # if: startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/actions')
+ if: startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/actions')
steps:
- name: Check for secrets
id: setvar
@@ -247,12 +247,15 @@ jobs:
echo "Secrets to use trigger ReadTheDocs were not configured"
echo "::set-output name=have_secrets::false"
fi
+ - name: Get branch name
+ id: get_branch
+ run: |
+ echo "::set-output name=branch::${GITHUB_REF##refs/heads/}"
- name: Trigger ReadTheDocs webhook
- uses: dfm/rtds-action@v1
- with:
- webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
- webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
- commit_ref: ${{ github.ref }}
+ run: |
+ curl -X POST -d "branches=${{ steps.get_branch.outputs.branch }}" \
+ -d "token=${{ secrets.RTDS_WEBHOOK_TOKEN }}" \
+ "${{ secrets.RTDS_WEBHOOK_URL }}""
if: ${{ steps.setvar.outputs.have_secrets == 'true' }}
upload_pypi:
diff --git a/docs/conf.py b/docs/conf.py
index 2833b38..963e768 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,6 +11,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
+import io
import os
import subprocess
import sys
@@ -37,47 +38,58 @@ extensions = [
on_rtd = os.environ.get('READTHEDOCS') == 'True'
if on_rtd:
- extensions.append('rtds_action')
+ import tempfile
+ import zipfile
-if on_rtd:
- github_token = os.environ['GITHUB_TOKEN']
- # The name of your GitHub repository
- rtds_action_github_repo = "pikepdf/pikepdf"
-
- # The path where the artifact should be extracted
- # Note: this is relative to the conf.py file!
- rtds_action_path = "."
+ import git
+ import github
+ import requests
- # The "prefix" used in the `upload-artifact` step of the action
- rtds_action_artifact_prefix = "rtd-wheel-"
+ # Borrowed from https://github.com/YannickJadoul/Parselmouth/blob/master/docs/conf.py
+ rtd_version = os.environ.get('READTHEDOCS_VERSION', '')
+ branch = 'master' if rtd_version == 'latest' else rtd_version
- # A GitHub personal access token is required, more info below
- rtds_action_github_token = os.environ["GITHUB_TOKEN"]
+ github_token = os.environ['GITHUB_TOKEN']
+ head_sha = git.Repo(search_parent_directories=True).head.commit.hexsha
+ g = github.Github()
- # Whether or not to raise an error on Read the Docs if the
- # artifact can't be downloaded (optional)
- rtds_action_error_if_missing = True
+ runs = (
+ g.get_repo('pikepdf/pikepdf').get_workflow('build.yml').get_runs(branch=branch)
+ )
+ artifacts_url = next(r for r in runs if r.head_sha == head_sha).artifacts_url
+
+ archive_download_url = next(
+ artifact
+ for artifact in requests.get(artifacts_url).json()['artifacts']
+ if artifact['name'] == 'rtd-wheel'
+ )['archive_download_url']
+ artifact_bin = io.BytesIO(
+ requests.get(
+ archive_download_url,
+ headers={'Authorization': f'token {github_token}'},
+ stream=True,
+ ).content
+ )
def pip(*args):
subprocess.run([sys.executable, '-m', 'pip', *args], check=True)
- wheel = next(Path('.').glob('*.whl'))
- pip('install', '--force-reinstall', wheel)
+ with zipfile.ZipFile(artifact_bin) as zf, tempfile.TemporaryDirectory() as tmpdir:
+ assert len(zf.namelist()) == 1
+ zf.extractall(tmpdir)
+ pip('install', '--force-reinstall', f'{tmpdir}/{zf.namelist()[0]}')
else:
sys.path.insert(0, os.path.abspath(os.path.join('..', 'installed')))
-
autodoc_mock_imports = ['libxmp']
autodoc_typehints = 'description'
-
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext'))
sys.path.insert(0, os.path.join(os.path.abspath('.'), '..'))
-
import pikepdf # isort:skip pylint: disable=unused-import
# -- General configuration ------------------------------------------------
@@ -85,7 +97,6 @@ import pikepdf # isort:skip pylint: disable=unused-import
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
-
issues_github_path = "pikepdf/pikepdf"
ipython_execlines = ['import pikepdf', 'from pikepdf import Pdf']
diff --git a/docs/requirements.txt b/docs/requirements.txt
index d951506..d5c92e3 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -17,4 +17,6 @@ sphinx-design
sphinx-rtd-theme
tomli; python_version < '3.11'
-rtds-action
+GitPython
+PyGithub
+requests
diff --git a/setup.cfg b/setup.cfg
index 461a58f..93db146 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -62,7 +62,6 @@ docs =
matplotlib
pybind11
requests
- rtds-action
setuptools-scm
sphinx-design
sphinx-issues