Skip to content

Commit 607b57c

Browse files
jeremyromandomenic
andauthored
Fix installation of bs-highlighter and Prince XML
* Use pipx to install bs-highlighter: Debian now complains about externally managed Python packages. This installs it into its own little virtual env. * Install prince from tarball: The .deb package has not been updated for Debian 12, and depends on shared libraries not available in Debian stable anymore. The tarball version has fewer dynamic dependencies. Co-authored-by: Domenic Denicola <[email protected]>
1 parent 74e002c commit 607b57c

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
FROM debian:stable-slim
22
RUN apt-get update && \
3-
apt-get install --yes --no-install-recommends ca-certificates curl git python3 python3-pip && \
3+
apt-get install --yes --no-install-recommends ca-certificates curl git python3 python3-pip pipx && \
44
rm -rf /var/lib/apt/lists/*
55

66
COPY --from=ghcr.io/whatwg/wattsi:latest /whatwg/wattsi/bin/wattsi /bin/wattsi
77

8-
RUN pip3 install bs-highlighter
8+
ENV PIPX_HOME /opt/pipx
9+
ENV PIPX_BIN_DIR /usr/bin
10+
RUN pipx install bs-highlighter
911

1012
COPY . /whatwg/html-build/
1113

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To build locally, you'll need the following commands installed on your system:
2222

2323
- `curl`, `grep`, `perl`, `unzip`
2424

25-
Optionally, for faster builds, you can install [Wattsi](https://github.com/whatwg/wattsi) and Python 3.7+ (necessary for applying syntax highlighting to `pre` contents). If you don't bother with that, the build will use [Wattsi Server](https://github.com/whatwg/build.whatwg.org), which requires an internet connection.
25+
Optionally, for faster builds, you can install [Wattsi](https://github.com/whatwg/wattsi). If you don't bother with that, the build will use [Wattsi Server](https://github.com/whatwg/build.whatwg.org), which requires an internet connection. If you do use a local build of Wattsi, you'll likely also want Python 3.7+ with [pipx](https://pypa.github.io/pipx/), to enable syntax highlighting of `pre` contents.
2626

2727
### Running the build
2828

build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ function checkHTMLBuildIsUpToDate {
218218
function ensureHighlighterInstalled {
219219
# If we're not using local Wattsi then we won't use the local highlighter.
220220
if [[ $LOCAL_WATTSI == "true" && $DO_HIGHLIGHT == "true" ]]; then
221-
if hash pip3 2>/dev/null; then
221+
if hash pipx 2>/dev/null; then
222222
if ! hash bs-highlighter-server 2>/dev/null; then
223-
pip3 install bs-highlighter
223+
pipx install bs-highlighter
224224
fi
225225
else
226226
echo
227-
echo "Warning: could not find pip3 in your PATH. Disabling syntax highlighting."
227+
echo "Warning: could not find pipx in your PATH. Disabling syntax highlighting."
228228
echo
229229
DO_HIGHLIGHT="false"
230230
fi
@@ -650,7 +650,7 @@ function runWattsi {
650650
wattsi "${WATTSI_ARGS[@]}" || WATTSI_RESULT=$?
651651
else
652652
$QUIET || echo
653-
$QUIET || echo "Local wattsi or pip3 are not present; trying the build server..."
653+
$QUIET || echo "Local wattsi not present; trying the build server..."
654654

655655
CURL_URL="https://build.whatwg.org/wattsi"
656656
if [[ "$QUIET" == "true" && "$SINGLE_PAGE_ONLY" == "true" ]]; then

ci-build/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ RUN apt-get update && \
66
apt-get install --yes --no-install-recommends \
77
ca-certificates curl rsync git \
88
default-jre \
9-
python3 python3-pip \
9+
python3 python3-pip pipx \
10+
libbrotli1 libexpat1 libfontconfig1 libfreetype6 libpng16-16 \
1011
fonts-dejavu fonts-droid-fallback fonts-liberation fonts-symbola fonts-unfonts-core
1112

1213
# Dependency lines above are:
1314
# - General
1415
# - validator
1516
# - Highlighter
17+
# - Prince
1618
# - fonts, for when Prince renders to PDF
1719

1820
COPY --from=ghcr.io/whatwg/wattsi:latest /whatwg/wattsi/bin/wattsi /bin/wattsi
19-
RUN pip3 install bs-highlighter
21+
22+
ENV PIPX_HOME /opt/pipx
23+
ENV PIPX_BIN_DIR /usr/bin
24+
RUN pipx install bs-highlighter
2025

2126
# The DockerHub container for the validator only contains the server version, so we get the .jar
2227
# from GitHub:
@@ -25,11 +30,14 @@ ADD https://github.com/validator/validator/releases/download/latest/vnu.jar /wha
2530
# Trying to copy Prince from its DockerHub container like the others does not work; it has too many
2631
# shared library dependencies. Probably this is a job for Docker Compose... we should learn how that
2732
# works one day.
28-
ADD https://www.princexml.com/download/prince_14.2-1_debian10_amd64.deb /whatwg/prince.deb
33+
# Prince also hasn't been updated for Debian 12 and is no longer installable from its deb file.
34+
ADD https://www.princexml.com/download/prince-14.2-linux-generic-x86_64.tar.gz /whatwg/prince.tar.gz
2935
RUN cd /whatwg && \
30-
apt-get install --yes ./prince.deb && \
36+
tar xvzf prince.tar.gz && \
37+
( cd prince-* && echo /usr | ./install.sh ) && \
3138
echo '@font-face { font-family: serif; src: local("Symbola") }' >> /usr/lib/prince/style/fonts.css && \
32-
rm -rf /whatwg/prince.deb
39+
rm -rf prince* && \
40+
prince --version
3341

3442
ADD . /whatwg/html-build
3543

0 commit comments

Comments
 (0)