Skip to content

Commit acf90d5

Browse files
authored
Merge branch 'main' into job-detail-leak
2 parents 75ae6fe + e89f46d commit acf90d5

File tree

173 files changed

+5292
-2354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+5292
-2354
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ updates:
1919
- dependency-name: lxml
2020
versions:
2121
- 4.6.2
22+
- package-ecosystem: github-actions
23+
directory: "/"
24+
groups:
25+
github-actions:
26+
patterns:
27+
- "*" # Group all Actions updates into a single larger pull request
28+
schedule:
29+
interval: daily

.github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
services:
77
postgres:
8-
image: postgres:10.1
8+
image: postgres:15.3
99
env:
1010
POSTGRES_USER: postgres
1111
POSTGRES_PASSWORD: postgres
@@ -16,12 +16,24 @@ jobs:
1616
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
1717
steps:
1818
- name: Check out repository
19-
uses: actions/checkout@v2
20-
- uses: actions/setup-python@v2
19+
uses: actions/checkout@v4
20+
- name: Install platform dependencies
21+
run: |
22+
sudo apt -y update
23+
sudo apt -y install --no-install-recommends \
24+
texlive-latex-base \
25+
texlive-latex-recommended \
26+
texlive-plain-generic \
27+
lmodern
28+
- name: Install pandoc
29+
run: |
30+
wget https://github.com/jgm/pandoc/releases/download/2.17.1.1/pandoc-2.17.1.1-1-amd64.deb
31+
sudo dpkg -i pandoc-2.17.1.1-1-amd64.deb
32+
- uses: actions/setup-python@v5
2133
with:
2234
python-version: 3.9.16
2335
- name: Cache Python dependencies
24-
uses: actions/cache@v2
36+
uses: actions/cache@v4
2537
env:
2638
cache-name: pythondotorg-cache-pip
2739
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# $ git config --global core.excludesfile ~/.gitignore_global
1111

