Skip to content

Commit 8182463

Browse files
committed
Update to Trac 1.6 and Python 3.8 (finally 🎉)
Still running Django 1.11 which is technically not compatible with Python 3.8 but our test suite seems to pass.
1 parent eb16ed0 commit 8182463

File tree

6 files changed

+56
-71
lines changed

6 files changed

+56
-71
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ jobs:
2121
uses: actions/checkout@v4
2222
- uses: actions/setup-python@v5
2323
with:
24-
python-version: '3.7'
24+
python-version: '3.8'
2525
- run: pip install "tinycss2>=1.2.0"
2626
- run: python noshadows.py --tests
2727

2828
tracdjangoplugin:
29-
runs-on: ubuntu-latest
30-
container:
31-
image: python:2.7.18-buster
29+
runs-on: ubuntu-20.04
3230
steps:
3331
- name: Checkout
3432
uses: actions/checkout@v4
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.8'
3536
- name: Install requirements
3637
run: python -m pip install -r requirements.txt
3738
- name: Run tests

DjangoPlugin/tracdjangoplugin/plugins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from urlparse import urlparse
1+
from urllib.parse import urlparse
22

33
from trac.core import Component, implements
44
from trac.web.chrome import INavigationContributor
55
from trac.web.api import IRequestFilter, IRequestHandler, RequestDone
66
from trac.web.auth import LoginModule
77
from trac.wiki.web_ui import WikiModule
8-
from trac.util import Markup
98
from trac.util.html import tag
109
from tracext.github import GitHubBrowser
1110

@@ -82,7 +81,7 @@ def get_navigation_items(self, req):
8281
(
8382
"mainnav",
8483
"custom_reports",
85-
Markup('<a href="%s">Reports</a>' % req.href.wiki("Reports")),
84+
tag.a("Reports", href=req.href.wiki("Reports")),
8685
),
8786
]
8887

