Skip to content

Commit

Permalink
fix: Support for python 3.8 dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithEmad committed Oct 25, 2024
1 parent 7cd50cc commit a3561b6
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 153 deletions.
122 changes: 61 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [master]
pull_request:
branches:
- '**'
- "**"
workflow_dispatch:

defaults:
Expand All @@ -20,26 +20,26 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version:
- '3.12'
- "3.12"
toxenv: [py, quality]

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt
- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt
- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

# Tests that used to be in the cookiecutter-django-ida Makefile but
# that have not yet been moved into the regular unit tests (which
Expand All @@ -50,50 +50,50 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version:
- '3.12'
- "3.12"
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Generate demo project
run: |
make requirements
cookiecutter cookiecutter-django-ida --no-input
- name: "Post-gen: Virtualenv, and set up requirements"
working-directory: repo_name
run: |
virtualenv .venv
source .venv/bin/activate
make upgrade # TODO should be part of initial cookiecutter setup
make requirements
- name: "Post-gen: Migrations"
working-directory: repo_name
run: |
source .venv/bin/activate
python manage.py makemigrations
make migrate
- name: "Quality checks"
working-directory: repo_name
run: |
source .venv/bin/activate
make validate
- name: "Ensure translations can be compiled"
working-directory: repo_name
run: |
source .venv/bin/activate
sudo apt install gettext # required for msguniq, called by makemessages management command
make fake_translations
- name: "Ensure docker can build a container"
working-directory: repo_name
run: |
source .venv/bin/activate
docker build . --target app
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Generate demo project
run: |
make requirements
cookiecutter cookiecutter-django-ida --no-input
- name: "Post-gen: Virtualenv, and set up requirements"
working-directory: repo_name
run: |
virtualenv .venv
source .venv/bin/activate
make upgrade # TODO should be part of initial cookiecutter setup
make requirements
- name: "Post-gen: Migrations"
working-directory: repo_name
run: |
source .venv/bin/activate
python manage.py makemigrations
make migrate
- name: "Quality checks"
working-directory: repo_name
run: |
source .venv/bin/activate
make validate
- name: "Ensure translations can be compiled"
working-directory: repo_name
run: |
source .venv/bin/activate
sudo apt install gettext # required for msguniq, called by makemessages management command
make fake_translations
- name: "Ensure docker can build a container"
working-directory: repo_name
run: |
source .venv/bin/activate
docker build . --target app
2 changes: 1 addition & 1 deletion cookiecutter-django-app/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Enter the project and take a look around:
ls
Generate a virtualenv and generate requirements files with dependencies
pinned to current versions (make sure you're using pip 9.0.2+ and Python 3.8):
pinned to current versions (make sure you're using pip 23.2+ and Python 3.12):

.. code-block:: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
branches: [main]
pull_request:
branches:
- '**'

- "**"

jobs:
run_tests:
Expand All @@ -15,31 +14,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8']
toxenv: [quality, docs, pii_check, django32, django40]

python-version: ["3.12"]
toxenv: [quality, docs, pii_check, django42]
steps:
- uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django32'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.12' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion cookiecutter-django-ida/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A cookiecutter_ template for Open edX Django projects.

.. _cookiecutter: https://cookiecutter.readthedocs.org/en/latest/index.html

**This template produces a Python 3.8 project.**
**This template produces a Python 3.12 project.**

This cookiecutter template is intended for new edX independently deployable apps (IDAs). It includes the following packages:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install pip
run: pip install -r requirements/pip.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FROM ubuntu:focal as app
# If you add a package here please include a comment above describing what it is used for
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \
language-pack-en locales \
python3.8 python3-dev python3-pip \
python3.12 python3-dev python3-pip \
# The mysqlclient Python package has install-time dependencies
libmysqlclient-dev libssl-dev pkg-config \
gcc
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter-python-library/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A cookiecutter_ template for edX python projects. For django-related cookiecutte

.. _cookiecutter: https://cookiecutter.readthedocs.org/en/latest/index.html

**This template produces a Python 3.8 project.**
**This template produces a Python 3.12 project.**

This cookiecutter template is intended for new edX python libraries.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
branches: [main]
pull_request:
branches:
- '**'

- "**"

jobs:
run_tests:
Expand All @@ -15,31 +14,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8']
toxenv: [quality, docs, django32, django40]

python-version: ["3.12"]
toxenv: [quality, docs, django42]
steps:
- uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django32'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.12' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""TO-DO: Write a description of what this XBlock is."""

import os
from importlib import resources

from django.utils import translation
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Integer, Scope
try:
from xblock.utils.resources import ResourceLoader
except ModuleNotFoundError:
from xblockutils.resources import ResourceLoader
from xblock.utils.resources import ResourceLoader


resource_loader = ResourceLoader(__name__)

Expand All @@ -27,7 +27,7 @@ class {{cookiecutter.class_name}}(XBlock):
help="A simple counter, to show something happening",
)

def get_resource_string(self, path):
def resource_string(self, path):
"""
Retrieve string contents for the file path
"""
Expand Down Expand Up @@ -100,10 +100,8 @@ def _get_statici18n_js_url():
text_js = 'static/js/translations/{locale_code}/text.js'
lang_code = locale_code.split('-')[0]
for code in (locale_code, lang_code, 'en'):
import importlib.resources as resources

text_js_path = text_js.format(locale_code=code)
if resources.is_resource(resource_loader.module_name, text_js_path):
if resources.files(resource_loader.module_name).joinpath(text_js_path).is_file():
return text_js_path
return None

Expand Down
Loading

0 comments on commit a3561b6

Please sign in to comment.