Skip to content

Commit 2a9aa01

Browse files
authored
Merge pull request #10 from Zedifuu/bugfix/outdated-build
Fixed outdated build script and fixed compatibility with Python 3.10 and 3.12
2 parents d11ff9c + 9aace1a commit 2a9aa01

File tree

4 files changed

+57
-29
lines changed

4 files changed

+57
-29
lines changed

.github/workflows/pontoon-tarball.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,23 @@ jobs:
2626
- name: "Checkout the repository"
2727
uses: actions/checkout@v4
2828

29-
- name: "Set up Python 3.11"
30-
uses: actions/setup-python@v5
31-
with:
32-
python-version: "3.11"
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v4
31+
32+
- name: Set up Python 3.11
33+
run: uv python install 3.11
3334

34-
- name: "Set up Node 16"
35+
- name: "Set up Node 20"
3536
uses: actions/setup-node@v4
3637
with:
37-
node-version: 16
38+
node-version: 20
3839

3940
- name: "Make Pontoon release tarball"
4041
run: |
4142
./make-pontoon-tarball.sh
4243
4344
- name: "Upload artifacts"
44-
uses: actions/upload-artifact@v3
45+
uses: actions/upload-artifact@v4
4546
with:
4647
name: pontoon-release-tarball
4748
path: ./dist/
@@ -84,7 +85,7 @@ jobs:
8485
python-version: ${{ matrix.python-version }}
8586

8687
- name: "Download Pontoon release tarball"
87-
uses: actions/download-artifact@v3
88+
uses: actions/download-artifact@v4
8889
with:
8990
name: pontoon-release-tarball
9091

@@ -102,6 +103,8 @@ jobs:
102103
- name: "Install Python dependencies"
103104
run: |
104105
cd pontoon-*
106+
python -m pip install pip-tools
107+
pip-compile --generate-hashes requirements/default.in -o requirements/default.txt
105108
pip install -r requirements.txt
106109
107110
- name: "Make DB Migration"

Dockerfile

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
FROM ubuntu:22.04
1+
FROM python:3.11-bookworm
2+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
23

34
ENV DEBIAN_FRONTEND=noninteractive
45

5-
RUN apt-get update && \
6+
RUN mkdir -p /etc/apt/keyrings && \
7+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
8+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
9+
apt-get update && \
610
apt-get install -y \
711
build-essential \
8-
ca-certificates \
9-
curl \
1012
git \
11-
gnupg \
1213
libpq-dev \
13-
python3 \
14-
python3-dev \
15-
python3-venv \
16-
&& \
17-
mkdir -p /etc/apt/keyrings && \
18-
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
19-
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
20-
apt-get update && \
21-
apt-get install -y nodejs
14+
nodejs
2215

2316
WORKDIR /data
2417

debian/requirements.py310.in

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file must be copied to the root of the Pontoon's repository,
2+
# Then the requirements.py310.txt can be generated with the following command:
3+
#
4+
# uv pip compile --generate-hashes requirements.py310.in -o requirements.py310.txt
5+
#
6+
7+
-r requirements.txt
8+
9+
# Python 3.10 additional dependency for anyio
10+
exceptiongroup==1.2.2

make-pontoon-tarball.sh

+29-7
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,35 @@ git clone https://github.com/mozilla/pontoon.git $BUILD_DIR/$APP_NAME.git
3333
cd $BUILD_DIR/$APP_NAME.git
3434
git checkout $PONTOON_REV
3535

36-
# Install Python dependencies
37-
python3 -m venv __env__
36+
# Prepare Python Virtual Environment using uv if available else using venv
37+
uv --version > /dev/null 2>&1 && uv venv __env__ || python3 -m venv __env__
3838
source __env__/bin/activate
39-
pip install --upgrade pip==23.1.1 # Pip version fixed because it breaks pip-tools everytime...
40-
pip install -r requirements.txt
39+
40+
# Collect info about the environment
41+
PYTHON_MAJOR=$(python -c "import sys;print(sys.version_info.major)")
42+
PYTHON_MINOR=$(python -c "import sys;print(sys.version_info.minor)")
43+
uv --version > /dev/null 2>&1 && UV_AVAILABLE=1 || UV_AVAILABLE=0
44+
45+
# Install uv in the venv if not available
46+
if [ $UV_AVAILABLE != 1 ] ; then
47+
pip install uv
48+
fi
49+
50+
# Compile dependencies (Replicating: https://github.com/mozilla/pontoon/blob/d619331f62b28fd69d3f998d97e4343dd0ed6bc4/docker/compile_requirements.sh)
51+
uv pip compile --generate-hashes requirements/default.in -o requirements/default.txt
52+
uv pip compile --generate-hashes requirements/dev.in -o requirements/dev.txt
53+
uv pip compile --generate-hashes requirements/lint.in -o requirements/lint.txt
54+
uv pip compile --generate-hashes requirements/test.in -o requirements/test.txt
55+
56+
# Compile additional dependencies for Python 3.10
57+
cp $DEBIAN_DIR/requirements.py310.in $BUILD_DIR/$APP_NAME.git/
58+
uv pip compile --generate-hashes $BUILD_DIR/$APP_NAME.git/requirements.py310.in -o $OUTPUT_DIR/requirements.py310.txt
59+
60+
# Install Python dependencies
61+
uv pip install -r requirements.txt
62+
if [ $PYTHON_MAJOR == 3 ] && [ $PYTHON_MINOR -ge 12 ] ; then
63+
uv pip install setuptools
64+
fi
4165

4266
# Install Node dependencies
4367
npm install
@@ -49,19 +73,17 @@ export DJANGO_DEBUG=True
4973

5074
# Build the front
5175
npm run build:prod
52-
python3 manage.py collectstatic
76+
uv run manage.py collectstatic
5377

5478
# Leave the virtualenv
5579
deactivate
5680

5781
# Copy files
5882
cp -vr static/ $OUTPUT_DIR
5983
cp -vr pontoon/ $OUTPUT_DIR
60-
cp -vr tag-admin/ $OUTPUT_DIR
6184
cp -vr translate/ $OUTPUT_DIR
6285
cp -vr requirements/ $OUTPUT_DIR
6386
cp -v setup.py $OUTPUT_DIR
64-
cp -v setup.cfg $OUTPUT_DIR
6587
cp -v manage.py $OUTPUT_DIR
6688
cp -v requirements.txt $OUTPUT_DIR
6789
cp -v LICENSE $OUTPUT_DIR

0 commit comments

Comments
 (0)