Skip to content

Commit

Permalink
build: add support for python 3.12 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsobanjaved authored Sep 11, 2024
1 parent 335b793 commit 32f0263
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 19 deletions.
8 changes: 7 additions & 1 deletion .github/docker-compose-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ services:
ELASTICSEARCH_LEARNERS_UPDATE_INDEX: 'index_update'
command: /edx/app/analytics_api/venvs/analytics_api/bin/python /edx/app/analytics_api/analytics_api/manage.py runserver 0.0.0.0:80 --settings analyticsdataserver.settings.local
insights:
image: edxops/insights:latest
# Use this image once the Python version upgrade is complete
# image: edxops/insights:latest
build:
context: ../.
target: dev
args:
PYTHON_VERSION: "${PYTHON_VERSION}"
container_name: insights_testing
volumes:
- ..:/edx/app/insights/edx_analytics_dashboard
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.8", "3.12"]
os: [ubuntu-20.04]
toxenv: [django42]
node: [16]
Expand All @@ -21,11 +21,26 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Format Python Version
id: format_python_version
shell: bash
run: |
# Replace the dot in the Python version and remove 'py'
FORMATTED_VERSION=${{ matrix.python-version }} # e.g., 3.12
FORMATTED_VERSION=${FORMATTED_VERSION//./} # becomes 312
# Set environment variables
echo "FORMATTED_PYTHON_VERSION=py${FORMATTED_VERSION}" >> $GITHUB_ENV
# Output formatted version for use in subsequent steps
echo "Formatted Python Version: py${FORMATTED_VERSION}"
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: start container
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: docker compose -f .github/docker-compose-github.yml up -d
- name: setup analytics-api
run: |
Expand All @@ -41,37 +56,37 @@ jobs:
env:
TESTNAME: quality
TARGETS: "quality"
TOXENV: ${{ matrix.toxenv }}
TOXENV: ${{ env.FORMATTED_PYTHON_VERSION }}-${{ matrix.toxenv }}
- name: test js
run: ./.github/scripts/testing-js.sh
shell: bash
env:
TESTNAME: js
NODE: ${{ matrix.node }}
TOXENV: ${{ matrix.toxenv }}
TOXENV: ${{ env.FORMATTED_PYTHON_VERSION }}-${{ matrix.toxenv }}
TARGETS: "requirements.js validate_js"
- name: test i18n
run: ./.github/scripts/testing.sh
shell: bash
env:
TESTNAME: test-i18n
TOXENV: ${{ matrix.toxenv }}
TOXENV: ${{ env.FORMATTED_PYTHON_VERSION }}-${{ matrix.toxenv }}
TARGETS: "generate_fake_translations"
- name: test acceptance
run: ./.github/scripts/testing-js.sh
shell: bash
env:
TESTNAME: acceptance
NODE: ${{ matrix.node }}
TOXENV: ${{ matrix.toxenv }}
TOXENV: ${{ env.FORMATTED_PYTHON_VERSION }}-${{ matrix.toxenv }}
TARGETS: "requirements.a11y migrate requirements.js static accept"
- name: test python
run: ./.github/scripts/testing-js.sh
shell: bash
env:
TESTNAME: test-python
NODE: ${{ matrix.node }}
TOXENV: ${{ matrix.toxenv }}
TOXENV: ${{ env.FORMATTED_PYTHON_VERSION }}-${{ matrix.toxenv }}
TARGETS: "requirements.js static test_python"
- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ FROM ubuntu:focal as app

ENV DEBIAN_FRONTEND noninteractive

ARG PYTHON_VERSION=3.8

# Packages installed:

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

RUN apt-get update && apt-get install --no-install-recommends -qy \
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa && \
apt-get install --no-install-recommends -qy \
language-pack-en \
build-essential \
python3.8-dev \
python3-virtualenv \
python3.8-distutils \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils \
libmysqlclient-dev \
pkg-config \
libssl-dev \
Expand Down Expand Up @@ -42,9 +46,13 @@ ARG INSIGHTS_NODEENV_DIR="${COMMON_APP_DIR}/insights/nodeenvs/insights"
ENV PATH "${INSIGHTS_VENV_DIR}/bin:${INSIGHTS_NODEENV_DIR}/bin:$PATH"
ENV INSIGHTS_APP_DIR ${INSIGHTS_APP_DIR}
ENV THEME_SCSS "sass/themes/open-edx.scss"
ENV PYTHON_VERSION "${PYTHON_VERSION}"

RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# No need to activate insights virtualenv as it is already activated by putting in the path
RUN virtualenv -p python3.8 --always-copy ${INSIGHTS_VENV_DIR}
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${INSIGHTS_VENV_DIR}

COPY requirements ${INSIGHTS_CODE_DIR}/requirements

Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ asgiref==3.8.1
# via
# django
# django-countries
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# django
# djangorestframework
certifi==2024.7.4
Expand Down
3 changes: 3 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

-c common_constraints.txt

# Temporary to Support the python 3.12 Upgrade
backports.zoneinfo;python_version<"3.9" # Newer versions have zoneinfo available in the standard library

# Newer version of django-webpack-loader is not compatible with npm webpack-bundle-tracker > 0.4.3
django-webpack-loader==0.7.0

Expand Down
3 changes: 2 additions & 1 deletion requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ babel==2.16.0
# via
# pydata-sphinx-theme
# sphinx
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# django
# djangorestframework
Expand Down
4 changes: 2 additions & 2 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ astroid==3.2.4
# -r requirements/test.txt
# pylint
# pylint-celery
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/test.txt
# django
# djangorestframework
Expand Down Expand Up @@ -96,7 +97,6 @@ django==4.2.15
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/test.txt
# django-appconf
# django-braces
# django-crispy-forms
Expand Down
3 changes: 2 additions & 1 deletion requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ asgiref==3.8.1
# -r requirements/base.txt
# django
# django-countries
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# django
# djangorestframework
Expand Down
3 changes: 2 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ astroid==3.2.4
# -r requirements/test.in
# pylint
# pylint-celery
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# django
# djangorestframework
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-django{42}
envlist = py{38, 312}-django{42}
skipsdist = true

[pytest]
Expand Down

0 comments on commit 32f0263

Please sign in to comment.