Skip to content

Commit

Permalink
Merge pull request #335 from edx/python312-upgrade
Browse files Browse the repository at this point in the history
This commits upgrades this repository to use Python 3.12 instead of Python 3.8.

This was motivated by Python 3.8's end-of-life in October of 2024.
  • Loading branch information
MichaelRoytman authored Sep 9, 2024
2 parents 314d833 + 2a97852 commit 95830f3
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 281 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.12"]
toxenv: [django42, quality, pii_check, check_keywords]
steps:
- uses: actions/checkout@v2
Expand All @@ -29,7 +29,7 @@ jobs:
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: Codecov
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
if: matrix.python-version == '3.12' && matrix.toxenv == 'django42'
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mysql8-migrations-check.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: 31 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
FROM ubuntu:focal as app
MAINTAINER sre@edx.org

# 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

# Packages installed:

# pkg-config; mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620)

RUN apt-get update && apt-get -qy install --no-install-recommends \
build-essential \
language-pack-en \
locales \
python3.8 \
python3-pip \
libmysqlclient-dev \
pkg-config \
libssl-dev \
python3-dev \
gcc \
make

make \
curl \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils

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

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

# 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

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
Expand All @@ -34,11 +55,16 @@ EXPOSE 18808
RUN useradd -m --shell /bin/false app

WORKDIR /edx/app/designer
ARG DESIGNER_VENV_DIR="/edx/app/venvs/designer"
ENV PATH="$DESIGNER_VENV_DIR/bin:$PATH"

# Copy the requirements explicitly even though we copy everything below
# this prevents the image cache from busting unless the dependencies have changed.
COPY requirements/production.txt /edx/app/designer/requirements/production.txt

# Create virtualenv to install requirements
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${DESIGNER_VENV_DIR}

# Dependencies are installed as root so they cannot be modified by the application user.
RUN pip install -r requirements/production.txt

Expand Down
44 changes: 17 additions & 27 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 @@ -10,30 +10,25 @@ asgiref==3.8.1
# via
# django
# django-cors-headers
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# django
# djangorestframework
beautifulsoup4==4.12.3
# via wagtail
boto3==1.35.1
boto3==1.35.12
# via -r requirements/base.in
botocore==1.35.1
botocore==1.35.12
# via
# boto3
# s3transfer
certifi==2024.7.4
certifi==2024.8.30
# via requests
cffi==1.17.0
cffi==1.17.1
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via edx-django-utils
cryptography==43.0.0
cryptography==43.0.1
# via
# pyjwt
# social-auth-core
Expand All @@ -42,7 +37,7 @@ defusedxml==0.8.0rc2
# python3-openid
# social-auth-core
# willow
django==4.2.15
django==4.2.16
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
Expand Down Expand Up @@ -120,9 +115,9 @@ edx-django-utils==5.15.0
# -r requirements/base.in
# edx-drf-extensions
# edx-rest-api-client
edx-drf-extensions==10.3.0
edx-drf-extensions==10.4.0
# via -r requirements/base.in
edx-opaque-keys==2.10.0
edx-opaque-keys==2.11.0
# via edx-drf-extensions
edx-rest-api-client==4.0.1
# via
Expand All @@ -132,10 +127,8 @@ et-xmlfile==1.1.0
# via openpyxl
filetype==1.2.0
# via willow
idna==3.7
idna==3.8
# via requests
importlib-metadata==8.3.0
# via typeguard
inflect==7.3.1
# via -r requirements/base.in
inflection==0.5.1
Expand Down Expand Up @@ -164,7 +157,7 @@ openpyxl==3.1.5
# via wagtail
packaging==24.1
# via drf-yasg
pbr==6.0.0
pbr==6.1.0
# via stevedore
pillow==10.4.0
# via
Expand Down Expand Up @@ -238,7 +231,7 @@ soupsieve==2.6
# via beautifulsoup4
sqlparse==0.5.1
# via django
stevedore==5.2.0
stevedore==5.3.0
# via
# edx-django-utils
# edx-opaque-keys
Expand All @@ -248,26 +241,23 @@ typeguard==4.3.0
# via inflect
typing-extensions==4.12.2
# via
# asgiref
# edx-opaque-keys
# inflect
# typeguard
uritemplate==4.1.1
# via drf-yasg
urllib3==1.26.19
urllib3==1.26.20
# via
# -c requirements/constraints.txt
# botocore
# requests
wagtail==6.2
wagtail==6.2.1
# via -r requirements/base.in
willow[heif]==1.8.0
# via
# wagtail
# willow
zipp==3.20.0
# via
# -r requirements/base.in
# importlib-metadata
zipp==3.20.1
# via -r requirements/base.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
5 changes: 2 additions & 3 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ edx_rest_api_client==4.0.1 # versions>4.0.1 have backward incompatible chan
# Django5 release is inline. So better to add constraint.
Django<4.3


# Temporary to Support the python 3.11 Upgrade
backports.zoneinfo;python_version<"3.9" # Newer versions have zoneinfo available in the standard library
# Needed for botocore==1.34.151 support
urllib3<1.27
Loading

0 comments on commit 95830f3

Please sign in to comment.