Skip to content

Commit

Permalink
Merge pull request #12 from Novakov/py312
Browse files Browse the repository at this point in the history
fix: Python 3.12 compatibility
  • Loading branch information
Novakov authored Jan 15, 2024
2 parents 13710f4 + a02167b commit 801a571
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v1
Expand Down
18 changes: 14 additions & 4 deletions src/qemu_runner/make_runner/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import zipimport
from pathlib import Path
from typing import IO, List, Any
import pkg_resources

from qemu_runner.layer_locator import load_layer
import qemu_runner
Expand All @@ -19,9 +18,20 @@

def load_layers_from_all_search_paths(layer_names: List[str]) -> List[str]:
packages = ['qemu_runner']
for ep in pkg_resources.iter_entry_points('qemu_runner_layer_packages'):
ep: pkg_resources.EntryPoint
packages.append(ep.module_name)
try:
import pkg_resources
for ep in pkg_resources.iter_entry_points('qemu_runner_layer_packages'):
ep: pkg_resources.EntryPoint
packages.append(ep.module_name)

return [load_layer(layer, packages=packages) for layer in layer_names]
except ImportError:
import importlib.metadata

eps = importlib.metadata.entry_points(group='qemu_runner_layer_packages')

for ep in eps:
packages.append(ep.module_name)

return [load_layer(layer, packages=packages) for layer in layer_names]

Expand Down
17 changes: 2 additions & 15 deletions tests/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,7 @@ def install_script(builder: venv.EnvBuilder, context, name, url):


def install_setuptools(builder: venv.EnvBuilder, context):
"""
Install setuptools in the virtual environment.
:param context: The information for the virtual environment
creation request being processed.
"""
url = 'https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
install_script(builder, context, 'setuptools', url)
# clear up the setuptools archive which gets downloaded
pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')
files = filter(pred, os.listdir(context.bin_path))
for f in files:
f = os.path.join(context.bin_path, f)
os.unlink(f)
subprocess.run([context.env_exe, '-m', 'pip', 'install', 'setuptools'], check=True)


@pytest.fixture()
Expand All @@ -56,7 +43,7 @@ def create_venv(venv_dir: Path):
ctx = builder.ensure_directories(venv_dir)
# builder.create_configuration(ctx)
# builder.setup_python(ctx)
# install_setuptools(builder, ctx)
install_setuptools(builder, ctx)
return Path(ctx.env_exe)


Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.4.0
envlist = py38,py39,py310,py311
envlist = py38,py39,py310,py311,py312

[gh-actions]
python =
Expand All @@ -9,6 +9,7 @@ python =
3.9: py39
3.10: py310, mypy
3.11: py311, mypy
3.12: py312, mypy

[testenv]
;download = true
Expand Down

0 comments on commit 801a571

Please sign in to comment.