Skip to content
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
3 changes: 1 addition & 2 deletions py/private/venv/venv.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def _make_venv(ctx, name = None, main = None, strip_pth_workspace_root = None):
content = pth_lines,
)

venv_sibling = _get_attr(ctx.file, "main", main)
venv_directory = ctx.actions.declare_directory("%s.source" % name, sibling = venv_sibling)
venv_directory = ctx.actions.declare_directory("%s.source" % name)

common_substitutions = {
"{{BASH_BIN}}": bash_bin,
Expand Down
15 changes: 14 additions & 1 deletion py/tests/external-deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("//py:defs.bzl", "py_binary", "py_library")
load("@python_toolchain//:defs.bzl", "host_platform")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("//py/tests/external-deps/custom-macro:macro.bzl", "click_cli_binary")

py_library(
name = "lib",
Expand Down Expand Up @@ -33,7 +34,7 @@ genrule(

py_binary(
name = "click",
srcs = ["click.py"],
srcs = ["//py/tests/external-deps/custom-macro:__main__.py"],
deps = [
# Referencing the external py_library rule generated by rules_python
"@pypi_click//:pkg",
Expand All @@ -47,10 +48,22 @@ genrule(
tools = ["click"],
)

click_cli_binary(
name = "click_binary",
)

genrule(
name = "run_click_cli_binary",
outs = ["click_cli_binary_out"],
cmd = "$(execpath click_binary) --count 628 > $@",
tools = ["click_binary"],
)

write_source_files(
name = "test",
files = {
"expected_pathing": "pathing_out",
"expected_click": "click_out",
"expected_click_cli_binary": "click_cli_binary_out",
},
)
1 change: 1 addition & 0 deletions py/tests/external-deps/custom-macro/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports_files(["__main__.py"])
17 changes: 17 additions & 0 deletions py/tests/external-deps/custom-macro/macro.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("//py:defs.bzl", "py_binary", "py_library")

def click_cli_binary(name, deps = [], **kwargs):
py_library(
name = name + "_lib",
srcs = ["//py/tests/external-deps/custom-macro:__main__.py"],
)

py_binary(
name = name,
main = "//py/tests/external-deps/custom-macro:__main__.py",
deps = deps + [
name + "_lib",
"@pypi_click//:pkg",
],
**kwargs
)
1 change: 1 addition & 0 deletions py/tests/external-deps/expected_click_cli_binary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Count = 628
20 changes: 20 additions & 0 deletions py/tests/external-deps/sibling-package/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("//py/tests/external-deps/custom-macro:macro.bzl", "click_cli_binary")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")

click_cli_binary(
name = "click_sibling_binary",
)

genrule(
name = "run_click_cli_binary",
outs = ["click_sibling_cli_binary_out"],
cmd = "$(execpath click_sibling_binary) --count 628 > $@",
tools = ["click_sibling_binary"],
)

write_source_files(
name = "test",
files = {
"expected_click_sibling_cli_binary": "click_sibling_cli_binary_out",
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Count = 628
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Count = 628