From 8d9dc40e5f513c3433a4e91ca886c6d3833ad554 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 12 Dec 2024 10:07:50 -0500 Subject: [PATCH] Remove defunct read-the-docs script --- .github/workflows/release.yml | 7 ---- rtd_change_default_version.py | 74 ----------------------------------- 2 files changed, 81 deletions(-) delete mode 100644 rtd_change_default_version.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0044fbf2..447a9f0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,10 +90,3 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: python -m twine upload -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} --skip-existing dist/* - - - name: Change default version in readthedocs.io - if: success() - env: - RTD_USERNAME: ${{ secrets.RTD_USERNAME }} - RTD_PASSWORD: ${{ secrets.RTD_PASSWORD }} - run: python rtd_change_default_version.py cmdstanpy ${RTD_USERNAME} ${RTD_PASSWORD} v${{ github.event.inputs.new_version }} diff --git a/rtd_change_default_version.py b/rtd_change_default_version.py deleted file mode 100644 index cc122443..00000000 --- a/rtd_change_default_version.py +++ /dev/null @@ -1,74 +0,0 @@ -import sys - -import requests - -# This scrip accepts 4 arguments in order: -# Project name in readthedocs, readthedocs username, readthedocs password and version in readthedocs to set as default. -# Example: -# python3 change_default_version.py cmdstanpy snick secretpassword stable-0.9.66 - - -def get_csrf_token(cookies): - if 'csrftoken' in cookies: - # Django 1.6 and up - return cookies['csrftoken'] - else: - # older versions - return cookies['csrf'] - - -def set_version_active_on_rtd( - project_slug, - rtd_user, - rtd_password, - default_version, - server_addr="https://readthedocs.org", -): - - with requests.session() as s: - - url = server_addr + "/accounts/login/" - - # Fetch the login page - s.get(url) - # Extract CSRF token - csrftoken = get_csrf_token(s.cookies) - - # Build out login data - login_data = dict( - login=rtd_user, - password=rtd_password, - csrfmiddlewaretoken=csrftoken, - next='/', - ) - # Post login request - r = s.post(url, data=login_data, headers=dict(Referer=url)) - - # Set url for dashboard/advanced - url = server_addr + "/dashboard/" + project_slug + "/advanced/" - # Extract CSRF token - csrftoken = get_csrf_token(s.cookies) - - # Build out version data - version_data = { - 'csrfmiddlewaretoken': csrftoken, - 'default_version': default_version, - 'default_branch': 'develop', - 'analytics_code': '', - 'documentation_type': 'sphinx', - 'requirements_file': '', - 'python_interpreter': 'python', - 'conf_py_file': 'docsrc/conf.py', - 'enable_pdf_build': 'on', - 'enable_epub_build': 'on', - 'save': 'Save', - } - - # Post our version data - r = s.post(url, data=version_data, headers=dict(Referer=url)) - - -if __name__ == '__main__': - set_version_active_on_rtd( - sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] - )