summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2023-01-06 15:40:41 +0000
committerGitHub <noreply@github.com>2023-01-06 07:40:41 -0800
commitc790c60a214bbcf1da203aee96c60aa0bc4411d1 (patch)
treecc8dc7f3f5a51fe07f188aad88eb979239d0934e /src
parentaf35384bb2eeb13e1a023ce9f0e9530adafa63dd (diff)
downloadtox-git-c790c60a214bbcf1da203aee96c60aa0bc4411d1.tar.gz
Fix various issues with missing interpreters (#2828)
fix https://github.com/tox-dev/tox/issues/2811
Diffstat (limited to 'src')
-rw-r--r--src/tox/session/cmd/run/common.py4
-rw-r--r--src/tox/tox_env/python/api.py24
-rw-r--r--src/tox/tox_env/python/package.py8
3 files changed, 22 insertions, 14 deletions
diff --git a/src/tox/session/cmd/run/common.py b/src/tox/session/cmd/run/common.py
index 02797bfb..73facf62 100644
--- a/src/tox/session/cmd/run/common.py
+++ b/src/tox/session/cmd/run/common.py
@@ -187,7 +187,9 @@ def report(start: float, runs: list[ToxEnvRunResult], is_colored: bool, verbosit
_print(Fore.GREEN, f" congratulations :) ({duration:.2f} seconds)")
return Outcome.OK
_print(Fore.RED, f" evaluation failed :( ({duration:.2f} seconds)")
- return runs[0].code if len(runs) == 1 else -1
+ if len(runs) == 1:
+ return runs[0].code if not runs[0].skipped else -1
+ return -1
def _get_outcome_message(run: ToxEnvRunResult) -> tuple[str, int]:
diff --git a/src/tox/tox_env/python/api.py b/src/tox/tox_env/python/api.py
index 58e73ca2..9aa1f839 100644
--- a/src/tox/tox_env/python/api.py
+++ b/src/tox/tox_env/python/api.py
@@ -231,27 +231,29 @@ class Python(ToxEnv, ABC):
@property
def base_python(self) -> PythonInfo:
"""Resolve base python"""
+ base_pythons: list[str] = self.conf["base_python"]
+
if self._base_python_searched is False:
- base_pythons: list[str] = self.conf["base_python"]
self._base_python_searched = True
self._base_python = self._get_python(base_pythons)
- if self._base_python is None:
- if self.core["skip_missing_interpreters"]:
- raise Skip(f"could not find python interpreter with spec(s): {', '.join(base_pythons)}")
- raise NoInterpreter(base_pythons)
- if self.journal:
+ if self._base_python is not None and self.journal:
value = self._get_env_journal_python()
self.journal["python"] = value
+
+ if self._base_python is None:
+ if self.core["skip_missing_interpreters"]:
+ raise Skip(f"could not find python interpreter with spec(s): {', '.join(base_pythons)}")
+ raise NoInterpreter(base_pythons)
+
return cast(PythonInfo, self._base_python)
def _get_env_journal_python(self) -> dict[str, Any]:
- assert self._base_python is not None
return {
- "implementation": self._base_python.implementation,
+ "implementation": self.base_python.implementation,
"version_info": tuple(self.base_python.version_info),
- "version": self._base_python.version,
- "is_64": self._base_python.is_64,
- "sysplatform": self._base_python.platform,
+ "version": self.base_python.version,
+ "is_64": self.base_python.is_64,
+ "sysplatform": self.base_python.platform,
"extra_version_info": None,
}
diff --git a/src/tox/tox_env/python/package.py b/src/tox/tox_env/python/package.py
index 289bd774..d671550d 100644
--- a/src/tox/tox_env/python/package.py
+++ b/src/tox/tox_env/python/package.py
@@ -14,7 +14,7 @@ from ..api import ToxEnvCreateArgs
from ..errors import Skip
from ..package import Package, PackageToxEnv, PathPackage
from ..runner import RunToxEnv
-from .api import Python
+from .api import NoInterpreter, Python
from .pip.req_file import PythonDeps
if TYPE_CHECKING:
@@ -87,7 +87,11 @@ class PythonPackageToxEnv(Python, PackageToxEnv, ABC):
# python only code are often compatible at major level (unless universal wheel in which case both 2/3)
# c-extension codes are trickier, but as of today both poetry/setuptools uses pypa/wheels logic
# https://github.com/pypa/wheel/blob/master/src/wheel/bdist_wheel.py#L234-L280
- run_py = cast(Python, run_env).base_python
+ try:
+ run_py = cast(Python, run_env).base_python
+ except NoInterpreter:
+ run_py = None
+
if run_py is None:
base = ",".join(run_env.conf["base_python"])
raise Skip(f"could not resolve base python with {base}")