Skip to content

Commit

Permalink
fix: Python 3.12 compatibility - module attribute on EntryPoint
Browse files Browse the repository at this point in the history
It seems that in recent releases EntryPoint API has stabilised and
settled on module instead of module_name attribute
  • Loading branch information
Novakov committed Jun 24, 2024
1 parent a658f67 commit f65eda1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/qemu_runner/make_runner/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def load_layers_from_all_search_paths(layer_names: List[str]) -> List[str]:
eps = importlib.metadata.entry_points(group='qemu_runner_layer_packages')

for ep in eps:
packages.append(ep.module_name)
module_name = getattr(ep, 'module', None)
if module_name is None:
module_name = ep.module_name
packages.append(module_name)

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

Expand Down
15 changes: 2 additions & 13 deletions tests/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def install_script(builder: venv.EnvBuilder, context, name, url):
os.unlink(distpath)


def install_setuptools(builder: venv.EnvBuilder, context):
subprocess.run([context.env_exe, '-m', 'pip', 'install', 'setuptools'], check=True)


@pytest.fixture()
def venv_py(tmp_path: Path) -> Path:
venv_dir = tmp_path / 'venv'
Expand All @@ -41,9 +37,6 @@ def create_venv(venv_dir: Path):
builder = venv.EnvBuilder(with_pip=True)
builder.create(venv_dir)
ctx = builder.ensure_directories(venv_dir)
# builder.create_configuration(ctx)
# builder.setup_python(ctx)
install_setuptools(builder, ctx)
return Path(ctx.env_exe)


Expand All @@ -64,12 +57,8 @@ def make_runner(python: Path, args: List[str], cwd: Path):


def install_dev_package(python: Path, pkg: Path):
cp = subprocess.run([
python,
pkg / 'setup.py',
'-q',
'install'
],
cp = subprocess.run(
[python, '-m', 'pip', 'install', '-q', pkg],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8',
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ python =
3.12: py312, mypy

[testenv]
;download = true
;recreate = true
;alwayscopy = true
deps = pytest
commands = pytest tests

0 comments on commit f65eda1

Please sign in to comment.