Skip to content

Commit eb16738

Browse files
zhengruifengHyukjinKwon
authored andcommitted
[SPARK-55518][INFRA][PYTHON][DOCS] Upgrade Python to 3.12 in doc build
### What changes were proposed in this pull request? Upgrade Python to 3.12 in doc build ### Why are the changes needed? 1, Upgrade Python to 3.12 in doc build; 2, Unpin `pyzmq<24.0.0` introduced in #37904 for python linter, otherwise the python installation fails ### Does this PR introduce _any_ user-facing change? No, infra-only ### How was this patch tested? CI, the PR builder should cover this change ### Was this patch authored or co-authored using generative AI tooling? No Closes #54310 from zhengruifeng/doc_py312. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 829045e commit eb16738

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

.github/workflows/build_and_test.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,11 +1104,14 @@ jobs:
11041104
- name: List Python packages for branch-3.5 and branch-4.0
11051105
if: inputs.branch == 'branch-3.5' || inputs.branch == 'branch-4.0'
11061106
run: python3.9 -m pip list
1107+
- name: List Python packages for branch-4.1
1108+
if: inputs.branch == 'branch-4.1'
1109+
run: python3.11 -m pip list
11071110
- name: List Python packages
1108-
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0'
1111+
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0' && inputs.branch != 'branch-4.1'
11091112
run: |
11101113
lsb_release -a
1111-
python3.11 -m pip list
1114+
python3.12 -m pip list
11121115
- name: Install dependencies for documentation generation
11131116
run: |
11141117
# Keep the version of Bundler here in sync with the following locations:
@@ -1139,8 +1142,8 @@ jobs:
11391142
echo "SKIP_SQLDOC: $SKIP_SQLDOC"
11401143
cd docs
11411144
bundle exec jekyll build
1142-
- name: Run documentation build
1143-
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0'
1145+
- name: Run documentation build for branch-4.1
1146+
if: inputs.branch == 'branch-4.1'
11441147
run: |
11451148
# We need this link to make sure `python3` points to `python3.11` which contains the prerequisite packages.
11461149
ln -s "$(which python3.11)" "/usr/local/bin/python3"
@@ -1163,6 +1166,30 @@ jobs:
11631166
echo "SKIP_SQLDOC: $SKIP_SQLDOC"
11641167
cd docs
11651168
bundle exec jekyll build
1169+
- name: Run documentation build
1170+
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0' && inputs.branch != 'branch-4.1'
1171+
run: |
1172+
# We need this link to make sure `python3` points to `python3.12` which contains the prerequisite packages.
1173+
ln -s "$(which python3.12)" "/usr/local/bin/python3"
1174+
# Build docs first with SKIP_API to ensure they are buildable without requiring any
1175+
# language docs to be built beforehand.
1176+
cd docs; SKIP_ERRORDOC=1 SKIP_API=1 bundle exec jekyll build; cd ..
1177+
if [ -f "./dev/is-changed.py" ]; then
1178+
# Skip PySpark and SparkR docs while keeping Scala/Java/SQL docs
1179+
pyspark_modules=`cd dev && python3.12 -c "import sparktestsupport.modules as m; print(','.join(m.name for m in m.all_modules if m.name.startswith('pyspark')))"`
1180+
if [ `./dev/is-changed.py -m $pyspark_modules` = false ]; then export SKIP_PYTHONDOC=1; fi
1181+
if [ `./dev/is-changed.py -m sparkr` = false ]; then export SKIP_RDOC=1; fi
1182+
fi
1183+
export PYSPARK_DRIVER_PYTHON=python3.12
1184+
export PYSPARK_PYTHON=python3.12
1185+
# Print the values of environment variables `SKIP_ERRORDOC`, `SKIP_SCALADOC`, `SKIP_PYTHONDOC`, `SKIP_RDOC` and `SKIP_SQLDOC`
1186+
echo "SKIP_ERRORDOC: $SKIP_ERRORDOC"
1187+
echo "SKIP_SCALADOC: $SKIP_SCALADOC"
1188+
echo "SKIP_PYTHONDOC: $SKIP_PYTHONDOC"
1189+
echo "SKIP_RDOC: $SKIP_RDOC"
1190+
echo "SKIP_SQLDOC: $SKIP_SQLDOC"
1191+
cd docs
1192+
bundle exec jekyll build
11661193
- name: Tar documentation
11671194
if: github.repository != 'apache/spark'
11681195
run: tar cjf site.tar.bz2 docs/_site

