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

Support Python 3.12 #78

Merged
merged 1 commit into from
Mar 13, 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
1 change: 1 addition & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12'

steps:
- name: Check out code
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Unreleased
* [Enhancement] Support Python 3.12.

## Version 3.1.0 (2024-01-12)

* [Enhancement] Support Tutor 17 and Open edX Quince.
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[tox]
envlist = gitlint,py{38,39,310,311},flake8
envlist = gitlint,py{38,39,310,311,312},flake8

[gh-actions]
python =
3.8: gitlint,py38,flake8
3.9: gitlint,py39,flake8
3.10: gitlint,py310,flake8
3.11: gitlint,py311,flake8
3.12: gitlint,py312,flake8

[flake8]
ignore = E124,W504
Expand Down
5 changes: 2 additions & 3 deletions tutorbackup/__about__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pkg_resources
from importlib import metadata
# __version__ attribute as suggested by (deferred) PEP 396:
# https://www.python.org/dev/peps/pep-0396/
#
# Single-source package definition as suggested (among several
# options) by:
# https://packaging.python.org/guides/single-sourcing-package-version/
__version__ = pkg_resources.get_distribution(
'tutor-contrib-backup').version
__version__ = metadata.version('tutor-contrib-backup')
16 changes: 8 additions & 8 deletions tutorbackup/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from .__about__ import __version__
from glob import glob
import os
import pkg_resources
# When Tutor drops support for Python 3.8, we'll need to update this to:
# from importlib import resources as importlib_resources
# See: https://github.com/overhangio/tutor/issues/966#issuecomment-1938681102
import importlib_resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't add any dependency on importlib_resources in this change, and we don't need to, because we do depend on tutor, which as of overhangio/tutor@d99b2fe does have that dependency.

As explained in overhangio/tutor#966 (comment), Tutor will drop that dependency once it no longer wants to support Python 3.8. At that point, this import statement will also break, and we will replace it with

from importlib import resources as importlib_resources

Perhaps we want to add a comment to that effect now, as a benefit to our future selves?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yes, sounds like a good idea, thanks!

import click
from tutor import hooks
from tutor import config as tutor_config
Expand Down Expand Up @@ -154,7 +157,7 @@ def restore(context, date, version, exclude, list_versions): # noqa: F811

# Add the "templates" folder as a template root
hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
pkg_resources.resource_filename("tutorbackup", "templates")
str(importlib_resources.files("tutorbackup") / "templates")
)
# Render the "build" and "apps" folders
hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
Expand All @@ -164,12 +167,9 @@ def restore(context, date, version, exclude, list_versions): # noqa: F811
],
)
# Load patches from files
for path in glob(
os.path.join(
pkg_resources.resource_filename("tutorbackup", "patches"),
"*",
)
):
for path in glob(str(
importlib_resources.files("tutorbackup") / "patches" / "*")):

with open(path, encoding="utf-8") as patch_file:
hooks.Filters.ENV_PATCHES.add_item(
(os.path.basename(path), patch_file.read())
Expand Down
Loading