Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.12 #392

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['py38']
python-version: ['py38', 'py312']
django-version: ['django42']
db-version: ['mysql80']

Expand All @@ -26,6 +27,11 @@ jobs:
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "apt-get update && apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config"
- name: setup python
if: ${{ matrix.python-version == 'py312' }}
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "add-apt-repository ppa:deadsnakes/ppa -y && apt install python3.12 python3.12-dev python3.12-distutils -y"
- name: Run Tests
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.ci/run_tests.sh
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/migrations-mysql8-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ jobs:
name: check migrations
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04 ]
python-version: [ 3.8 ]
python-version: [ '3.8', '3.12' ]

steps:
- name: Checkout repo
Expand Down
12 changes: 9 additions & 3 deletions notesapi/v1/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import unittest
from calendar import timegm
from datetime import datetime, timedelta
Expand Down Expand Up @@ -387,9 +388,14 @@ def test_read_all_no_annotations(self):
headers["course_id"] = "a/b/c"
response = self.client.get(reverse('api:v1:annotations'), headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictContainsSubset(
{'total': 0, 'rows': []}, response.data, "no annotation should be returned in response"
)
if sys.version_info[1] == 12: # python 3.12
self.assertEqual(
irtazaakram marked this conversation as resolved.
Show resolved Hide resolved
{'total': 0, 'rows': []} | response.data, response.data, "no annotation should be returned in response"
)
else: # remove this code after removing python 3.8 dependency
self.assertDictContainsSubset(
{'total': 0, 'rows': []}, response.data, "no annotation should be returned in response"
)

def test_read_all(self):
"""
Expand Down
18 changes: 10 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#
asgiref==3.7.2
# via django
backports-zoneinfo==0.2.1
# via django
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# django
certifi==2024.2.2
# via
# elasticsearch
Expand All @@ -20,11 +22,11 @@ chardet==3.0.4
# via requests
click==8.1.7
# via edx-django-utils
cryptography==42.0.2
cryptography==42.0.5
# via pyjwt
django==4.2.10
django==4.2.11
# via
# -c requirements/constraints.txt
# -c requirements/common_constraints.txt
# -r requirements/base.in
# django-cors-headers
# django-crum
Expand Down Expand Up @@ -97,7 +99,7 @@ inflection==0.5.1
# via drf-yasg
mysqlclient==2.2.4
# via -r requirements/base.in
newrelic==9.6.0
newrelic==9.7.0
# via
# -r requirements/base.in
# edx-django-utils
Expand Down Expand Up @@ -154,11 +156,11 @@ six==1.16.0
# python-dateutil
sqlparse==0.4.4
# via django
stevedore==5.1.0
stevedore==5.2.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# asgiref
# edx-opaque-keys
Expand Down
6 changes: 3 additions & 3 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
cachetools==5.3.2
cachetools==5.3.3
# via tox
chardet==5.2.0
# via tox
Expand Down Expand Up @@ -32,7 +32,7 @@ tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.12.1
tox==4.13.0
# via -r requirements/ci.in
virtualenv==20.25.0
virtualenv==20.25.1
# via tox
28 changes: 28 additions & 0 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a temporary solution to override the real common_constraints.txt
# In edx-lint, until the pyjwt constraint in edx-lint has been removed.
# See BOM-2721 for more details.
# Below is the copied and edited version of common_constraints

# A central location for most common version constraints
# (across edx repos) for pip-installation.
#
# Similar to other constraint files this file doesn't install any packages.
# It specifies version constraints that will be applied if a package is needed.
# When pinning something here, please provide an explanation of why it is a good
# idea to pin this package across all edx repos, Ideally, link to other information
# that will help people in the future to remove the pin when possible.
# Writing an issue against the offending project and linking to it here is good.
#
# Note: Changes to this file will automatically be used by other repos, referencing
# this file from Github directly. It does not require packaging in edx-lint.


# using LTS django version
Django<5.0

# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
elasticsearch<7.14.0

# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected
django-simple-history==3.0.0
4 changes: 2 additions & 2 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ more-itertools==5.0.0
pylint==1.5.0
django-cors-headers==3.14.0

# Stay on LTS
Django<5.0

backports-zoneinfo==0.2.1; python_version < '3.9'
2 changes: 1 addition & 1 deletion requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==4.2.10
django==4.2.11
8 changes: 5 additions & 3 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
#
# make upgrade
#
build==1.0.3
build==1.1.1
# via pip-tools
click==8.1.7
# via pip-tools
importlib-metadata==7.0.1
# via build
packaging==23.2
# via build
pip-tools==7.3.0
pip-tools==7.4.0
# via -r requirements/pip-tools.in
pyproject-hooks==1.0.0
# via build
# via
# build
# pip-tools
tomli==2.0.1
# via
# build
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ wheel==0.42.0
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r requirements/pip.in
setuptools==69.1.0
setuptools==69.1.1
# via -r requirements/pip.in
24 changes: 12 additions & 12 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ astroid==1.6.6
# -c requirements/constraints.txt
# -r requirements/test.in
# pylint
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# django
certifi==2024.2.2
Expand All @@ -41,22 +42,22 @@ code-annotations==1.6.0
# via -r requirements/test.in
colorama==0.4.6
# via pylint
coverage[toml]==7.4.1
coverage[toml]==7.4.3
# via
# -r requirements/test.in
# pytest-cov
cryptography==42.0.2
cryptography==42.0.5
# via
# -r requirements/base.txt
# pyjwt
ddt==1.7.1
ddt==1.7.2
# via -r requirements/test.in
diff-cover==8.0.3
# via -r requirements/test.in
distlib==0.3.8
# via virtualenv
# via
# -c requirements/constraints.txt
# -c requirements/common_constraints.txt
# -r requirements/base.txt
# django-cors-headers
# django-crum
Expand Down Expand Up @@ -134,7 +135,7 @@ exceptiongroup==1.2.0
# via pytest
factory-boy==3.3.0
# via -r requirements/test.in
faker==23.2.0
faker==24.0.0
# via factory-boy
filelock==3.13.1
# via
Expand Down Expand Up @@ -166,7 +167,7 @@ more-itertools==5.0.0
# -r requirements/test.in
mysqlclient==2.2.4
# via -r requirements/base.txt
newrelic==9.6.0
newrelic==9.7.0
# via
# -r requirements/base.txt
# edx-django-utils
Expand Down Expand Up @@ -212,7 +213,6 @@ pyjwt[crypto]==2.8.0
# -r requirements/base.txt
# drf-jwt
# edx-drf-extensions
# pyjwt
pylint==1.5.0
# via
# -c requirements/constraints.txt
Expand All @@ -225,7 +225,7 @@ pynacl==1.5.0
# via
# -r requirements/base.txt
# edx-django-utils
pytest==8.0.0
pytest==8.0.2
# via
# -r requirements/test.in
# pytest-cov
Expand Down Expand Up @@ -278,7 +278,7 @@ sqlparse==0.4.4
# via
# -r requirements/base.txt
# django
stevedore==5.1.0
stevedore==5.2.0
# via
# -r requirements/base.txt
# code-annotations
Expand All @@ -293,7 +293,7 @@ tomli==2.0.1
# tox
tox==3.28.0
# via -r requirements/test.in
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# -r requirements/base.txt
# asgiref
Expand All @@ -308,7 +308,7 @@ urllib3==1.26.18
# -r requirements/base.txt
# elasticsearch
# requests
virtualenv==20.25.0
virtualenv==20.25.1
# via tox
wrapt==1.16.0
# via astroid
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[tox]
envlist = py38-django{42}
envlist = py{38,312}-django{42}
skipsdist = true

[testenv]
deps =
django42: Django>=4.2,<4.3
deps =
setuptools
django42: Django>=4.2,<5.0
-r {toxinidir}/requirements/test.txt
passenv =
passenv =
CONN_MAX_AGE
DB_ENGINE
DB_HOST
Expand All @@ -16,7 +17,7 @@ passenv =
DB_USER
ENABLE_DJANGO_TOOLBAR
ELASTICSEARCH_URL
allowlist_externals =
allowlist_externals =
make
commands =
commands =
make validate
Loading