Skip to content

Commit

Permalink
Drop support for Python 3.8 and XBlock<2
Browse files Browse the repository at this point in the history
* Drop support for Python 3.8 and Xblock <2.
* Remove Python 3.8 and pip 22.0.4 from the test matrix.
  • Loading branch information
Maari Tamm committed Oct 10, 2024
1 parent f56e6fc commit ce011f6
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 143 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
strategy:
matrix:
python-version:
- '3.8'
- '3.11'
pip-version:
- 22.0.4
- 23.0.1
- 23.2.1
include:
Expand Down Expand Up @@ -51,10 +49,10 @@ jobs:
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Set up Python 3.8
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
pip install coverage
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
-------------------------
* Drop support for Python 3.8 and `XBlock<2` (and, as a consequence,
any Open edX releases prior to Redwood).

Version 7.13.0 (2024-09-27)
-------------------------
* [Enhancement] Enable `show_in_read_only_mode` XBlock attribute
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ repository, you must select the appropriate one:
| Open edX release | Tutor version | XBlock version | XBlock branch |
|------------------|---------------|----------------|---------------|
| Maple | `>=13.2, <14` | `>=6.0, <7.0` | `stable-6.0` |
| Nutmeg | `>=14.0, <15` | `>=7.0` | `master` |
| Olive | `>=15.0, <16` | `>=7.5` | `master` |
| Palm | `>=16.0, <17` | `>=7.5` | `master` |
| Quince | `>=17.0, <18` | `>=7.9` | `master` |
| Redwood | `>=18.0, <19` | `>=7.12` | `master` |
| Nutmeg | `>=14.0, <15` | `>=7.0, <8.0` | `stable-7` |
| Olive | `>=15.0, <16` | `>=7.5, <8.0` | `stable-7` |
| Palm | `>=16.0, <17` | `>=7.5, <8.0` | `stable-7` |
| Quince | `>=17.0, <18` | `>=7.9, <8.0` | `stable-7` |
| Redwood | `>=18.0, <19` | `>=8.0` | `master` |

Instructions for deploying this XBlock with Tutor can be found
below, in the [Deployment with Tutor](#deployment-with-tutor)
Expand Down
75 changes: 13 additions & 62 deletions hastexo/hastexo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,14 @@

from xblock.core import XBlock, XML_NAMESPACES
from xblock.fields import Scope, Float, String, Dict, List, Integer, Boolean
try: # XBlock 2+
from web_fragments.fragment import Fragment
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import XBlockWithSettingsMixin
from xblock.utils.studio_editable import (
NestedXBlockSpec,
StudioContainerWithNestedXBlocksMixin,
StudioEditableXBlockMixin
)
except ImportError: # Compatibility with XBlock<2
from xblock.fragment import Fragment
from xblockutils.resources import ResourceLoader
from xblockutils.settings import XBlockWithSettingsMixin
from xblockutils.studio_editable import (
NestedXBlockSpec,
StudioContainerWithNestedXBlocksMixin,
StudioEditableXBlockMixin,
)
from web_fragments.fragment import Fragment
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import XBlockWithSettingsMixin
from xblock.utils.studio_editable import (
NestedXBlockSpec,
StudioContainerWithNestedXBlocksMixin,
StudioEditableXBlockMixin
)

from xblock.scorable import ScorableXBlockMixin, Score

Expand Down Expand Up @@ -318,21 +308,13 @@ def parse_attributes(tag, node, block):
block.providers.append(provider)

@classmethod
def parse_xml(cls, node, runtime, keys, id_generator=None):
def parse_xml(cls, node, runtime, keys):
"""
Use `node` to construct a new block.
"""
block = runtime.construct_xblock_from_class(cls, keys)

# Prior to XBlock 2.0, id_generator is passed in.
# Since XBlock 2.0, we grab it from the runtime.
#
# TODO: Once we decide to drop support for versions prior to
# XBlock 2 (i.e. Open edX releases before Redwood), we can
# drop id_generator from the method signature, and always rely
# on runtime.id_generator.
if not id_generator:
id_generator = runtime.id_generator
id_generator = runtime.id_generator

if 'filename' in node.attrib:
# Read xml content from file.
Expand Down Expand Up @@ -374,15 +356,7 @@ def parse_xml(cls, node, runtime, keys, id_generator=None):
child.tag))
# Import nested blocks
for child in node:
# Prior to XBlock 2.0, id_generator needs to be passed here.
#
# TODO: Once we decide to drop support for versions prior to
# XBlock 2 (i.e. Open edX releases before Redwood), we can
# drop the try/except block and passing the id_generator here.
try:
block.runtime.add_node_as_child(block, child)
except TypeError:
block.runtime.add_node_as_child(block, child, id_generator)
block.runtime.add_node_as_child(block, child)

else:
for child in node:
Expand All @@ -400,18 +374,7 @@ def parse_xml(cls, node, runtime, keys, id_generator=None):
cls.parse_attributes(child.tag, child, block)
else:
# Import nested blocks

# Prior to XBlock 2.0, id_generator needs to be passed.
#
# TODO: Once we decide to drop support for versions prior
# to XBlock 2 (i.e. Open edX releases before Redwood),
# we can drop the try/except block here and stop passing
# the id_generator.
try:
block.runtime.add_node_as_child(block, child)
except TypeError:
block.runtime.add_node_as_child(
block, child, id_generator)
block.runtime.add_node_as_child(block, child)

# Attributes become fields.
for name, value in list(node.items()): # lxml has no iteritems
Expand Down Expand Up @@ -743,19 +706,7 @@ def student_view(self, context=None):
for child_id in self.children:
child = self.runtime.get_block(child_id)
child_fragment = child.render("student_view", context)

# Prior to XBlock 2.0, Fragment is imported from XBlock
# and we the `add_frag_resources` method.
#
# TODO: Once we decide to drop support for versions prior
# to XBlock 2 (i.e. Open edX releases before Redwood),
# we can drop the try/except block here and use
# `add_fragment_resources` from `web_fragments.Fragment`
try:
frag.add_fragment_resources(child_fragment)
except AttributeError:
frag.add_frag_resources(child_fragment)

frag.add_fragment_resources(child_fragment)
child_content += child_fragment.content

# Render the main template
Expand Down
1 change: 0 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ tenacity>=6.2,<8
django<=4.2.14
channels<=4.0.0
daphne<=4.0.0
twisted<24;python_version<="3.9" # drop this restriction once we drop Python 3.8 and 3.9 support
mysqlclient<=2.2.4 # keep in sync with edx-platform
jsonfield>=3.1.0,<4 # keep in sync with edx-platform
pyguacamole>=0.11
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def package_data(pkg, roots):
packages=[
'hastexo',
],
python_requires='>=3.11',
install_requires=[
'apscheduler<3.8',
'google-api-python-client<1.8',
Expand Down
1 change: 1 addition & 0 deletions tests/resources/course/hastexo/fake_lab_hook_events_1.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<hastexo>
<!--Fake comment 1-->
<hook_events resume="True" suspend="true"/>
</hastexo>
Loading

0 comments on commit ce011f6

Please sign in to comment.