Skip to content

Commit c29d3d8

Browse files
arrdemkeith
andauthored
Fix debug logging in release (#613)
debug_build was enabled for users who were using `--compilation_mode=dbg`, which lead to `set -x` being set in the terminal used to create the venv, and tons of logging users don't need to see. The help for the venv tool was also printed. Replaces #596 which has conflicts. ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes/no - Breaking change (forces users to change their own code or config): yes/no - Suggested release notes appear below: yes/no ### Test plan - Covered by existing test cases - New test cases added - Manual testing; please provide instructions so we can reproduce: Co-authored-by: Keith Smiley <[email protected]>
1 parent bfd4aee commit c29d3d8

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

py/private/py_venv/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
23
load(":defs.bzl", "py_venv_test")
34

45
package(default_visibility = [
@@ -11,10 +12,15 @@ exports_files([
1112
"link.py",
1213
])
1314

15+
bool_flag(
16+
name = "debug_venv",
17+
build_setting_default = False,
18+
)
19+
1420
config_setting(
15-
name = "debug_build",
16-
values = {
17-
"compilation_mode": "dbg",
21+
name = "debug_venv_setting",
22+
flag_values = {
23+
":debug_venv": "True",
1824
},
1925
)
2026

py/private/py_venv/link.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def munge_venv_name(target_package, virtualenv_name):
4646
default=munge_venv_name(target_package, virtualenv_name),
4747
help="Name to link the virtualenv as.",
4848
)
49-
5049

51-
PARSER.print_help(sys.stdout)
5250
opts = PARSER.parse_args()
5351
dest = Path(os.path.join(opts.dest, opts.name))
5452
print("""
@@ -68,7 +66,7 @@ def munge_venv_name(target_package, virtualenv_name):
6866
dest.unlink()
6967
except FileNotFoundError:
7068
pass
71-
69+
7270
# From -> to
7371
dest.symlink_to(virtualenv_home, target_is_directory=True)
7472
print("Link created!")

py/private/py_venv/py_venv.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ _py_venv = rule(
351351

352352
def _wrap_with_debug(rule):
353353
def helper(**kwargs):
354-
kwargs["debug"] = select({Label(":debug_build"): True, "//conditions:default": False})
354+
kwargs["debug"] = select({Label(":debug_venv_setting"): True, "//conditions:default": False})
355355
return rule(**kwargs)
356356

357357
return helper
@@ -383,7 +383,7 @@ def py_venv_link(venv_name = None, srcs = [], **kwargs):
383383

384384
# Note that the binary is already wrapped with debug
385385
link_script = str(Label("//py/private/py_venv:link.py"))
386-
kwargs["debug"] = select({Label(":debug_build"): True, "//conditions:default": False})
386+
kwargs["debug"] = select({Label(":debug_venv_setting"): True, "//conditions:default": False})
387387
py_venv_binary(
388388
args = [] + (["--name=" + venv_name] if venv_name else []),
389389
main = link_script,

0 commit comments

Comments
 (0)