Skip to content

Commit

Permalink
Respect UV_PYTHON and fallback to sys.executable (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Oct 29, 2024
1 parent 02a8e4d commit 3278739
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/pre_commit_uv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ def _install_environment(
logger = logging.getLogger("pre_commit")
logger.info("Using pre-commit with uv %s via pre-commit-uv %s", uv_version(), self_version())
uv = _uv()
venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version)]
py = python.norm_version(version)
if py is not None:
venv_cmd.extend(("-p", py))
env = os.environ.copy()
env["UV_INTERNAL__PARENT_INTERPRETER"] = sys.executable
cmd_output_b(*venv_cmd, cwd="/", env=env)
py = python.norm_version(version) or os.environ.get("UV_PYTHON", sys.executable)
venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version), "-p", py]
cmd_output_b(*venv_cmd, cwd="/")

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

0 comments on commit 3278739

Please sign in to comment.