From 3ec5f8f899740a5a931d3bb844b36cd2837c0177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 14 Aug 2024 16:43:26 +0200 Subject: [PATCH] Implement a new method for tox 4.18+ Fixes https://github.com/fedora-python/tox-current-env/issues/77 --- src/tox_current_env/hooks4.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tox_current_env/hooks4.py b/src/tox_current_env/hooks4.py index 5628eff..5d629f8 100644 --- a/src/tox_current_env/hooks4.py +++ b/src/tox_current_env/hooks4.py @@ -12,7 +12,7 @@ from tox.execute.local_sub_process import ( LocalSubProcessExecuteInstance, ) from tox.plugin import impl -from tox.tox_env.python.api import PythonInfo +from tox.tox_env.python.api import PythonInfo, PythonSpec from tox.tox_env.python.runner import PythonRun try: @@ -209,6 +209,17 @@ class CurrentEnv(PythonRun): def runs_on_platform(self): return sys.platform + @classmethod + def python_spec_for_path(cls, path): + # Needed for https://github.com/fedora-python/tox-current-env/issues/77 + # This is a copy of an internal tox method added in + # https://github.com/tox-dev/tox/pull/3327 + implementation = sys.implementation.name + version = sys.version_info + bits = "64" if sys.maxsize > 2**32 else "32" + string_spec = f"{implementation}{version.major}{version.minor}-{bits}" + return PythonSpec.from_string_spec(string_spec) + class PrintEnv(CurrentEnv): def __init__(self, create_args):