Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use modern helper from bazel-lib #207

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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