Dockerfile

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,52 @@
1-
# The official python:2.7 image no longer receives automatic rebuilds (it's
2-
# a year old as of October, 2021), so use the latest LTS release of Ubuntu
3-
# that includes Python 2.7 instead.
4-
FROM ubuntu:20.04
5-
6-
# Install packages needed to run your application (not build deps).
7-
RUN set -x \
8-
&& RUN_DEPS=" \
9-
ca-certificates \
10-
git \
11-
libpq5 \
12-
make \
13-
postgresql-client \
14-
python2.7 \
15-
" \
16-
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
1+
# pull official base image
2+
FROM python:3.8-slim-bullseye
3+
4+
# set work directory
5+
WORKDIR /code
6+
7+
# set environment varibles
8+
ENV PYTHONDONTWRITEBYTECODE 1
9+
ENV PYTHONUNBUFFERED 1
10+
11+
# install deb packages
12+
RUN apt-get update \
13+
&& apt-get install --assume-yes --no-install-recommends \
14+
git \
15+
make \
16+
postgresql-client-13 \
1717
&& rm -rf /var/lib/apt/lists/*
1818

19-
# Copy requirements
20-
ADD requirements.txt /requirements.txt
21-
ADD DjangoPlugin /DjangoPlugin
22-
23-
# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step.
24-
# Correct the path to your production requirements file, if needed.
25-
# For installing a python2.7-compatible pip: https://stackoverflow.com/a/54335642/166053
26-
# Since we are using the system Python, also isolate the code in its own virtualenv.
27-
RUN set -x \
28-
&& BUILD_DEPS=" \
29-
build-essential \
30-
libpq-dev \
31-
python2.7-dev \
32-
wget \
33-
" \
34-
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
35-
&& wget -q -O /tmp/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py \
36-
&& python2.7 /tmp/get-pip.py \
37-
&& rm /tmp/get-pip.py \
38-
&& python2.7 -m pip install virtualenv \
39-
&& virtualenv /venv \
40-
&& /venv/bin/python -m pip install --no-cache-dir -r /requirements.txt \
41-
\
42-
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
19+
# install python dependencies
20+
COPY ./requirements.txt ./requirements.txt
21+
COPY ./DjangoPlugin ./DjangoPlugin
22+
23+
RUN apt-get update \
24+
&& apt-get install --assume-yes --no-install-recommends \
25+
g++ \
26+
gcc \
27+
libc6-dev \
28+
libpq-dev \
29+
&& python3 -m pip install --no-cache-dir -r requirements.txt \
30+
&& apt-get purge --assume-yes --auto-remove \
31+
gcc \
32+
libc6-dev \
33+
libpq-dev \
4334
&& rm -rf /var/lib/apt/lists/*
4435

45-
# Copy application code
46-
RUN mkdir /code/
47-
WORKDIR /code/
48-
ADD . /code/
36+
COPY ./docker-entrypoint.sh ./docker-entrypoint.sh
37+
COPY ./Makefile ./Makefile
38+
COPY ./scss ./scss
39+
COPY ./trac-env ./trac-env
40+
RUN make compile-scss
41+
RUN rm -r ./scss
4942

50-
RUN PATH=/venv/bin:${PATH} make compile-scss
5143

5244
VOLUME /code/trac-env/files/
5345

54-
# gunicorn or tracd will listen on this port
5546
EXPOSE 9000
56-
5747
ENV DJANGO_SETTINGS_MODULE=tracdjangoplugin.settings TRAC_ENV=/code/trac-env/
5848

59-
ENTRYPOINT ["/code/docker-entrypoint.sh"]
49+
ENTRYPOINT ["./docker-entrypoint.sh"]
6050

6151
# Start gunicorn
62-
CMD ["/venv/bin/gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"]
52+
CMD ["gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"]

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
build:
88
context: ./
99
dockerfile: Dockerfile
10-
command: ["/venv/bin/tracd", "--port", "9000", "-s", "trac-env"]
10+
command: ["tracd", "--port", "9000", "-s", "trac-env"]
1111
environment:
1212
- TRAC_INI_database=postgres://code.djangoproject:secret@db/code.djangoproject
1313
volumes:

docker-entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ set -e
1010
# database = postgres://...
1111

1212
for var in "${!TRAC_INI_@}"; do
13-
sed -i "s;^${var:9} = .*;${var:9} = ${!var};" trac-env/conf/trac.ini
13+
sed -i "s;^${var:9} = .*;${var:9} = ${!var};" /code/trac-env/conf/trac.ini
1414
done
1515

1616
if [ "x$TRAC_COLLECT_STATIC" = 'xon' ]; then
1717
# Collect trac static files to be served by nginx
18-
/venv/bin/trac-admin ./trac-env/ deploy ./static/
18+
trac-admin /code/trac-env/ deploy ./static/
1919
fi
2020

2121
exec "$@"

requirements.txt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
# spam-filter doesn't work without babel (but somehow doesn't list it in its requirements)
2-
Trac[pygments, babel]==1.4.4
2+
Trac[pygments, babel]==1.6.0
33
dnspython==1.15
4-
spambayes == 1.1b1
5-
psycopg2==2.7.6.1 --no-binary=psycopg2
6-
docutils==0.14
4+
psycopg2==2.9.9 --no-binary=psycopg2
75
Django==1.11.29
8-
libsass==0.17.0
9-
Genshi==0.7.7 # still required by some plugins
6+
libsass==0.23.0
107

118
# Trac plugins
12-
https://trac.edgewall.org/browser/plugins/1.4/spam-filter?format=zip
13-
# TracXMLRPC from PyPI does not (yet) have a 1.2.0 release (compatible with Trac 1.4)
9+
https://trac.edgewall.org/browser/plugins/trunk/spam-filter?rev=17752&format=zip
10+
# TracXMLRPC from PyPI does not (yet) have a 1.2.0 release (compatible with Trac >=1.4)
1411
https://trac-hacks.org/browser/xmlrpcplugin/trunk?rev=18591&format=zip
1512

16-
oauthlib==2.1.0
17-
requests==2.20.1
18-
requests-oauthlib==1.0.0
19-
trac-github==2.3
13+
# No pypi release compatible with trac 1.6 yet
14+
trac-github[oauth] @ git+https://github.com/bmispelon/[email protected]
2015

2116
gunicorn==19.10.0
2217
sentry-sdk==1.11.0

0 commit comments

Comments
 (0)