Skip to content

Commit

Permalink
Python=3.11 Django=5.0.2 Upgrades (#248)
Browse files Browse the repository at this point in the history
* WIP Python + Django Upgrades

* Upgrade Dockerfile

* Monkey patch for apn2

* Bump python version workflow

* Run cdk, update pipfile for linting

* Compile yarn to upgrade python version

* Remove else clause for monkey patch
  • Loading branch information
judtinzhang authored Mar 6, 2024
1 parent 7e43efe commit 10be4f0
Show file tree
Hide file tree
Showing 7 changed files with 626 additions and 707 deletions.
2 changes: 1 addition & 1 deletion .github/cdk/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ new LabsApplicationStack(app, {
djangoProjectName: 'pennmobile',
dockerImageBaseName: 'penn-mobile',
djangoCheckProps: {
pythonVersion: "3.9.14-buster",
pythonVersion: "3.11-bookworm",
}
});

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cdkactions_build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
name: codecov-umbrella
verbose: true
container:
image: python:3.9.14-buster
image: python:3.11-bookworm
env:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
services:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This repository is the Django-based successor to `labs-api-server`, containing A
- `git clone https://github.com/pennlabs/penn-mobile.git`
- `cd penn-mobile/backend`
- `brew install postgres`
- `pipenv install --dev --python 3.9`
- `pipenv install --dev --python 3.11`

Note that the above command will likely throw some ugly errors at you with regards to the `psycopg2` packages. If that is the case, just manually install them:
- `pipenv install psycopg2`
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pennlabs/django-base:4a5feb154cbce223ab108e775ca60af0f604f479-3.9.14
FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11

LABEL maintainer="Penn Labs"

Expand Down
14 changes: 7 additions & 7 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ verify_ssl = true
[dev-packages]
black = "==19.10b0"
unittest-xml-reporting = "*"
flake8 = "*"
flake8-isort = "*"
flake8-quotes = "*"
flake8 = "==6.1.0"
flake8-isort = "==6.1.0"
flake8-quotes = "==3.3.2"
django-extensions = "*"
flake8-absolute-import = "*"
rope = "*"
Expand All @@ -24,13 +24,13 @@ pandas = "*"
html5lib = "*"
psycopg2 = "*"
sentry-sdk = "*"
django = "==4.2.9"
django = "==5.0.2"
django-cors-headers = "*"
pyyaml = "*"
uritemplate = "*"
uwsgi = "*"
uwsgi = {version = "*", markers = "sys_platform== 'linux'"}
django-filter = "*"
django-labs-accounts = "*"
django-labs-accounts = "==0.9.5"
django-debug-toolbar = "*"
django-runtime-options = "*"
django-storages = "*"
Expand All @@ -47,4 +47,4 @@ python-dateutil = "*"
selenium = "*"

[requires]
python_version = "3.9.14"
python_version = "3.11"
1,294 changes: 598 additions & 696 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions backend/user/notifications.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import collections
import os
import sys


# Monkey Patch for apn2 errors, referenced from:
# https://github.com/jazzband/django-push-notifications/issues/622
if sys.version_info.major >= 3 and sys.version_info.minor >= 10:
"""
The apns2 package is throwing errors because some aliases in collections
were removed in 3.10. Specifically, the error is coming from a dependency
of apns2 named hyper.
"""
from collections import abc

collections.Iterable = abc.Iterable
collections.Mapping = abc.Mapping
collections.MutableSet = abc.MutableSet
collections.MutableMapping = abc.MutableMapping

from apns2.client import APNsClient
from apns2.credentials import TokenCredentials
Expand Down

0 comments on commit 10be4f0

Please sign in to comment.