-
-
Notifications
You must be signed in to change notification settings - Fork 53
Description
It's always been a pain point that the if name == "__main__"
pattern allows for Python files to serve double duty as both scripts and libraries. This creates ambiguity for Bazel and significantly Gazelle which struggle with the fact that the one file is serving double duty.
In rules_python
when taking a deps = []
dependency on PyInfo
providers, the py_binary
machinery blithely does what it normally does which is generate an entrypoint script and propagate runfiles. This never really made sense beyond being the "natural" conclusion of depending on an action which normally produces files.
By introducing a new config_setting_flag
something like @aspect_rules_py//py/private/settings:binaries_are_libraries=false
, the py_*_binary
rules and py_library
itself could be configured to apply a transition to their deps
which flips that flag. If the py_*_binary
rules inspect that flag and codepath switch between the py_library
impl or the "normal" binary impl, then we've created a way to turn off the longstanding missbehavior of what happens when binaries depend on fellow binaries as sources of code.
It should still be possible to force a dependency on another binary, specifically by taking a data=[]
dependency which does just depend on files unlike deps
which can and should have language specific meaning.