Skip to content

Commit 9c9c8b0

Browse files
committed
clean up some more
1 parent ac5d58c commit 9c9c8b0

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

python/bin/BUILD.bazel

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
load("//python:py_binary.bzl", "py_binary")
21
load("//python/private:interpreter.bzl", _interpreter_binary = "interpreter_binary")
3-
load("//python/private:repl.bzl", "generate_repl_main")
2+
load("//python/private:repl.bzl", "py_repl_binary")
43

54
filegroup(
65
name = "distribution",
@@ -25,10 +24,14 @@ label_flag(
2524
build_setting_default = "//python:none",
2625
)
2726

28-
generate_repl_main(
29-
name = "repl_py",
30-
src = "repl_stub",
31-
out = "repl.py",
27+
py_repl_binary(
28+
name = "repl",
29+
visibility = ["//visibility:public"],
30+
stub = ":repl_stub",
31+
deps = [
32+
":repl_dep",
33+
":repl_stub_dep",
34+
],
3235
)
3336

3437
# The user can replace this with their own stub. E.g. they can use this to
@@ -46,20 +49,6 @@ label_flag(
4649
build_setting_default = "//python/private:empty",
4750
)
4851

49-
py_binary(
50-
name = "repl",
51-
srcs = [":repl.py"],
52-
visibility = ["//visibility:public"],
53-
data = [
54-
":repl_stub",
55-
],
56-
deps = [
57-
":repl_dep",
58-
":repl_stub_dep",
59-
"//python/runfiles",
60-
],
61-
)
62-
6352
# The user can modify this flag to make arbitrary PyInfo targets available for
6453
# import on the REPL.
6554
label_flag(

python/private/repl.bzl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("//python:py_binary.bzl", "py_binary")
2+
13
def _generate_repl_main_impl(ctx):
24
stub_repo = ctx.attr.src.label.repo_name or ctx.workspace_name
35
stub_path = "/".join([stub_repo, ctx.file.src.short_path])
@@ -10,7 +12,7 @@ def _generate_repl_main_impl(ctx):
1012
},
1113
)
1214

13-
generate_repl_main = rule(
15+
_generate_repl_main = rule(
1416
implementation = _generate_repl_main_impl,
1517
attrs = {
1618
"out": attr.output(
@@ -31,3 +33,24 @@ generate_repl_main = rule(
3133
),
3234
},
3335
)
36+
37+
def py_repl_binary(name, stub, deps=[], data=[], **kwargs):
38+
_generate_repl_main(
39+
name = "%s_py" % name,
40+
src = stub,
41+
out = "%s.py" % name,
42+
)
43+
44+
py_binary(
45+
name = name,
46+
srcs = [
47+
":%s.py" % name,
48+
],
49+
data = data + [
50+
stub,
51+
],
52+
deps = deps + [
53+
"//python/runfiles",
54+
],
55+
**kwargs,
56+
)

0 commit comments

Comments
 (0)