File tree Expand file tree Collapse file tree 4 files changed +59
-8
lines changed Expand file tree Collapse file tree 4 files changed +59
-8
lines changed Original file line number Diff line number Diff line change @@ -38,3 +38,45 @@ config_setting(
3838 ":venv_strategy" : "dynamic" ,
3939 },
4040)
41+
42+ string_flag (
43+ name = "linking_strategy" ,
44+ build_setting_default = "per-package" ,
45+ values = [
46+ "per-package" ,
47+ "workspace-root" ,
48+ "workon-root" ,
49+ ],
50+ visibility = ["//visibility:public" ],
51+ )
52+
53+ config_setting (
54+ name = "link_to_package" ,
55+ flag_values = {
56+ ":linking_strategy" : "per-package" ,
57+ },
58+ )
59+
60+ config_setting (
61+ name = "link_to_workspace" ,
62+ flag_values = {
63+ ":linking_strategy" : "workspace-root" ,
64+ },
65+ )
66+
67+ config_setting (
68+ name = "link_to_workon" ,
69+ flag_values = {
70+ ":linking_strategy" : "workspace-root" ,
71+ },
72+ )
73+
74+ string_flag (
75+ name = "naming_strategy" ,
76+ build_setting_default = "venv-name" ,
77+ values = [
78+ "venv-name" , # Respect the virtualenv's name property
79+ "dot-venv" , # Use .venv as the name of the link
80+ ],
81+
82+ )
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ def py_link_venv(
3737 if venv_dest != None :
3838 args = ["--dest=" + venv_dest ] + args
3939
40+ # Default configurable behavior
41+ if not venv_name and not venv_dest :
42+ args = select ({
43+ Label (":link_per_package" ): ["--dest=$BUILD_WORKING_DIRECTORY/" + native .package (), "--name=.venv" ] + args
44+ "//conditions:default" : args
45+ })
46+
4047 binary_rule (
4148 name = name ,
4249 args = args ,
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def munge_venv_name(target_package, virtualenv_name):
4545 )
4646
4747 opts = PARSER .parse_args ()
48- dest = Path (os .path .join (opts .dest , opts .name ))
48+ dest = Path (os .path .join (os . path . expandvars ( opts .dest ) , opts .name ))
4949 print ("""
5050
5151Linking: {venv_home} -> {venv_path}
Original file line number Diff line number Diff line change 99 visibility = ["//visibility:public" ],
1010)
1111
12- string_flag (
13- name = "venv_strategy" ,
14- build_setting_default = "dynamic" ,
15- values = [
16- "dynamic" ,
17- "static" ,
18- ],
12+ alias (
13+ name = "link_venv_strategy" ,
14+ actual = "//py/private/link:venv_strategy" ,
15+ visibility = ["//visibility:public" ],
16+ )
17+
18+ alias (
19+ name = "linking_strategy" ,
20+ actual = "//py/private/link:linking_strategy" ,
1921 visibility = ["//visibility:public" ],
2022)
You can’t perform that action at this time.
0 commit comments