Skip to content

Commit

Permalink
feat: add python 312 support
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq committed Apr 17, 2024
1 parent 886da91 commit a414fd7
Show file tree
Hide file tree
Showing 17 changed files with 1,521 additions and 23 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [py38]
python-version: ['3.8', '3.12']
django-version: [django42]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Start container
run: |
docker-compose -f .github/docker-compose-github.yml up -d
- name: Install test dependencies and run validation
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} -u root enterprise.catalog.app /edx/app/enterprise_catalog/enterprise_catalog/validate.sh
if [[ "${{ matrix.python-version }}" == "3.8" ]]; then
docker exec -e TOXENV=py38-${{ matrix.django-version }} -u root enterprise.catalog.app /edx/app/enterprise_catalog/enterprise_catalog/validate.sh
elif [[ "${{ matrix.python-version }}" == "3.12" ]]; then
docker exec -e TOXENV=py312-${{ matrix.django-version }} -u root enterprise.catalog.app /edx/app/enterprise_catalog/enterprise_catalog/validate.sh
fi
- name: Code Coverage
if: matrix.python-version == 'py38' && matrix.django-version=='django42'
if: matrix.python-version == '3.8' && matrix.django-version=='django42'
uses: codecov/codecov-action@v1
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ RUN apt-get update && apt-get -qy install --no-install-recommends \
git \
wget

ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get -qy install libffi-dev libsqlite3-dev python3-distutils

RUN apt-get update && apt-get install -y build-essential wget && \
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz && \
tar -xzvf Python-3.12.0.tgz && cd Python-3.12.0 && ./configure --enable-optimizations && \
make -j$(nproc) && make altinstall && python3.12 --version

ENV VIRTUAL_ENV=/venv
RUN python3.8 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ piptools: ## install pinned version of pip-compile and pip-sync

requirements: piptools dev_requirements ## sync to default requirements

requirements312: ## sync to requirements for local development with Python 3.12
pip3.12 install -qr requirements/pip-tools.txt
pip3.12 install -qr requirements/dev312.txt

dev_requirements: ## sync to requirements for local development
pip-sync -q requirements/dev.txt

Expand Down Expand Up @@ -99,9 +103,8 @@ html_coverage: ## generate and view HTML coverage report
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: $(COMMON_CONSTRAINTS_TXT) piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# Make sure to compile files after any other files they include!
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
sed 's/django-simple-history==3.0.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
sed -i 's/django-simple-history==//g' requirements/common_constraints.txt
pip-compile --allow-unsafe --rebuild --upgrade -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
Expand Down
2 changes: 1 addition & 1 deletion enterprise_catalog/apps/api_client/tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_retrieve_course_reviews_with_successful_response(
"total_enrollments": 300
}
})
assert mock_sleep.not_called()
mock_sleep.assert_not_called()

@mock.patch('enterprise_catalog.apps.api_client.discovery.time.sleep')
@mock.patch('enterprise_catalog.apps.api_client.discovery.LOGGER')
Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ attrs==23.2.0
# referencing
backoff==1.10.0
# via analytics-python
backports-zoneinfo[tzdata]==0.2.1
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# celery
# django
# djangorestframework
Expand Down
2 changes: 1 addition & 1 deletion requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Django<5.0
elasticsearch<7.14.0

# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected
3.0.0


# opentelemetry requires version 6.x at the moment:
# https://github.com/open-telemetry/opentelemetry-python/issues/3570
Expand Down
3 changes: 3 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ astroid<2.12

# To avoid any breaking changes
openai<=1.13.3

# For python greater than or equal to 3.9 backports.zoneinfo causing failures
backports.zoneinfo; python_version<'3.9'
18 changes: 15 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ backoff==1.10.0
# -r requirements/quality.txt
# -r requirements/test.txt
# analytics-python
backports-zoneinfo[tzdata]==0.2.1
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/quality.txt
# -r requirements/test.txt
# celery
Expand Down Expand Up @@ -137,6 +138,7 @@ click-repl==0.3.0
# -r requirements/quality.txt
# -r requirements/test.txt
# celery
code-annotations==1.8.0
code-annotations==1.8.0
# via
# -r requirements/quality.txt
Expand Down Expand Up @@ -224,6 +226,7 @@ django-clearcache==1.2.1
# via
# -r requirements/quality.txt
# -r requirements/test.txt
django-config-models==2.7.0
django-config-models==2.7.0
# via
# -r requirements/quality.txt
Expand Down Expand Up @@ -251,6 +254,7 @@ django-log-request-id==2.1.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
django-model-utils==4.5.0
django-model-utils==4.5.0
# via
# -r requirements/quality.txt
Expand Down Expand Up @@ -290,18 +294,22 @@ drf-jwt==1.19.2
# -r requirements/quality.txt
# -r requirements/test.txt
# edx-drf-extensions
drf-spectacular==0.27.2
drf-spectacular==0.27.2
# via
# -r requirements/quality.txt
# -r requirements/test.txt
edx-auth-backends==4.3.0
edx-auth-backends==4.3.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
edx-celeryutils==1.3.0
edx-celeryutils==1.3.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
edx-django-release-util==1.4.0
edx-django-release-util==1.4.0
# via
# -r requirements/quality.txt
Expand Down Expand Up @@ -335,10 +343,12 @@ edx-rbac==1.8.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
edx-rest-api-client==5.7.0
edx-rest-api-client==5.7.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
edx-toggles==5.2.0
edx-toggles==5.2.0
# via
# -r requirements/quality.txt
Expand All @@ -351,7 +361,7 @@ exceptiongroup==1.2.0
# pytest
factory-boy==3.3.0
# via -r requirements/test.txt
faker==24.9.0
faker==24.7.1
# via
# -r requirements/test.txt
# factory-boy
Expand Down Expand Up @@ -458,6 +468,7 @@ lazy-object-proxy==1.10.0
# -r requirements/quality.txt
# -r requirements/test.txt
# astroid
lxml==5.2.1
lxml==5.2.1
# via edx-i18n-tools
markupsafe==2.1.5
Expand Down Expand Up @@ -510,7 +521,7 @@ packaging==24.0
# pyproject-api
# pytest
# tox
path==16.14.0
path==16.12.1
# via edx-i18n-tools
pbr==6.0.0
# via
Expand Down Expand Up @@ -818,6 +829,7 @@ tqdm==4.66.2
# -r requirements/quality.txt
# -r requirements/test.txt
# openai
typing-extensions==4.11.0
typing-extensions==4.11.0
# via
# -r requirements/quality.txt
Expand Down
Loading

0 comments on commit a414fd7

Please sign in to comment.