@@ -14,12 +14,12 @@ py_pytest_main = _py_pytest_main
1414py_venv = _py_venv
1515py_binary_rule = _py_binary
1616py_test_rule = _py_test
17- py_library_rule = _py_library
18- py_unpacked_wheel_rule = _py_unpacked_wheel
17+ py_library = _py_library
18+ py_unpacked_wheel = _py_unpacked_wheel
1919
2020resolutions = _resolutions
2121
22- def _py_binary_or_test (name , rule , srcs , main , imports , deps = [], resolutions = {}, ** kwargs ):
22+ def _py_binary_or_test (name , rule , srcs , main , deps = [], resolutions = {}, ** kwargs ):
2323 # Compatibility with rules_python, see docs in py_executable.bzl
2424 main_target = "_{}.find_main" .format (name )
2525 determine_main (
@@ -34,7 +34,6 @@ def _py_binary_or_test(name, rule, srcs, main, imports, deps = [], resolutions =
3434 name = name ,
3535 srcs = srcs ,
3636 main = main_target ,
37- imports = imports ,
3837 deps = deps ,
3938 resolutions = resolutions ,
4039 ** kwargs
@@ -43,17 +42,17 @@ def _py_binary_or_test(name, rule, srcs, main, imports, deps = [], resolutions =
4342 _py_venv (
4443 name = "{}.venv" .format (name ),
4544 deps = deps ,
46- imports = imports ,
45+ imports = kwargs . get ( " imports" ) ,
4746 resolutions = resolutions ,
4847 tags = ["manual" ],
4948 testonly = kwargs .get ("testonly" , False ),
5049 )
5150
52- def py_binary (name , srcs = [], main = None , imports = [ "." ], ** kwargs ):
53- """Wrapper macro for [`py_binary_rule`](#py_binary_rule), setting a default for imports .
51+ def py_binary (name , srcs = [], main = None , ** kwargs ):
52+ """Wrapper macro for [`py_binary_rule`](#py_binary_rule).
5453
55- It also creates a virtualenv to constrain the interpreter and packages used at runtime,
56- you can `bazel run [name].venv` to produce this, then use it in the editor.
54+ Creates a virtualenv to constrain the interpreter and packages used at runtime.
55+ Users can `bazel run [name].venv` to produce this, then use it in the editor.
5756
5857 Args:
5958 name: Name of the rule.
@@ -62,7 +61,6 @@ def py_binary(name, srcs = [], main = None, imports = ["."], **kwargs):
6261 Like rules_python, this is treated as a suffix of a file that should appear among the srcs.
6362 If absent, then "[name].py" is tried. As a final fallback, if the srcs has a single file,
6463 that is used as the main.
65- imports: List of import paths to add for this binary.
6664 **kwargs: additional named parameters to the py_binary_rule.
6765 """
6866
@@ -72,32 +70,11 @@ def py_binary(name, srcs = [], main = None, imports = ["."], **kwargs):
7270 if resolutions :
7371 resolutions = resolutions .to_label_keyed_dict ()
7472
75- _py_binary_or_test (name = name , rule = _py_binary , srcs = srcs , main = main , imports = imports , resolutions = resolutions , ** kwargs )
73+ _py_binary_or_test (name = name , rule = _py_binary , srcs = srcs , main = main , resolutions = resolutions , ** kwargs )
7674
77- def py_test (name , main = None , srcs = [], imports = [ "." ], ** kwargs ):
75+ def py_test (name , main = None , srcs = [], ** kwargs ):
7876 "Identical to py_binary, but produces a target that can be used with `bazel test`."
7977
8078 # Ensure that any other targets we write will be testonly like the py_test target
8179 kwargs ["testonly" ] = True
82- _py_binary_or_test (name = name , rule = _py_test , srcs = srcs , main = main , imports = imports , ** kwargs )
83-
84- def py_library (name , imports = ["." ], ** kwargs ):
85- """Wrapper macro for the [py_library_rule](./py_library_rule), supporting virtual deps.
86-
87- Args:
88- name: Name for this rule.
89- imports: List of import paths to add for this library.
90- **kwargs: Additional named parameters to py_library_rule.
91- """
92-
93- _py_library (name = name , imports = imports , ** kwargs )
94-
95- def py_unpacked_wheel (name , ** kwargs ):
96- """Wrapper macro for the [py_unpacked_wheel_rule](#py_unpacked_wheel_rule), setting a defaults.
97-
98- Args:
99- name: Name of this rule.
100- **kwargs: Additional named parameters to py_unpacked_wheel_rule.
101- """
102-
103- _py_unpacked_wheel (name = name , ** kwargs )
80+ _py_binary_or_test (name = name , rule = _py_test , srcs = srcs , main = main , ** kwargs )
0 commit comments