Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
feat!: Python 3.12 Upgrade (#636)
Browse files Browse the repository at this point in the history
* feat!: Python 3.12 Upgrade
  • Loading branch information
UsamaSadiq authored Aug 1, 2024
1 parent 83f75bd commit fd4efc8
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 295 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8', '3.12']
python-version: ['3.12']
toxenv: [django42]
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mysql8-check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-20.04 ]
python-version: [ 3.8 ]
python-version: [ 3.12 ]

steps:
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-python-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master
with:
branch: ${{ github.event.inputs.branch || 'master' }}
python_version: "3.8"
python_version: "3.12"
# optional parameters below; fill in if you'd like github or email notifications
# user_reviewers: ""
# team_reviewers: ""
Expand Down
36 changes: 28 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
FROM ubuntu:focal as app

# ENV variables for Python 3.12 support
ARG PYTHON_VERSION=3.12
ENV TZ=UTC
ENV TERM=xterm-256color
ENV DEBIAN_FRONTEND=noninteractive

# software-properties-common is needed to setup Python 3.12 env
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa

# System requirements.
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -qy \
git-core \
language-pack-en \
build-essential \
python3.8 \
python3-pip \
python3-virtualenv \
python3.8-dev \
# libmysqlclient-dev header files needed to use native C implementation for MySQL-python for performance gains.
libmysqlclient-dev \
# mysqlclient wont install without libssl-dev
libssl-dev \
# mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620)
pkg-config \
&& \
# delete apt package lists because we do not need them inflating our image
rm -rf /var/lib/apt/lists/*
curl \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils

# need to use virtualenv pypi package with Python 3.12
RUN pip install --upgrade pip setuptools
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# delete apt package lists because we do not need them inflating our image
RUN rm -rf /var/lib/apt/lists/*

# Python is Python3.
RUN ln -s /usr/bin/python3 /usr/bin/python

# Setup zoneinfo for Python 3.12
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Use UTF-8.
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
Expand All @@ -44,7 +64,7 @@ COPY requirements ${REGISTRAR_CODE_DIR}/requirements
# Working directory will be root of repo.
WORKDIR ${REGISTRAR_CODE_DIR}

RUN virtualenv -p python3.8 --always-copy ${REGISTRAR_VENV_DIR}
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${REGISTRAR_VENV_DIR}

# Copy just Python requirements & install them.
COPY requirements ${REGISTRAR_CODE_DIR}/requirements
Expand Down
22 changes: 4 additions & 18 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# make upgrade
Expand All @@ -12,17 +12,8 @@ asgiref==3.8.1
# via
# django
# django-cors-headers
async-timeout==4.0.3
# via redis
backoff==1.10.0
# via analytics-python
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# celery
# django
# djangorestframework
# kombu
billiard==4.2.0
# via celery
celery==5.4.0
Expand Down Expand Up @@ -198,7 +189,7 @@ pyyaml==6.0.1
# via
# drf-yasg
# edx-django-release-util
redis==5.0.7
redis==5.0.8
# via -r requirements/base.in
requests==2.32.3
# via
Expand Down Expand Up @@ -237,14 +228,9 @@ stevedore==5.2.0
text-unidecode==1.3
# via python-slugify
typing-extensions==4.12.2
# via
# asgiref
# edx-opaque-keys
# kombu
# via edx-opaque-keys
tzdata==2024.1
# via
# backports-zoneinfo
# celery
# via celery
uritemplate==4.1.1
# via drf-yasg
urllib3==1.26.19
Expand Down
4 changes: 0 additions & 4 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ wrapt < 1.14.0
# At the time of adding this, the moto version 4.1.9 requires urllib3<1.27,>=1.25.4
urllib3<1.27,>=1.25.4

# backports.zoneinfo needed for Python 3.12 + Django 4.2 compatibility
# Can be removed once requirements have been upgraded with Python>=3.9
backports.zoneinfo; python_version<'3.9'

# path>16.14.0 has removed the deprecated abspath function, which is breaking the docs build
path<16.15.0
65 changes: 13 additions & 52 deletions requirements/devstack.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# make upgrade
#
accessible-pygments==0.0.4
accessible-pygments==0.0.5
# via
# -r requirements/local.txt
# pydata-sphinx-theme
alabaster==0.7.13
alabaster==1.0.0
# via
# -r requirements/local.txt
# sphinx
Expand All @@ -28,10 +28,6 @@ astroid==3.2.4
# -r requirements/local.txt
# pylint
# pylint-celery
async-timeout==4.0.3
# via
# -r requirements/local.txt
# redis
babel==2.15.0
# via
# -r requirements/local.txt
Expand All @@ -41,14 +37,6 @@ backoff==1.10.0
# via
# -r requirements/local.txt
# analytics-python
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/local.txt
# celery
# django
# djangorestframework
# kombu
beautifulsoup4==4.12.3
# via
# -r requirements/local.txt
Expand Down Expand Up @@ -231,7 +219,7 @@ dnspython==2.6.1
# via
# -r requirements/local.txt
# pymongo
docutils==0.19
docutils==0.21.2
# via
# -r requirements/local.txt
# pydata-sphinx-theme
Expand Down Expand Up @@ -268,10 +256,6 @@ edx-opaque-keys==2.10.0
# edx-drf-extensions
edx-rest-api-client==5.7.1
# via -r requirements/local.txt
exceptiongroup==1.2.2
# via
# -r requirements/local.txt
# pytest
factory-boy==3.3.0
# via -r requirements/local.txt
faker==26.0.0
Expand All @@ -293,11 +277,6 @@ imagesize==1.4.1
# via
# -r requirements/local.txt
# sphinx
importlib-metadata==6.11.0
# via
# -c requirements/common_constraints.txt
# -r requirements/local.txt
# sphinx
inflection==0.5.1
# via
# -r requirements/local.txt
Expand Down Expand Up @@ -416,7 +395,7 @@ pycparser==2.22
# via
# -r requirements/local.txt
# cffi
pydata-sphinx-theme==0.14.4
pydata-sphinx-theme==0.15.4
# via
# -r requirements/local.txt
# sphinx-book-theme
Expand Down Expand Up @@ -501,7 +480,6 @@ python3-openid==3.2.0
pytz==2024.1
# via
# -r requirements/local.txt
# babel
# drf-yasg
pywatchman==2.0.0
# via -r requirements/local.txt
Expand All @@ -513,7 +491,7 @@ pyyaml==6.0.1
# edx-django-release-util
# edx-i18n-tools
# yamllint
redis==5.0.7
redis==5.0.8
# via -r requirements/local.txt
requests==2.32.3
# via
Expand Down Expand Up @@ -595,34 +573,34 @@ soupsieve==2.5
# via
# -r requirements/local.txt
# beautifulsoup4
sphinx==6.2.1
sphinx==8.0.2
# via
# -r requirements/local.txt
# pydata-sphinx-theme
# sphinx-book-theme
sphinx-book-theme==1.0.1
sphinx-book-theme==1.1.3
# via -r requirements/local.txt
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-applehelp==2.0.0
# via
# -r requirements/local.txt
# sphinx
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-devhelp==2.0.0
# via
# -r requirements/local.txt
# sphinx
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-htmlhelp==2.1.0
# via
# -r requirements/local.txt
# sphinx
sphinxcontrib-jsmath==1.0.1
# via
# -r requirements/local.txt
# sphinx
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-qthelp==2.0.0
# via
# -r requirements/local.txt
# sphinx
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib-serializinghtml==2.0.0
# via
# -r requirements/local.txt
# sphinx
Expand All @@ -641,14 +619,6 @@ text-unidecode==1.3
# via
# -r requirements/local.txt
# python-slugify
tomli==2.0.1
# via
# -r requirements/local.txt
# coverage
# pylint
# pyproject-api
# pytest
# tox
tomlkit==0.13.0
# via
# -r requirements/local.txt
Expand All @@ -658,16 +628,11 @@ tox==4.16.0
typing-extensions==4.12.2
# via
# -r requirements/local.txt
# asgiref
# astroid
# edx-opaque-keys
# kombu
# pydata-sphinx-theme
# pylint
tzdata==2024.1
# via
# -r requirements/local.txt
# backports-zoneinfo
# celery
uritemplate==4.1.1
# via
Expand Down Expand Up @@ -704,7 +669,3 @@ xmltodict==0.13.0
# moto
yamllint==1.35.1
# via -r requirements/local.txt
zipp==3.19.2
# via
# -r requirements/local.txt
# importlib-metadata
Loading

0 comments on commit fd4efc8

Please sign in to comment.