Skip to content

Commit

Permalink
Use --python arg instead of PATH munging (#65)
Browse files Browse the repository at this point in the history
## Issue
We were updating PATH to get our desired Python interpreter at the front, but more recent versions of uv let us specify the interpreter explicitly.

## Summary
Specify the interpreter using `--python` instead of munging the path.
  • Loading branch information
mark-thm authored Jun 17, 2024
1 parent 9dac582 commit 23fdc71
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion uv/private/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def _uv_pip_compile(
args = []
args += uv_args
args.append("--custom-compile-command='{compile_command}'".format(compile_command = compile_command))
args.append("--python={python}".format(python = py_toolchain.py3_runtime.interpreter.short_path))
args.append("--python-version={version}".format(version = _python_version(py_toolchain)))
if ctx.attr.python_platform:
args.append("--python-platform={platform}".format(platform = ctx.attr.python_platform))
Expand All @@ -48,7 +49,6 @@ def _uv_pip_compile(
"{{requirements_in}}": ctx.file.requirements_in.short_path,
"{{requirements_txt}}": ctx.file.requirements_txt.short_path,
"{{compile_command}}": compile_command,
"{{resolved_python}}": py_toolchain.py3_runtime.interpreter.short_path,
},
)

Expand Down
4 changes: 0 additions & 4 deletions uv/private/pip_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ set -euo pipefail
REQUIREMENTS_IN="{{requirements_in}}"
REQUIREMENTS_TXT="{{requirements_txt}}"

# set resolved python to front of the path
RESOLVED_PYTHON_BIN="$(dirname "{{resolved_python}}")"
export PATH="$RESOLVED_PYTHON_BIN:$PATH"

{{uv}} pip compile \
{{args}} \
--output-file="$REQUIREMENTS_TXT" \
Expand Down
4 changes: 0 additions & 4 deletions uv/private/pip_compile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ REQUIREMENTS_IN="{{requirements_in}}"
REQUIREMENTS_TXT="{{requirements_txt}}"
COMPILE_COMMAND="{{compile_command}}"

# set resolved python to front of the path
RESOLVED_PYTHON_BIN="$(dirname "{{resolved_python}}")"
export PATH="$RESOLVED_PYTHON_BIN:$PATH"

# make a writable copy of incoming requirements
cp "$REQUIREMENTS_TXT" __updated__

Expand Down

0 comments on commit 23fdc71

Please sign in to comment.