1212
.sass-cache/
13+
docs/build
1314
media/*
1415
static-root/
1516
static/stylesheets/mq.css

.readthedocs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
# Project page: https://readthedocs.org/projects/pythondotorg/
4+
5+
version: 2
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3"
11+
12+
commands:
13+
- python -m pip install -r docs-requirements.txt
14+
- make -C docs html JOBS=$(nproc) BUILDDIR=_readthedocs
15+
- mv docs/_readthedocs _readthedocs

Aptfile

Whitespace-only changes.

Dockerfile

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
1-
FROM python:3.9-bullseye
1+
FROM python:3.9-bookworm
22
ENV PYTHONUNBUFFERED=1
33
ENV PYTHONDONTWRITEBYTECODE=1
4+
5+
# By default, Docker has special steps to avoid keeping APT caches in the layers, which
6+
# is good, but in our case, we're going to mount a special cache volume (kept between
7+
# builds), so we WANT the cache to persist.
8+
RUN set -eux; \
9+
rm -f /etc/apt/apt.conf.d/docker-clean; \
10+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache;
11+
12+
# Install System level build requirements, this is done before
13+
# everything else because these are rarely ever going to change.
14+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
15+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
16+
set -x \
17+
&& apt-get update \
18+
&& apt-get install --no-install-recommends -y \
19+
texlive-latex-base \
20+
texlive-latex-recommended \
21+
texlive-fonts-recommended \
22+
texlive-plain-generic \
23+
lmodern
24+
25+
RUN case $(uname -m) in \
26+
"x86_64") ARCH=amd64 ;; \
27+
"aarch64") ARCH=arm64 ;; \
28+
esac \
29+
&& wget --quiet https://github.com/jgm/pandoc/releases/download/2.17.1.1/pandoc-2.17.1.1-1-${ARCH}.deb \
30+
&& dpkg -i pandoc-2.17.1.1-1-${ARCH}.deb
31+
432
RUN mkdir /code
533
WORKDIR /code
34+
635
COPY dev-requirements.txt /code/
736
COPY base-requirements.txt /code/
8-
RUN pip install -r dev-requirements.txt
37+
COPY prod-requirements.txt /code/
38+
COPY requirements.txt /code/
39+
40+
RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel
41+
42+
RUN --mount=type=cache,target=/root/.cache/pip \
43+
set -x \
44+
&& pip --disable-pip-version-check \
45+
install \
46+
-r dev-requirements.txt
47+
948
COPY . /code/

Dockerfile.cabotage

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM python:3.9-bullseye
2+
COPY --from=ewdurbin/nginx-static:1.25.x /usr/bin/nginx /usr/bin/nginx
3+
ENV PYTHONUNBUFFERED=1
4+
ENV PYTHONDONTWRITEBYTECODE=1
5+
6+
# By default, Docker has special steps to avoid keeping APT caches in the layers, which
7+
# is good, but in our case, we're going to mount a special cache volume (kept between
8+
# builds), so we WANT the cache to persist.
9+
RUN set -eux; \
10+
rm -f /etc/apt/apt.conf.d/docker-clean; \
11+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache;
12+
13+
# Install System level build requirements, this is done before
14+
# everything else because these are rarely ever going to change.
15+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
16+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
17+
set -x \
18+
&& apt-get update \
19+
&& apt-get install --no-install-recommends -y \
20+
texlive-latex-base \
21+
texlive-latex-recommended \
22+
texlive-fonts-recommended \
23+
texlive-plain-generic \
24+
lmodern
25+
26+
RUN case $(uname -m) in \
27+
"x86_64") ARCH=amd64 ;; \
28+
"aarch64") ARCH=arm64 ;; \
29+
esac \
30+
&& wget --quiet https://github.com/jgm/pandoc/releases/download/2.17.1.1/pandoc-2.17.1.1-1-${ARCH}.deb \
31+
&& dpkg -i pandoc-2.17.1.1-1-${ARCH}.deb
32+
33+
RUN mkdir /code
34+
WORKDIR /code
35+
36+
COPY dev-requirements.txt /code/
37+
COPY base-requirements.txt /code/
38+
COPY prod-requirements.txt /code/
39+
COPY requirements.txt /code/
40+
41+
RUN pip --no-cache-dir --disable-pip-version-check install --upgrade pip setuptools wheel
42+
43+
RUN --mount=type=cache,target=/root/.cache/pip \
44+
set -x \
45+
&& pip --disable-pip-version-check \
46+
install \
47+
-r requirements.txt -r prod-requirements.txt
48+
COPY . /code/
49+
RUN DJANGO_SETTINGS_MODULE=pydotorg.settings.static python manage.py collectstatic --noinput

Procfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
release: python manage.py migrate --noinput
22
web: bin/start-nginx gunicorn -c gunicorn.conf pydotorg.wsgi
3+
worker: celery -A pydotorg worker -l INFO
4+
worker-beat: celery -A pydotorg beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# python.org
22

3-
[![Build Status](https://travis-ci.org/python/pythondotorg.svg?branch=main)](https://travis-ci.org/python/pythondotorg)
3+
[![CI](https://github.com/python/pythondotorg/actions/workflows/ci.yml/badge.svg)](https://github.com/python/pythondotorg/actions/workflows/ci.yml)
44
[![Documentation Status](https://readthedocs.org/projects/pythondotorg/badge/?version=latest)](https://pythondotorg.readthedocs.io/?badge=latest)
55

66
### General information

banners/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'banners.apps.BannersAppConfig'

base-requirements.txt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
dj-database-url==0.5.0
2-
django-pipeline==2.0.6
3-
django-sitetree==1.17.0
2+
django-pipeline==3.0.0 # 3.0.0 is first version that supports Django 4.2
3+
django-sitetree==1.18.0 # >=1.17.1 is (?) first version that supports Django 4.2
44
django-apptemplates==1.5
55
django-admin-interface==0.24.2
66
django-translation-aliases==0.1.0
7-
Django==2.2.24
7+
Django==4.2.16
88
docutils==0.12
99
Markdown==3.3.4
1010
cmarkgfm==0.6.0
@@ -13,43 +13,44 @@ psycopg2-binary==2.8.6
1313
python3-openid==3.2.0
1414
python-decouple==3.4
1515
# lxml used by BeautifulSoup.
16-
lxml==4.6.3
16+
lxml==5.2.2
1717
cssselect==1.1.0
1818
feedparser==6.0.8
19-
beautifulsoup4==4.9.3
19+
beautifulsoup4==4.11.2
2020
icalendar==4.0.7
2121
chardet==4.0.0
22+
celery[redis]==5.3.6
23+
django-celery-beat==2.5.0
2224
# TODO: We may drop 'django-imagekit' completely.
23-
django-imagekit==4.0.2
24-
django-haystack==3.0
25-
elasticsearch>=5,<6
25+
django-imagekit==5.0 # 5.0 is first version that supports Django 4.2
26+
django-haystack==3.2.1
27+
elasticsearch>=7,<8
2628
# TODO: 0.14.0 only supports Django 1.8 and 1.11.
27-
django-tastypie==0.14.3
29+
django-tastypie==0.14.6 # 0.14.6 is first version that supports Django 4.2
2830

2931
pytz==2021.1
3032
python-dateutil==2.8.2
3133

3234
requests[security]>=2.26.0
3335

34-
django-honeypot==1.0.1
35-
django-markupfield==2.0.0
36-
django-markupfield-helpers==0.1.1
36+
django-honeypot==1.0.4 # 1.0.4 is first version that supports Django 4.2
37+
django-markupfield==2.0.1
3738

38-
django-allauth==0.41.0
39+
django-allauth==0.57.2 # 0.55.0 is first version that supports Django 4.2
3940

4041
django-waffle==2.2.1
4142

42-
djangorestframework==3.12.2
43+
djangorestframework==3.14.0 # 3.14.0 is first version that supports Django 4.1, 4.2 support hasnt been "released"
4344
django-filter==2.4.0
4445
django-ordered-model==3.4.3
4546
django-widget-tweaks==1.4.8
4647
django-countries==7.2.1
47-
xhtml2pdf==0.2.5
48-
django-easy-pdf3==0.1.2
4948
num2words==0.5.10
50-
django-polymorphic==3.0.0
49+
django-polymorphic==3.1.0 # 3.1.0 is first version that supports Django 4.0, unsure if it fully supports 4.2
5150
sorl-thumbnail==12.7.0
52-
docxtpl==0.12.0
53-
reportlab==3.6.6
5451
django-extensions==3.1.4
5552
django-import-export==2.7.1
53+
54+
pypandoc==1.12
55+
panflute==2.3.0
56+
Unidecode==1.3.8

bin/start-nginx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
psmgr=/tmp/nginx-buildpack-wait
4+
rm -f $psmgr
5+
mkfifo $psmgr
6+
7+
n=1
8+
while getopts :f option ${@:1:2}
9+
do
10+
case "${option}"
11+
in
12+
f) FORCE=$OPTIND; n=$((n+1));;
13+
esac
14+
done
15+
16+
# Initialize log directory.
17+
mkdir -p /tmp/logs/nginx
18+
touch /tmp/logs/nginx/access.log /tmp/logs/nginx/error.log
19+
echo 'buildpack=nginx at=logs-initialized'
20+
21+
# Start log redirection.
22+
(
23+
# Redirect nginx logs to stdout.
24+
tail -qF -n 0 /tmp/logs/nginx/*.log
25+
echo 'logs' >$psmgr
26+
) &
27+
28+
# Start App Server
29+
(
30+
# Take the command passed to this bin and start it.
31+
# E.g. bin/start-nginx bundle exec unicorn -c config/unicorn.rb
32+
COMMAND=${@:$n}
33+
echo "buildpack=nginx at=start-app cmd=$COMMAND"
34+
$COMMAND
35+
echo 'app' >$psmgr
36+
) &
37+
38+
if [[ -z "$FORCE" ]]
39+
then
40+
FILE="/tmp/app-initialized"
41+
42+
# We block on app-initialized so that when nginx binds to $PORT
43+
# are app is ready for traffic.
44+
while [[ ! -f "$FILE" ]]
45+
do
46+
echo 'buildpack=nginx at=app-initialization'
47+
sleep 1
48+
done
49+
echo 'buildpack=nginx at=app-initialized'
50+
fi
51+
52+
# Start nginx
53+
(
54+
# We expect nginx to run in foreground.
55+
# We also expect a socket to be at /tmp/nginx.socket.
56+
echo 'buildpack=nginx at=nginx-start'
57+
cd /tmp
58+
/usr/bin/nginx -p . -c /code/config/nginx.conf
59+
echo 'nginx' >$psmgr
60+
) &
61+
62+
# This read will block the process waiting on a msg to be put into the fifo.
63+
# If any of the processes defined above should exit,
64+
# a msg will be put into the fifo causing the read operation
65+
# to un-block. The process putting the msg into the fifo
66+
# will use it's process name as a msg so that we can print the offending
67+
# process to stdout.
68+
read exit_process <$psmgr
69+
echo "buildpack=nginx at=exit process=$exit_process"
70+
exit 1

blogs/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'blogs.apps.BlogsAppConfig'

blogs/admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ class BlogEntryAdmin(admin.ModelAdmin):
1010
date_hierarchy = 'pub_date'
1111
actions = ['sync_new_entries']
1212

13+
@admin.action(
14+
description="Sync new blog entries"
15+
)
1316
def sync_new_entries(self, request, queryset):
1417
call_command('update_blogs')
1518
self.message_user(request, "Blog entries updated.")
1619

17-
sync_new_entries.short_description = "Sync new blog entries"
1820

1921

2022
@admin.register(FeedAggregate)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 4.2.11 on 2024-09-05 17:10
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
('blogs', '0002_remove_translations_and_contributors'),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name='relatedblog',
18+
name='creator',
19+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_creator', to=settings.AUTH_USER_MODEL),
20+
),
21+
migrations.AlterField(
22+
model_name='relatedblog',
23+
name='last_modified_by',
24+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_modified', to=settings.AUTH_USER_MODEL),
25+
),
26+
]

blogs/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from django.conf import settings
55
from django.template.loader import render_to_string
6-
from django.utils.timezone import make_aware, utc
6+
from django.utils.timezone import make_aware
77

88
from boxes.models import Box
99
from .models import BlogEntry, Feed
@@ -16,7 +16,7 @@ def get_all_entries(feed_url):
1616

1717
for e in d['entries']:
1818
published = make_aware(
19-
datetime.datetime(*e['published_parsed'][:7]), timezone=utc
19+
datetime.datetime(*e['published_parsed'][:7]), timezone=datetime.timezone.utc
2020
)
2121

2222
entry = {

0 commit comments

Comments
 (0)