File tree Expand file tree Collapse file tree
other_module/other_module/pkg Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11load ("@rules_python//python:py_binary.bzl" , "py_binary" )
22load ("@rules_python//python:py_library.bzl" , "py_library" )
3+ load ("@rules_python//python/zipapp:py_zipapp_binary.bzl" , "py_zipapp_binary" )
34
45py_library (
56 name = "lib" ,
@@ -26,4 +27,13 @@ py_binary(
2627 ],
2728)
2829
30+ # This is used for regression testing runfiles paths in submodules.
31+ # https://github.com/bazel-contrib/rules_python/issues/3563.
32+ py_zipapp_binary (
33+ name = "bin_zipapp" ,
34+ testonly = True ,
35+ binary = ":bin" ,
36+ visibility = ["//visibility:public" ],
37+ )
38+
2939exports_files (["data/data.txt" ])
Original file line number Diff line number Diff line change 55# in the root module.
66
77load ("@bazel_skylib//rules:build_test.bzl" , "build_test" )
8+ load ("@rules_python//python:py_test.bzl" , "py_test" )
89
910build_test (
1011 name = "other_module_bin_build_test" ,
1112 targets = [
1213 "@our_other_module//other_module/pkg:bin" ,
1314 ],
1415)
16+
17+ py_test (
18+ name = "other_module_import_test" ,
19+ srcs = ["other_module_import_test.py" ],
20+ data = ["@our_other_module//other_module/pkg:bin_zipapp" ],
21+ env = {"ZIPAPP_PATH" : "$(location @our_other_module//other_module/pkg:bin_zipapp)" },
22+ )
Original file line number Diff line number Diff line change 1+ """Regression test for https://github.com/bazel-contrib/rules_python/issues/3563"""
2+ import os
3+ import subprocess
4+ import sys
5+
6+ def main ():
7+ # The rlocation path for the bin_zipapp. It is in the "our_other_module" repository.
8+ zipapp_path = os .environ .get ("ZIPAPP_PATH" )
9+ print (f"Running bin_zipapp at: { zipapp_path } " )
10+
11+ result = subprocess .run ([zipapp_path ], capture_output = True , text = True )
12+ print ("--- bin_zippapp stdout ---" )
13+ print (result .stdout )
14+ print ("--- bin_zippapp stderr ---" )
15+ print (result .stderr )
16+
17+ if result .returncode != 0 :
18+ print (f"bin_zippapp failed with return code { result .returncode } " )
19+ sys .exit (result .returncode )
20+
21+ if __name__ == "__main__" :
22+ main ()
You can’t perform that action at this time.
0 commit comments