|
20 | 20 |
|
21 | 21 | from tox.execute.local_sub_process import LocalSubProcessExecutor |
22 | 22 | from tox.execute.request import StdinSource |
| 23 | +from tox.tox_env.errors import Skip |
23 | 24 | from tox.tox_env.python.api import Python, PythonInfo, VersionInfo |
24 | 25 | from uv import find_uv_bin |
25 | 26 | from virtualenv import app_data |
@@ -68,7 +69,8 @@ def installer(self) -> Installer[Any]: |
68 | 69 | def runs_on_platform(self) -> str: |
69 | 70 | return sys.platform |
70 | 71 |
|
71 | | - def _get_python(self, base_python: list[str]) -> PythonInfo | None: # noqa: PLR6301 |
| 72 | + @staticmethod |
| 73 | + def _get_python(base_python: list[str]) -> PythonInfo | None: |
72 | 74 | for base in base_python: # pragma: no branch |
73 | 75 | if base == sys.executable: |
74 | 76 | version_info = sys.version_info |
@@ -113,6 +115,7 @@ def _get_python(self, base_python: list[str]) -> PythonInfo | None: # noqa: PLR |
113 | 115 | platform=sys.platform, |
114 | 116 | extra={}, |
115 | 117 | ) |
| 118 | + |
116 | 119 | return None # pragma: no cover |
117 | 120 |
|
118 | 121 | @property |
@@ -149,13 +152,19 @@ def create_python_env(self) -> None: |
149 | 152 | else: |
150 | 153 | uv_imp = "" if (imp and imp == "cpython") else imp |
151 | 154 | version_spec = f"{uv_imp or ''}{base.major}.{base.minor}" if base.minor else f"{uv_imp or ''}{base.major}" |
| 155 | + |
152 | 156 | cmd: list[str] = [self.uv, "venv", "-p", version_spec, "--allow-existing"] |
153 | 157 | if self.options.verbosity > 2: # noqa: PLR2004 |
154 | 158 | cmd.append("-v") |
155 | 159 | if self.conf["uv_seed"]: |
156 | 160 | cmd.append("--seed") |
157 | 161 | cmd.append(str(self.venv_dir)) |
158 | 162 | outcome = self.execute(cmd, stdin=StdinSource.OFF, run_id="venv", show=None) |
| 163 | + |
| 164 | + if self.core["skip_missing_interpreters"] and outcome.exit_code == 1: |
| 165 | + msg = "could not find python interpreter with spec(s):" f" {version_spec}" |
| 166 | + raise Skip(msg) |
| 167 | + |
159 | 168 | outcome.assert_success() |
160 | 169 | self._created = True |
161 | 170 |
|
|
0 commit comments