1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2024-12-24 09:06:15 +01:00

Implement a new method for tox 4.18+

Fixes https://github.com/fedora-python/tox-current-env/issues/77
This commit is contained in:
Miro Hrončok 2024-08-14 16:43:26 +02:00
parent 10ff32b308
commit 3ec5f8f899

View File

@ -12,7 +12,7 @@ from tox.execute.local_sub_process import (
LocalSubProcessExecuteInstance, LocalSubProcessExecuteInstance,
) )
from tox.plugin import impl 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 from tox.tox_env.python.runner import PythonRun
try: try:
@ -209,6 +209,17 @@ class CurrentEnv(PythonRun):
def runs_on_platform(self): def runs_on_platform(self):
return sys.platform 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): class PrintEnv(CurrentEnv):
def __init__(self, create_args): def __init__(self, create_args):