From 8f181039d108aaeda7f2fce5753497c66ea24ed0 Mon Sep 17 00:00:00 2001 From: Maari Tamm Date: Thu, 28 Mar 2024 13:50:11 +0100 Subject: [PATCH 1/2] Add support for Python 3.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add support for Python 3.12 * Also, update the GitHub Actions workflow matrix so that we test all supported pip versions with Python 3.8–3.11, but only pip 23 on Python 3.12. --- .github/workflows/tox.yml | 6 +++++- Changelog.md | 4 ++++ hastexo/__init__.py | 4 ++-- hastexo/hastexo.py | 3 +-- requirements/base.txt | 1 + requirements/setup.txt | 1 - setup.py | 2 +- tests/unit/test_admin.py | 4 ++-- tests/unit/test_hastexo.py | 9 ++------- tests/unit/test_openstack.py | 6 +++--- tox.ini | 3 ++- 11 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index a816b1c5..d4a3ff49 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -17,6 +17,10 @@ jobs: pip-version: - 22.0.4 - 23.0.1 + - 23.2.1 + include: + - python-version: '3.12' + pip-version: '23.2.1' steps: - name: Check out code @@ -27,7 +31,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install "tox<4" tox-gh-actions tox-pip-version + pip install "tox<4" tox-gh-actions tox-pip-version setuptools-scm - env: TOX_PIP_VERSION: ${{ matrix.pip-version }} name: Test with tox (pip ${{ matrix.pip-version }}) diff --git a/Changelog.md b/Changelog.md index 79ca91b1..43e3122e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +Unreleased +------------------------- +* [Enhancement] Add support for Python 3.12. + Version 7.9.1 (2024-02-14) ------------------------- * [Bug fix] Don't allow accessing a fullscreen lab directly from a URL, diff --git a/hastexo/__init__.py b/hastexo/__init__.py index f4a98f18..eda0da44 100644 --- a/hastexo/__init__.py +++ b/hastexo/__init__.py @@ -1,8 +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('hastexo-xblock').version +__version__ = metadata.version('hastexo-xblock') diff --git a/hastexo/hastexo.py b/hastexo/hastexo.py index 37bcb659..0d7bf516 100644 --- a/hastexo/hastexo.py +++ b/hastexo/hastexo.py @@ -1,7 +1,6 @@ import time import logging import os -import pkg_resources import re import string import textwrap @@ -621,7 +620,7 @@ def get_js_urls(self): lang_code = translation.get_language() if lang_code and lang_code in SUPPORTED_LANGUAGES: text_js_url = f'public/js/translations/{lang_code}/text.js' - if pkg_resources.resource_exists(loader.module_name, text_js_url): + if os.path.exists(os.path.join('hastexo', text_js_url)): js_urls["text_js_url"] = self.runtime.local_resource_url( self, text_js_url) else: diff --git a/requirements/base.txt b/requirements/base.txt index b0b4f3b4..d7b7560b 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -15,6 +15,7 @@ python-heatclient>=1.6.1,<2 python-keystoneclient>=3.17.0,<3.22 python-novaclient>=7.1.2,<16 tenacity>=6.2,<8 +setuptools-scm # for hastexo_guacamole_client django<=4.2.8 diff --git a/requirements/setup.txt b/requirements/setup.txt index b0d97403..121ac1d0 100644 --- a/requirements/setup.txt +++ b/requirements/setup.txt @@ -1,3 +1,2 @@ -r base.txt -setuptools-scm<6 bumpversion diff --git a/setup.py b/setup.py index dbc9c88e..21142c43 100755 --- a/setup.py +++ b/setup.py @@ -77,5 +77,5 @@ def package_data(pkg, roots): "migrations", "translations", "locale"]), - setup_requires=['setuptools-scm<6'], + setup_requires=['setuptools-scm'], ) diff --git a/tests/unit/test_admin.py b/tests/unit/test_admin.py index 22f42ab5..b061a8d5 100644 --- a/tests/unit/test_admin.py +++ b/tests/unit/test_admin.py @@ -157,7 +157,7 @@ def test_clear_stacklog(self): stack.status = 'SUSPEND_COMPLETE' stack.save(update_fields=["status"]) logs = StackLog.objects.filter(stack_id=self.stack.id) - self.assertEquals(logs.count(), 4) + self.assertEqual(logs.count(), 4) data = { 'action': 'clear_stacklog', '_selected_action': [self.stack.id, ]} @@ -166,4 +166,4 @@ def test_clear_stacklog(self): self.assertEqual(response.status_code, 200) logs = StackLog.objects.filter(stack_id=self.stack.id) - self.assertEquals(logs.count(), 0) + self.assertEqual(logs.count(), 0) diff --git a/tests/unit/test_hastexo.py b/tests/unit/test_hastexo.py index 0028941b..bd023f6f 100644 --- a/tests/unit/test_hastexo.py +++ b/tests/unit/test_hastexo.py @@ -1,7 +1,6 @@ import time import json import textwrap -import pkg_resources import os from hastexo.models import Stack @@ -50,13 +49,9 @@ class TestHastexoXBlockHTML(TestCase): """ def test_static(self): - static_files = ['main.html'] + static_files = ['main.html', 'lab.html'] for static_file in static_files: - source = pkg_resources.resource_stream( - 'hastexo', - os.path.join('static', 'html', static_file) - ) - etree.parse(source, + etree.parse(os.path.join('hastexo', 'static', 'html', static_file), etree.HTMLParser(recover=False)) diff --git a/tests/unit/test_openstack.py b/tests/unit/test_openstack.py index 9a1aff30..2a51ec93 100644 --- a/tests/unit/test_openstack.py +++ b/tests/unit/test_openstack.py @@ -102,7 +102,7 @@ def test_get_client(self): wrapper, get_keystone_auth=mock_get_keystone_auth): wrapper.get_client() - self.mocks["heat_client"].Client.called_with( + self.mocks["heat_client"].Client.assert_called_with( "1", auth_url=self.credentials['os_auth_url'], session="sess", @@ -129,8 +129,8 @@ def test_get_client(self): wrapper, get_keystone_auth=mock_get_keystone_auth): wrapper.get_client() - self.mocks["nova_client"].Client.called_with( - "2.0", + self.mocks["nova_client"].Client.assert_called_with( + "2.2", self.credentials['os_username'], self.credentials['os_password'], project_id=self.credentials['os_project_id'], diff --git a/tox.ini b/tox.ini index fb78f739..9a790713 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8,pipdeptree{,-requirements},py{38,39,310,311}-xblock{17,18,19}-celery5 +envlist = flake8,pipdeptree{,-requirements},py{38,39,310,311,312}-xblock{17,18,19}-celery5 [gh-actions] python = @@ -7,6 +7,7 @@ python = 3.9: flake8,pipdeptree,pipdeptree-requirements,py39 3.10: flake8,pipdeptree,pipdeptree-requirements,py310 3.11: flake8,pipdeptree,pipdeptree-requirements,py311 + 3.12: flake8,pipdeptree,pipdeptree-requirements,py312 [flake8] ignore = E124,W504 From 924ea48b7bca494d02d83f3c5da858d89d7eadb8 Mon Sep 17 00:00:00 2001 From: Florian Haas Date: Mon, 15 Apr 2024 11:37:30 +0200 Subject: [PATCH 2/2] fixup! Add support for Python 3.12 --- .github/workflows/tox.yml | 2 +- requirements/base.txt | 1 - requirements/setup.txt | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index d4a3ff49..f29bd4c1 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -31,7 +31,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install "tox<4" tox-gh-actions tox-pip-version setuptools-scm + pip install "tox<4" tox-gh-actions tox-pip-version setuptools - env: TOX_PIP_VERSION: ${{ matrix.pip-version }} name: Test with tox (pip ${{ matrix.pip-version }}) diff --git a/requirements/base.txt b/requirements/base.txt index d7b7560b..b0b4f3b4 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -15,7 +15,6 @@ python-heatclient>=1.6.1,<2 python-keystoneclient>=3.17.0,<3.22 python-novaclient>=7.1.2,<16 tenacity>=6.2,<8 -setuptools-scm # for hastexo_guacamole_client django<=4.2.8 diff --git a/requirements/setup.txt b/requirements/setup.txt index 121ac1d0..767cf231 100644 --- a/requirements/setup.txt +++ b/requirements/setup.txt @@ -1,2 +1,3 @@ -r base.txt +setuptools-scm bumpversion