mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2025-11-23 18:58:58 +01:00
hooks: implement custom tox_runenvreport without a pip dependency
This gets rid of the pip dependency, undesirable in some cases. Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
@@ -4,6 +4,11 @@ import subprocess
|
||||
import sys
|
||||
import tox
|
||||
|
||||
try:
|
||||
import importlib.metadata as importlib_metadata
|
||||
except ImportError:
|
||||
import importlib_metadata
|
||||
|
||||
|
||||
@tox.hookimpl
|
||||
def tox_addoption(parser):
|
||||
@@ -185,3 +190,13 @@ def tox_cleanup(session):
|
||||
for venv in session.venv_dict.values():
|
||||
if is_current_env_link(venv):
|
||||
rm_venv(venv)
|
||||
|
||||
|
||||
@tox.hookimpl
|
||||
def tox_runenvreport(venv, action):
|
||||
if not venv.envconfig.config.option.current_env:
|
||||
return None
|
||||
return (
|
||||
"{}=={}".format(d.metadata.get("name"), d.version)
|
||||
for d in importlib_metadata.distributions()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user