Skip to content

Add support for Python Docs 3.7 #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
description: "Name of the Transifex translation project"
required: true
type: string
py_bin:
description: "Python binary version to use (useful if not equal to the 'version' input)"
required: false
type: string
workflow_call:
inputs:
version:
Expand All @@ -23,6 +27,10 @@ on:
description: "Name of the Transifex translation project"
required: true
type: string
py_bin:
description: "Python binary version to use (useful if not equal to the 'version' input)"
required: false
type: string
secrets:
TELEGRAM_TOKEN:
description: "Token required for interacting with Telegram API"
Expand Down Expand Up @@ -50,11 +58,20 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 5

- name: Set python binary version to use
run: |
if [[ -n "${{ inputs.py_bin }}" ]]; then
py_bin="${{ inputs.py_bin }}"
else
py_bin="${{ inputs.version }}"
fi
echo "PYTHON_BINARY_VERSION=$py_bin" >> $GITHUB_ENV

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.version }}
python-version: ${{ env.PYTHON_BINARY_VERSION }}
cache: pip
allow-prereleases: true

Expand Down Expand Up @@ -116,11 +133,20 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 5

- name: Set python binary version to use
run: |
if [[ -n "${{ inputs.py_bin }}" ]]; then
py_bin="${{ inputs.py_bin }}"
else
py_bin="${{ inputs.version }}"
fi
echo "PYTHON_BINARY_VERSION=$py_bin" >> $GITHUB_ENV

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.version }}
python-version: ${{ env.PYTHON_BINARY_VERSION }}
cache: pip
allow-prereleases: true

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/python-37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ jobs:
with:
tx_project: ${{ github.workflow }}
version: 3.7
py_bin: 3.9
secrets: inherit
check:
uses: ./.github/workflows/check.yml
needs: sync
with:
tx_project: ${{ github.workflow }}
version: 3.7
py_bin: 3.9
secrets: inherit
15 changes: 14 additions & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: "Name of the Transifex translation project"
required: true
type: string
py_bin:
description: "Python binary version to use (useful if not equal to the 'version' input)"
required: false
type: string
secrets:
TX_TOKEN:
description: "Token required for interacting with Transifex API"
Expand Down Expand Up @@ -48,10 +52,19 @@ jobs:
with:
ref: ${{ env.PYDOC_VERSION }}
path: ${{ env.LANGUAGE_DIR }}

- name: Set python binary version to use
run: |
if [[ -n "${{ inputs.py_bin }}" ]]; then
py_bin="${{ inputs.py_bin }}"
else
py_bin="${{ inputs.version }}"
fi
echo "PYTHON_BINARY_VERSION=$py_bin" >> $GITHUB_ENV

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.version }}
python-version: ${{ env.PYTHON_BINARY_VERSION }}
allow-prereleases: true
cache: 'pip'
cache-dependency-path: |
Expand Down
5 changes: 3 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ set -xeu

# Fail earlier if required variables are not set
test -n ${PYDOC_LANGUAGE+x}
test -n ${PYDOC_VERSION+x}

cd "$(dirname $0)/.."
mkdir -p logs

# If version is 3.12 or older, set gettext_compact.
# This confval is not needed since 3.12.
# In 3.13, its presence messes 3.13's syntax checking (?)
minor_version=${PYDOC_VERSION##*.}
opts="-D language=${PYDOC_LANGUAGE} --keep-going -w ../../logs/sphinxwarnings.txt"
minor_version=$(git -C cpython/Doc branch --show-current | sed 's|^3\.||')
if [ $minor_version -lt 12 ]; then
opts="$opts -D gettext_compact=False"
fi

make -C cpython/Doc html SPHINXOPTS="${opts}"

# Remove empty file
# Remove sphinxwarnings.txt if empty file
if [ ! -s logs/sphinxwarnings.txt ]; then
rm logs/sphinxwarnings.txt
fi
10 changes: 10 additions & 0 deletions scripts/generate_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ set -xeu
# Fail earlier if required variables are not set (do not expose TX_TOKEN)
test -n ${PYDOC_TX_PROJECT+x}
test -n ${PYDOC_LANGUAGE+x}
test -n ${PYDOC_VERSION+x}

# Make sure to run all commands from CPython docs locales directory
cd $(dirname $0)/../cpython/Doc/locales

# Python 3.7: Add missing sections to satisfy Blurb's check
# Useful if setup.sh was not ran
if [ ${PYDOC_VERSION} = '3.7' ] && [ ! -f ../../114553.patch ]; then
curl -L https://github.com/python/cpython/pull/114553.patch -o ../../114553.patch
git apply ../../114553.patch
cat ../../114553.patch
sleep 1
fi

# Generate message catalog template (.pot) files
# TODO: use `make -C .. gettext` when there are only Python >= 3.12
opts='-E -b gettext -D gettext_compact=0 -d build/.doctrees . build/gettext'
Expand Down
17 changes: 17 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ set -u
pip install -r requirements.txt
make -C cpython/Doc venv


if [[ ${PYDOC_VERSION} == '3.7' ]]; then
# Fixes circular dependencies that affects Python 3.7, see:
# https://github.com/sphinx-doc/sphinx/issues/11567
# https://github.com/bazelbuild/rules_python/pull/1166
cpython/Doc/venv/bin/pip install \
sphinxcontrib-applehelp==1.0.4 \
sphinxcontrib-devhelp==1.0.2 \
sphinxcontrib-htmlhelp==2.0.1 \
sphinxcontrib-qthelp==1.0.3 \
sphinxcontrib-serializinghtml==1.1.5 \
alabaster==0.7.13
# Add missing sections to satisfy Blurb's check
curl -L https://github.com/python/cpython/pull/114553.patch -o ../../114553.patch
git apply ../../114553.patch
fi

if ! command -v tx > /dev/null; then
echo "WARNING: Transifex CLI tool was not found."
echo "If going to pull translations it is needed, can be ignored otherwise."
Expand Down
Loading