Skip to content

Commit

Permalink
chore: use modern helper from bazel-lib (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored Oct 8, 2023
1 parent 70b6697 commit 9dc9650
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions py/private/py_binary.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Implementation for the py_binary and py_test rules."

load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_manifest_path")
load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_rlocation_path")
load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables")
load("//py/private:py_library.bzl", _py_library = "py_library_utils")
load("//py/private:providers.bzl", "PyWheelInfo")
Expand Down Expand Up @@ -32,16 +32,16 @@ def _py_binary_rule_imp(ctx):
attribute_name = "env",
)

python_interpreter_path = interpreter.python.path if interpreter.uses_interpreter_path else to_manifest_path(ctx, interpreter.python)
python_interpreter_path = interpreter.python.path if interpreter.uses_interpreter_path else to_rlocation_path(ctx, interpreter.python)

common_substitutions = {
"{{BASH_BIN}}": bash_bin,
"{{BASH_RLOCATION_FN}}": BASH_RLOCATION_FUNCTION,
"{{BINARY_ENTRY_POINT}}": to_manifest_path(ctx, main),
"{{BINARY_ENTRY_POINT}}": to_rlocation_path(ctx, main),
"{{INTERPRETER_FLAGS}}": " ".join(interpreter.flags),
"{{PYTHON_INTERPRETER_PATH}}": python_interpreter_path,
"{{RUN_BINARY_ENTRY_POINT}}": "true",
"{{VENV_SOURCE}}": to_manifest_path(ctx, venv_info.venv_directory),
"{{VENV_SOURCE}}": to_rlocation_path(ctx, venv_info.venv_directory),
"{{VENV_NAME}}": "%s.venv" % ctx.attr.name,
"{{PYTHON_ENV}}": "\n".join(dict_to_exports(env)).strip(),
"{{PYTHON_ENV_UNSET}}": "\n".join(["unset %s" % k for k in env.keys()]).strip(),
Expand Down
8 changes: 4 additions & 4 deletions py/private/venv/venv.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Implementations for the py_venv rule."

load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_manifest_path")
load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_rlocation_path")
load("//py/private:providers.bzl", "PyWheelInfo")
load("//py/private:py_library.bzl", _py_library = "py_library_utils")
load("//py/private:utils.bzl", "PY_TOOLCHAIN", "SH_TOOLCHAIN", "resolve_toolchain")
Expand Down Expand Up @@ -130,9 +130,9 @@ def _make_venv(ctx, name = None, strip_pth_workspace_root = None):
substitutions = dict(
common_substitutions,
**{
"{{PYTHON_INTERPRETER_PATH}}": to_manifest_path(ctx, interpreter.python),
"{{WHL_REQUIREMENTS_FILE}}": to_manifest_path(ctx, whl_requirements),
"{{PTH_FILE}}": to_manifest_path(ctx, pth),
"{{PYTHON_INTERPRETER_PATH}}": to_rlocation_path(ctx, interpreter.python),
"{{WHL_REQUIREMENTS_FILE}}": to_rlocation_path(ctx, whl_requirements),
"{{PTH_FILE}}": to_rlocation_path(ctx, pth),
"{{VENV_LOCATION}}": "${BUILD_WORKSPACE_DIRECTORY}/.%s" % name,
"{{USE_MANIFEST_PATH}}": "true",
}
Expand Down

0 comments on commit 9dc9650

Please sign in to comment.