dev/spark-test-image/docs/Dockerfile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LABEL org.opencontainers.image.ref.name="Apache Spark Infra Image for Documentat
2424
# Overwrite this label to avoid exposing the underlying Ubuntu OS version label
2525
LABEL org.opencontainers.image.version=""
2626

27-
ENV FULL_REFRESH_DATE=20260208
27+
ENV FULL_REFRESH_DATE=20260213
2828

2929
ENV DEBIAN_FRONTEND=noninteractive
3030
ENV DEBCONF_NONINTERACTIVE_SEEN=true
@@ -56,14 +56,19 @@ RUN apt-get update && apt-get install -y \
5656
openjdk-17-jdk-headless \
5757
pandoc \
5858
pkg-config \
59+
python3.12 \
60+
python3.12-venv \
5961
qpdf \
6062
tzdata \
6163
r-base \
6264
ruby \
6365
ruby-dev \
6466
software-properties-common \
6567
wget \
66-
zlib1g-dev
68+
zlib1g-dev \
69+
&& apt-get autoremove --purge -y \
70+
&& apt-get clean \
71+
&& rm -rf /var/lib/apt/lists/*
6772

6873
# See more in SPARK-39959, roxygen2 < 7.2.1
6974
RUN Rscript -e "install.packages(c('devtools', 'knitr', 'markdown', 'rmarkdown', 'testthat'), repos='https://cloud.r-project.org/')" && \
@@ -74,27 +79,17 @@ RUN Rscript -e "install.packages(c('devtools', 'knitr', 'markdown', 'rmarkdown',
7479
# See more in SPARK-39735
7580
ENV R_LIBS_SITE="/usr/local/lib/R/site-library:${R_LIBS_SITE}:/usr/lib/R/library"
7681

77-
# Install Python 3.11
78-
RUN add-apt-repository ppa:deadsnakes/ppa
79-
RUN apt-get update && apt-get install -y \
80-
python3.11 \
81-
&& apt-get autoremove --purge -y \
82-
&& apt-get clean \
83-
&& rm -rf /var/lib/apt/lists/*
84-
8582
# Setup virtual environment
8683
ENV VIRTUAL_ENV=/opt/spark-venv
87-
RUN python3.11 -m venv --without-pip $VIRTUAL_ENV
84+
RUN python3.12 -m venv $VIRTUAL_ENV
8885
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
8986

90-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
91-
9287
# Should unpin 'sphinxcontrib-*' after upgrading sphinx>5
9388
# See 'ipython_genutils' in SPARK-38517
9489
# See 'docutils<0.18.0' in SPARK-39421
95-
RUN python3.11 -m pip install 'sphinx==4.5.0' mkdocs 'pydata_sphinx_theme>=0.13' sphinx-copybutton nbsphinx numpydoc jinja2 markupsafe 'pyzmq<24.0.0' \
90+
RUN python3.12 -m pip install 'sphinx==4.5.0' mkdocs 'pydata_sphinx_theme>=0.13' sphinx-copybutton nbsphinx numpydoc jinja2 markupsafe \
9691
ipython ipython_genutils sphinx_plotly_directive 'numpy>=1.22' pyarrow 'pandas==2.3.3' 'plotly>=4.8' 'docutils<0.18.0' \
9792
'flake8==3.9.0' 'mypy==1.19.1' 'pytest==7.1.3' 'pytest-mypy-plugins==1.9.3' 'black==23.12.1' \
9893
'pandas-stubs==1.2.0.53' 'grpcio==1.76.0' 'grpcio-status==1.76.0' 'protobuf==6.33.5' 'grpc-stubs==1.24.11' 'googleapis-common-protos-stubs==2.2.0' \
9994
'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' \
100-
&& python3.11 -m pip cache purge
95+
&& python3.12 -m pip cache purge

0 commit comments

Comments
 (0)