Skip to content

Commit 3278739

Browse files
authored
Respect UV_PYTHON and fallback to sys.executable (#29)
1 parent 02a8e4d commit 3278739

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/pre_commit_uv/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@ def _install_environment(
6565
logger = logging.getLogger("pre_commit")
6666
logger.info("Using pre-commit with uv %s via pre-commit-uv %s", uv_version(), self_version())
6767
uv = _uv()
68-
venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version)]
69-
py = python.norm_version(version)
70-
if py is not None:
71-
venv_cmd.extend(("-p", py))
72-
env = os.environ.copy()
73-
env["UV_INTERNAL__PARENT_INTERPRETER"] = sys.executable
74-
cmd_output_b(*venv_cmd, cwd="/", env=env)
68+
py = python.norm_version(version) or os.environ.get("UV_PYTHON", sys.executable)
69+
venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version), "-p", py]
70+
cmd_output_b(*venv_cmd, cwd="/")
7571

7672
with python.in_env(prefix, version):
7773
setup_cmd(prefix, (uv, "pip", "install", ".", *additional_dependencies))

0 commit comments

Comments
 (0)