File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,23 @@ def _maybe_add_path(path):
199199
200200 return coverage_setup
201201
202+ # The pyvenv.cfg created for py_binary leaves the `home` key unset. A
203+ # side-effect of this is `sys._base_executable` points to the venv executable,
204+ # not the actual executable. This mostly doesn't matter, but does affect
205+ # using the venv module to create venvs (they point to the venv executable, not
206+ # the actual executable).
207+ def _fixup_sys_base_executable ():
208+ # Must have been set correctly?
209+ if sys .executable != sys ._base_executable :
210+ return
211+ # Not in a venv, so don't touch anything.
212+ if sys .prefix == sys .base_prefix :
213+ return
214+ exe = os .path .realpath (sys .executable )
215+ _print_verbose ("setting sys._base_executable:" , exe )
216+ sys ._base_executable = exe
217+
218+ _fixup_sys_base_executable ()
202219
203220COVERAGE_SETUP = _setup_sys_path ()
204221_print_verbose ("DONE" )
You can’t perform that action at this time.
0 commit comments