Skip to content

Commit

Permalink
Merge pull request #2301 from liberapay/aws-upgrade
Browse files Browse the repository at this point in the history
The Liberapay webapp is now running on Python 3.11. This enables dropping support for older versions (3.8 to 3.10). It also enables using the new features that have been added in Python versions 3.9 to 3.11, but this branch attempt to do that.

I've observed a slight increase of the median response time to HTTP requests, by about 2.5ms (10%). A bit disappointing, but not too bad.
  • Loading branch information
Changaco authored Dec 14, 2023
2 parents c3f6fb1 + 9fb6499 commit cf4bf53
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Cache the .tox directory to speed things up
uses: actions/cache@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions .platform/hooks/prebuild/01_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
set -eux

# Install libffi-devel for misaka, and htop for when I want to look at what's going on
yum install -y libffi-devel htop
dnf install -y libffi-devel htop
# Install PostgreSQL client tools and libraries
amazon-linux-extras install -y postgresql11
dnf install -y postgresql15

# Automatically set the PG* environment variables so that `psql` connects to the liberapay database by default
install -m 644 -o root -g root -t /etc/profile.d .platform/files/pgenv.sh
Expand All @@ -18,7 +18,7 @@ install -m 644 -o root -g root -t /etc/systemd/system .platform/files/[email protected]
systemctl daemon-reload

# Install cloudflared, directly from GitHub
target_cfd_version="2021.11.0"
target_cfd_version="2023.10.0"
function get_installed_cfd_version() {
if [ -x /usr/local/bin/cloudflared ]; then
/usr/local/bin/cloudflared version | \
Expand All @@ -34,7 +34,7 @@ if [ "$installed_cfd_version" != "$target_cfd_version" ]; then
fi
wget "https://github.com/cloudflare/cloudflared/releases/download/$target_cfd_version/cloudflared-linux-amd64"
hash=$(sha256sum cloudflared-linux-amd64 | cut -d' ' -f1)
expected_hash=cce5bc7df0187e93291135d32d159b1acd86d9ca25c3e448b8bbeab2ce976b8e
expected_hash=33e6876bd55c2db13a931cf812feb9cb17c071ab45d3b50c588642b022693cdc
if [ $hash != $expected_hash ]; then
echo "cloudflared binary downloaded from GitHub doesn't match expected hash: $hash != $expected_hash"
exit 1
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python := "$(shell { command -v python3.8 || command -v python3 || command -v python || echo false; } 2>/dev/null)"
python := "$(shell { command -v python3.11 || command -v python3 || command -v python || echo false; } 2>/dev/null)"

# Set the relative path to installed binaries under the project virtualenv.
# NOTE: Creating a virtualenv on Windows places binaries in the 'Scripts' directory.
Expand All @@ -20,7 +20,7 @@ $(env): Makefile requirements*.txt
exit 1; \
fi;
@$(python) cli/check-python-version.py
$(python) -m venv $(env)
$(python) -m venv --upgrade-deps $(env)
$(pip) install wheel
$(pip) install --require-hashes -r requirements_base.txt
$(pip) install -r requirements_tests.txt
Expand Down Expand Up @@ -67,7 +67,7 @@ test-schema: $(env)
$(with_tests_env) ./recreate-schema.sh test

pyflakes: $(env)
$(env_bin)/python -m flake8 app.py liberapay tests
$(env_py) -m flake8 app.py liberapay tests

test: test-schema pytest
tests: test
Expand Down Expand Up @@ -99,7 +99,7 @@ _i18n_extract: $(env)
grep -E '^(liberapay/.+\.py|.+\.(spt|html))$$' | \
python -c "import sys; print(*sorted(sys.stdin, key=lambda l: l.rsplit('/', 1)))" \
)
@$(env_bin)/python cli/po-tools.py reflag i18n/core.pot
@$(env_py) cli/po-tools.py reflag i18n/core.pot
@for f in i18n/*/*.po; do \
$(env_bin)/pybabel update -i i18n/core.pot -l $$(basename -s '.po' "$$f") -o "$$f" --ignore-obsolete --no-fuzzy-matching --no-wrap; \
done
Expand All @@ -120,7 +120,7 @@ _i18n_clean: $(env)
done

_i18n_convert: $(env)
@$(env_bin)/python cli/convert-chinese.py
@$(env_py) cli/convert-chinese.py

i18n_update: _i18n_rebase _i18n_pull _i18n_extract _i18n_convert _i18n_clean
@if git commit --dry-run i18n &>/dev/null; then \
Expand Down Expand Up @@ -161,7 +161,7 @@ _i18n_merge:
git reset -q master -- i18n
@for f in i18n/*/*.po; do \
if test $$(sed -E -e '/\\n"$$/{d;d}' $$f | grep -c -E '^"' 2>/dev/null) -gt 10; then \
$(env_bin)/python cli/po-tools.py reformat $$f; \
$(env_py) cli/po-tools.py reformat $$f; \
fi \
done
@$(MAKE) --no-print-directory _i18n_clean
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The python code inside simplates is only for request-specific logic, common back

Make sure you have the following dependencies installed first:

- python ≥ 3.8
- python ≥ 3.11
- including the C headers of python and libffi, which are packaged separately in many Linux distributions
- postgresql 13 (see [the official download & install docs](https://www.postgresql.org/download/))
- make
Expand Down
4 changes: 2 additions & 2 deletions cli/check-python-version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys

if sys.version_info < (3, 8, 0):
print("Liberapay requires Python >= 3.8, but %s is version %s.%s" %
if sys.version_info < (3, 11, 0):
print("Liberapay requires Python >= 3.11, but %s is version %s.%s" %
(sys.executable, sys.version_info[0], sys.version_info[1]))
sys.exit(1)
if sys.version_info >= (3, 13, 0):
Expand Down
7 changes: 1 addition & 6 deletions requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,7 @@ cryptography==41.0.6 \
--hash=sha256:13ae38502be632115abf8a24cbe5f4da52e3b5231990aff31123c805306ccb9c \
--hash=sha256:db4e40728b728508912cbb3d44f19ce188f218e9eba635821bb4b68564f8fd67

OpenCC==1.1.3; python_version < '3.10' \
--hash=sha256:2d1043e4d19ac89656b83e027f1834451ee0639d27239b579ba0b7cbb24af805 \
--hash=sha256:3aadc356b3b67dead0614fd47530351130eddf0d45b9889a5b58dd888c945640 \
--hash=sha256:48309ed913fde331f43beea36ca74252f1e279ee98d149f8509151a2252adbca \
--hash=sha256:c0a85bb12f362903241a53c767838fe09d494c4caffe12797157bdd8133b7e6e
OpenCC==1.1.7; python_version >= '3.10' \
OpenCC==1.1.7 \
--hash=sha256:06092f06e4b8a1f2563df03214c9f6fa457c9ff6d114f76bf9fb374cc2a4591f \
--hash=sha256:253e7d636ad0aad2e70e616d2185181e0104687f53ec38974f7b67221c475382 \
--hash=sha256:3ed6f128383375b9dc5c3db02ffa9d6ac1a14242656414bab85a18ef65daf645 \
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py311
envlist = py311,py312
skipsdist = True

[testenv]
Expand Down

0 comments on commit cf4bf53

Please sign in to comment.