@@ -19,6 +19,11 @@ def _dict_to_exports(env):
1919 for (k , v ) in env .items ()
2020 ]
2121
22+ def _interpreter_flags (ctx ):
23+ py_toolchain = _py_semantics .resolve_toolchain (ctx )
24+
25+ return [it for it in py_toolchain .flags + ctx .attr .interpreter_options if it not in ["-I" ]]
26+
2227# FIXME: This is derived directly from the py_binary.bzl rule and should really
2328# be a layer on top of it if we can figure out flowing the data around. This is
2429# PoC quality.
@@ -137,7 +142,7 @@ def _py_venv_rule_impl(ctx):
137142 output = ctx .outputs .executable ,
138143 substitutions = {
139144 "{{BASH_RLOCATION_FN}}" : BASH_RLOCATION_FUNCTION .strip (),
140- "{{INTERPRETER_FLAGS}}" : " " .join (py_toolchain . flags + ctx . attr . interpreter_options ),
145+ "{{INTERPRETER_FLAGS}}" : " " .join (_interpreter_flags ( ctx ) ),
141146 "{{ENTRYPOINT}}" : "${VIRTUAL_ENV}/bin/python" ,
142147 "{{ARG_VENV}}" : to_rlocation_path (ctx , venv_dir ),
143148 },
@@ -204,7 +209,7 @@ def _py_venv_binary_impl(ctx):
204209 output = ctx .outputs .executable ,
205210 substitutions = {
206211 "{{BASH_RLOCATION_FN}}" : BASH_RLOCATION_FUNCTION .strip (),
207- "{{INTERPRETER_FLAGS}}" : " " .join (py_toolchain . flags + ctx . attr . interpreter_options ),
212+ "{{INTERPRETER_FLAGS}}" : " " .join (_interpreter_flags ( ctx ) ),
208213 "{{ENTRYPOINT}}" : to_rlocation_path (ctx , ctx .file .main ),
209214 "{{ARG_VENV}}" : to_rlocation_path (ctx , venv_dir ),
210215 "{{RUNFILES_INTERPRETER}}" : str (py_toolchain .runfiles_interpreter ).lower (),
0 commit comments