diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -152,17 +152,13 @@ """ for usl in (False, True): builder = venv.EnvBuilder(clear=True, symlinks=usl) - if (usl and sys.platform == 'darwin' and - '__PYVENV_LAUNCHER__' in os.environ): - self.assertRaises(ValueError, builder.create, self.env_dir) - else: - builder.create(self.env_dir) - fn = self.get_env_file(self.bindir, self.exe) - # Don't test when False, because e.g. 'python' is always - # symlinked to 'python3.3' in the env, even when symlinking in - # general isn't wanted. - if usl: - self.assertTrue(os.path.islink(fn)) + builder.create(self.env_dir) + fn = self.get_env_file(self.bindir, self.exe) + # Don't test when False, because e.g. 'python' is always + # symlinked to 'python3.3' in the env, even when symlinking in + # general isn't wanted. + if usl: + self.assertTrue(os.path.islink(fn)) def test_main(): run_unittest(BasicTest) diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -87,8 +87,9 @@ sysconfig.get_config_var('PYTHONFRAMEWORK')): # Symlinking the stub executable in an OSX framework build will # result in a broken virtual environment. - raise ValueError( - 'Symlinking is not supported on OSX framework Python.') + pass + #raise ValueError( + # 'Symlinking is not supported on OSX framework Python.') env_dir = os.path.abspath(env_dir) context = self.ensure_directories(env_dir) self.create_configuration(context) diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c --- a/Mac/Tools/pythonw.c +++ b/Mac/Tools/pythonw.c @@ -151,16 +151,18 @@ main(int argc, char **argv) { char* exec_path = get_python_path(); static char path[PATH_MAX * 2]; - static char real_path[PATH_MAX * 2]; int status; uint32_t size = PATH_MAX * 2; /* Set the original executable path in the environment. */ status = _NSGetExecutablePath(path, &size); if (status == 0) { - if (realpath(path, real_path) != NULL) { - setenv("__PYVENV_LAUNCHER__", real_path, 1); - } + /* + * Note: don't call 'realpath', that will + * erase symlink information, and that + * breaks "pyvenv --symlink" + */ + setenv("__PYVENV_LAUNCHER__", path, 1); } /* diff --git a/Modules/getpath.c b/Modules/getpath.c --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -628,7 +628,21 @@ wchar_t *env_cfg = L"pyvenv.cfg"; FILE * env_file = NULL; +#ifdef WITH_NEXT_FRAMEWORK + 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 + */ + wcsncpy(argv0_path, (wchar_t*)pyvenv_launcher, MAXPATHLEN); + } else { + wcscpy(tmpbuffer, argv0_path); + } + +#else wcscpy(tmpbuffer, argv0_path); +#endif joinpath(tmpbuffer, env_cfg); env_file = _Py_wfopen(tmpbuffer, L"r"); if (env_file == NULL) {