diff --git a/setup.py b/setup.py index 63ddc01..920f2ac 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ setup( # but the one downloaded from PyPI isn't and it doesn't work properly. "tox>=3.15; python_version >= '3.8'", "tox>=3.13; python_version < '3.8'", + "importlib_metadata; python_version < '3.8'" ], python_requires=">=3.6", classifiers=[ diff --git a/src/tox_current_env/hooks.py b/src/tox_current_env/hooks.py index f04ad67..695f320 100644 --- a/src/tox_current_env/hooks.py +++ b/src/tox_current_env/hooks.py @@ -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() + )