File tree Expand file tree Collapse file tree 4 files changed +19
-48
lines changed Expand file tree Collapse file tree 4 files changed +19
-48
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ label_flag(
2727
2828generate_repl_main (
2929 name = "repl_py" ,
30- src = "repl_stub.py " ,
30+ src = "repl_stub" ,
3131 out = "repl.py" ,
3232)
3333
@@ -50,9 +50,13 @@ py_binary(
5050 name = "repl" ,
5151 srcs = [":repl.py" ],
5252 visibility = ["//visibility:public" ],
53+ data = [
54+ ":repl_stub" ,
55+ ],
5356 deps = [
5457 ":repl_dep" ,
5558 ":repl_stub_dep" ,
59+ "//python/runfiles" ,
5660 ],
5761)
5862
Original file line number Diff line number Diff line change 11def _generate_repl_main_impl (ctx ):
2- args = ctx .actions .args ()
3- args .add_all ([
4- ctx .file ._template ,
5- ctx .file .src ,
6- ctx .outputs .out ,
7- ])
2+ stub_repo = ctx .attr .src .label .repo_name or ctx .workspace_name
3+ stub_path = "/" .join ([stub_repo , ctx .file .src .short_path ])
84
9- ctx .actions .run (
10- executable = ctx .executable ._generator ,
11- inputs = [
12- ctx .file ._template ,
13- ctx .file .src ,
14- ],
15- outputs = [ctx .outputs .out ],
16- arguments = [args ],
5+ ctx .actions .expand_template (
6+ template = ctx .file ._template ,
7+ output = ctx .outputs .out ,
8+ substitutions = {
9+ "%stub_path%" : stub_path ,
10+ },
1711 )
1812
1913generate_repl_main = rule (
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import os
2+ import runpy
23from pathlib import Path
34
5+ from python .runfiles import runfiles
46
5- def repl_stub ():
6- pass # %REPLACE_WHOLE_LINE_WITH_STUB%
7+
8+ STUB_PATH = "%stub_path%"
79
810
911def start_repl ():
@@ -19,7 +21,8 @@ def start_repl():
1921 compiled_code = compile (source_code , filename = startup_file , mode = "exec" )
2022 eval (compiled_code , {})
2123
22- repl_stub ()
24+ bazel_runfiles = runfiles .Create ()
25+ runpy .run_path (bazel_runfiles .Rlocation (STUB_PATH ), run_name = "__main__" )
2326
2427
2528if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments