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 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 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: | 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..405a1ef81 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -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' 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."