Skip to content

Commit

Permalink
Merge pull request #140 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 d018b7b + 584ce36 commit 673589c
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 352 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-reserved-keywords.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.12

- name: Install pip
run: pip install -r requirements/pip.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: ["py38", "quality", "pii_check"]
python-version: ['3.12']
toxenv: ["py312", "quality", "pii_check"]

steps:
- uses: actions/checkout@v2
Expand All @@ -37,7 +37,7 @@ jobs:
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'py38'
if: matrix.python-version == '3.12' && matrix.toxenv == 'py312'
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.12

- name: Install pip
run: pip install -r requirements/pip.txt
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 @@ -14,7 +14,7 @@ jobs:
uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master
with:
branch: ${{ github.event.inputs.branch || 'main' }}
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
35 changes: 31 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,50 @@ MAINTAINER [email protected]

# gcc; for compiling python extensions distributed with python packages like mysql-client

# 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

# If you add a package here please include a comment above describing what it is used for
RUN apt-get update && apt-get -qy install --no-install-recommends \
language-pack-en \
locales \
python3.8 \
python3-pip \
# libmysqlclient-dev header files needed to use native C implementation for MySQL-python for performance gains.
libmysqlclient-dev \
# mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620)
pkg-config \
# mysqlclient wont install without libssl-dev
libssl-dev \
python3-dev \
build-essential \
gcc
gcc \
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

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

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
Expand All @@ -57,6 +81,9 @@ WORKDIR /edx/app/program-intent-engagement
# this prevents the image cache from busting unless the dependencies have changed.
COPY requirements/production.txt /edx/app/program-intent-engagement/requirements/production.txt

ARG INTENT_MANAGEMENT_VENV_DIR="/edx/app/venvs/program-intent-management"
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${INTENT_MANAGEMENT_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
30 changes: 12 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 @@ -8,13 +8,9 @@ asgiref==3.8.1
# via
# django
# django-cors-headers
backports-zoneinfo==0.2.1
# via
# django
# djangorestframework
certifi==2024.7.4
certifi==2024.8.30
# via requests
cffi==1.17.0
cffi==1.17.1
# via
# cryptography
# pynacl
Expand All @@ -28,15 +24,15 @@ coreapi==2.3.3
# openapi-codec
coreschema==0.0.4
# via coreapi
cryptography==43.0.0
cryptography==43.0.1
# via
# pyjwt
# social-auth-core
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.15
django==4.2.16
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
Expand All @@ -61,7 +57,7 @@ django-crum==0.7.9
# via edx-django-utils
django-extensions==3.2.3
# via -r requirements/base.in
django-model-utils==4.5.1
django-model-utils==5.0.0
# via -r requirements/base.in
django-rest-swagger==2.2.0
# via -r requirements/base.in
Expand Down Expand Up @@ -95,13 +91,13 @@ 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==5.7.1
# via -r requirements/base.in
idna==3.7
idna==3.8
# via requests
inflection==0.5.1
# via drf-yasg
Expand All @@ -123,7 +119,7 @@ openapi-codec==1.3.2
# via django-rest-swagger
packaging==24.1
# via drf-yasg
pbr==6.0.0
pbr==6.1.0
# via stevedore
psutil==6.0.0
# via edx-django-utils
Expand Down Expand Up @@ -178,14 +174,12 @@ social-auth-core==4.5.4
# social-auth-app-django
sqlparse==0.5.1
# via django
stevedore==5.2.0
stevedore==5.3.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.12.2
# via
# asgiref
# edx-opaque-keys
# via edx-opaque-keys
uritemplate==4.1.1
# via
# coreapi
Expand Down
6 changes: 1 addition & 5 deletions requirements/ci.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 Down Expand Up @@ -30,10 +30,6 @@ pluggy==1.5.0
# via tox
pyproject-api==1.7.1
# via tox
tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.18.0
# via -r requirements/ci.in
virtualenv==20.26.3
Expand Down
Loading

0 comments on commit 673589c

Please sign in to comment.