From 8ae5d51762324a65fc4c7a4c8fd873e7fc1681dd Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Tue, 28 Jan 2025 14:13:53 -0300 Subject: [PATCH 1/7] Add support for Python Docs 3.7 --- scripts/build.sh | 5 +++-- scripts/generate_templates.sh | 8 ++++++++ scripts/setup.sh | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index ee338368e..44119ba9c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -7,6 +7,7 @@ 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 @@ -14,15 +15,15 @@ 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 diff --git a/scripts/generate_templates.sh b/scripts/generate_templates.sh index d1878f411..1f82b71ed 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -13,10 +13,18 @@ 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 +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' diff --git a/scripts/setup.sh b/scripts/setup.sh index 0c5a95adf..c1c7bc657 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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." From c2cdb95eb695095c9776bb691e3acac44fb2c847 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 5 Feb 2025 19:44:29 -0300 Subject: [PATCH 2/7] Add inputs.py_bin to sync.yml --- .github/workflows/sync.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 7ff462ff2..7c6c194cc 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -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" @@ -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: | From 8ce7a6b2a3be25ffece853cd8629746d5adb2da7 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 5 Feb 2025 19:46:29 -0300 Subject: [PATCH 3/7] Add inputs.py_bin to check.yml --- .github/workflows/check.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0ff197d01..e554a28be 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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: @@ -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" @@ -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 @@ -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 From 5a1aa4d21cee8238a0c2ebf186d4dd519758a76e Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 5 Feb 2025 19:47:06 -0300 Subject: [PATCH 4/7] set py_bin to 3.9 in python-37.yml --- .github/workflows/python-37.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-37.yml b/.github/workflows/python-37.yml index 2b1cadd25..08cef705a 100644 --- a/.github/workflows/python-37.yml +++ b/.github/workflows/python-37.yml @@ -9,6 +9,7 @@ jobs: with: tx_project: ${{ github.workflow }} version: 3.7 + py_bin: 3.9 secrets: inherit check: uses: ./.github/workflows/check.yml @@ -16,4 +17,5 @@ jobs: with: tx_project: ${{ github.workflow }} version: 3.7 + py_bin: 3.9 secrets: inherit From f1366f845a43ca4db4e4baa3cba118a614836ca3 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 5 Feb 2025 19:54:19 -0300 Subject: [PATCH 5/7] Fix equality comparison in generate_templates.sh --- scripts/generate_templates.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_templates.sh b/scripts/generate_templates.sh index 1f82b71ed..b29671416 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -20,7 +20,7 @@ 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 +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 fi From 670cee4b96aeb3e373b30f11fe95acff879e1963 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 6 Feb 2025 22:53:38 -0300 Subject: [PATCH 6/7] Try git-am instead of git-apply in generate_templates.sh --- scripts/generate_templates.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_templates.sh b/scripts/generate_templates.sh index b29671416..d82123634 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -22,7 +22,7 @@ cd $(dirname $0)/../cpython/Doc/locales # 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 + git am ../../114553.patch fi # Generate message catalog template (.pot) files From 1755b15829e829045f13e51d916b8e187f6622dc Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 6 Feb 2025 23:03:30 -0300 Subject: [PATCH 7/7] Debug generate_templates.sh --- scripts/generate_templates.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/generate_templates.sh b/scripts/generate_templates.sh index d82123634..405a1ef81 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -22,7 +22,9 @@ cd $(dirname $0)/../cpython/Doc/locales # 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 am ../../114553.patch + git apply ../../114553.patch + cat ../../114553.patch + sleep 1 fi # Generate message catalog template (.pot) files