Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: bpo-22490: Remove __PYVENV_LAUNCHER__ from the codebase. #9498

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,7 @@ def write_history():
def venv(known_paths):
global PREFIXES, ENABLE_USER_SITE

env = os.environ
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
executable = os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
executable = sys.executable
exe_dir, _ = os.path.split(os.path.abspath(executable))
site_prefix = os.path.dirname(exe_dir)
sys._home = None
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ def is_env_var_to_ignore(n):
# on adding even when the environment in exec is empty.
# Gentoo sandboxes also force LD_PRELOAD and SANDBOX_* to exist.
return ('VERSIONER' in n or '__CF' in n or # MacOS
'__PYVENV_LAUNCHER__' in n or # MacOS framework build
n == 'LD_PRELOAD' or n.startswith('SANDBOX') or # Gentoo
n == 'LC_CTYPE') # Locale coercion triggered

Expand Down
11 changes: 2 additions & 9 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ def setUp(self):
self.bindir = 'bin'
self.lib = ('lib', 'python%d.%d' % sys.version_info[:2])
self.include = 'include'
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ:
executable = os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
executable = sys.executable
self.exe = os.path.split(executable)[-1]

def tearDown(self):
Expand Down Expand Up @@ -100,11 +97,7 @@ def test_defaults(self):
else:
self.assertFalse(os.path.exists(p))
data = self.get_text_file_contents('pyvenv.cfg')
if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__'
in os.environ):
executable = os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
executable = sys.executable
path = os.path.dirname(executable)
self.assertIn('home = %s' % path, data)
fn = self.get_env_file(self.bindir, self.exe)
Expand Down
6 changes: 1 addition & 5 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ def create_if_needed(d):
prompt = self.prompt if self.prompt is not None else context.env_name
context.prompt = '(%s) ' % prompt
create_if_needed(env_dir)
env = os.environ
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
executable = os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
executable = sys.executable
dirname, exename = os.path.split(os.path.abspath(executable))
context.executable = executable
context.python_dir = dirname
Expand Down
2 changes: 0 additions & 2 deletions Mac/Tools/pythonw.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ main(int argc, char **argv) {
err(1, "realpath: %s", path);
}
}

setenv("__PYVENV_LAUNCHER__", real_path, 1);
}

/*
Expand Down
22 changes: 2 additions & 20 deletions Python/coreconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
}


/* Get the program name: use PYTHONEXECUTABLE and __PYVENV_LAUNCHER__
environment variables on macOS if available. */
/* Get the program name: use PYTHONEXECUTABLE
environment variable on macOS if available. */
static _PyInitError
config_init_program_name(_PyCoreConfig *config)
{
Expand Down Expand Up @@ -543,24 +543,6 @@ config_init_program_name(_PyCoreConfig *config)
config->program_name = program_name;
return _Py_INIT_OK();
}
#ifdef WITH_NEXT_FRAMEWORK
else {
const char* pyvenv_launcher = getenv("__PYVENV_LAUNCHER__");
if (pyvenv_launcher && *pyvenv_launcher) {
/* Used by Mac/Tools/pythonw.c to forward
* the argv0 of the stub executable
*/
size_t len;
wchar_t* program_name = Py_DecodeLocale(pyvenv_launcher, &len);
if (program_name == NULL) {
return DECODE_LOCALE_ERR("__PYVENV_LAUNCHER__ environment "
"variable", (Py_ssize_t)len);
}
config->program_name = program_name;
return _Py_INIT_OK();
}
}
#endif /* WITH_NEXT_FRAMEWORK */
#endif /* __APPLE__ */

/* Use argv[0] by default, if available */
Expand Down