cpython: b79d276041a8 (original) (raw)

Mercurial > cpython

changeset 78160:b79d276041a8

Closes #15307: symlinks now work on OS X with framework Python builds. Patch by Ronald Oussoren. [#15307]

Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Tue, 17 Jul 2012 17:33:46 +0100
parents fbda36216f24
children af7961e1c362
files Doc/library/venv.rst Lib/test/test_venv.py Lib/venv/__init__.py Mac/Tools/pythonw.c Modules/getpath.c Modules/main.c
diffstat 6 files changed, 115 insertions(+), 27 deletions(-)[+] [-] Doc/library/venv.rst 2 Lib/test/test_venv.py 52 Lib/venv/__init__.py 10 Mac/Tools/pythonw.c 40 Modules/getpath.c 16 Modules/main.c 22

line wrap: on

line diff

--- a/Doc/library/venv.rst +++ b/Doc/library/venv.rst @@ -81,7 +81,7 @@ creation according to their needs, the : * symlinks -- a Boolean value indicating whether to attempt to symlink the Python binary (and any necessary DLLs or other binaries, e.g. pythonw.exe), rather than copying. Defaults to True on Linux and

* upgrade -- a Boolean value which, if True, will upgrade an existing environment with the running Python - for use when that Python has been

--- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -154,17 +154,47 @@ class BasicTest(BaseTest): """ for usl in (False, True): builder = venv.EnvBuilder(clear=True, symlinks=usl)

+

+

def test_main(): run_unittest(BasicTest)

--- a/Lib/venv/init.py +++ b/Lib/venv/init.py @@ -82,13 +82,6 @@ class EnvBuilder: :param env_dir: The target directory to create an environment in. """

@@ -366,8 +359,7 @@ def main(args=None): action='store_true', dest='system_site', help='Give the virtual environment access to the ' 'system site-packages dir.')

--- a/Mac/Tools/pythonw.c +++ b/Mac/Tools/pythonw.c @@ -28,6 +28,7 @@ #include <dlfcn.h> #include <stdlib.h> #include <Python.h> +#include <mach-o/dyld.h> extern char** environ; @@ -158,9 +159,44 @@ main(int argc, char *argv) { / Set the original executable path in the environment. */ status = _NSGetExecutablePath(path, &size); if (status == 0) {

+

+

--- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -474,6 +474,7 @@ calculate_path(void) wchar_t *defpath; #ifdef WITH_NEXT_FRAMEWORK NSModule pythonModule;

#endif #ifdef APPLE #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 @@ -568,8 +569,8 @@ calculate_path(void) / pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize")); / Use dylib functions to find out where the framework was loaded from */

@@ -578,7 +579,12 @@ calculate_path(void) ** be running the interpreter in the build directory, so we use the ** build-directory-specific logic to find Lib and such. */

+

@@ -589,8 +595,9 @@ calculate_path(void) } else { /* Use the location of the library as the progpath */

#endif @@ -629,6 +636,7 @@ calculate_path(void) FILE * env_file = NULL; wcscpy(tmpbuffer, argv0_path); + joinpath(tmpbuffer, env_cfg); env_file = _Py_wfopen(tmpbuffer, L"r"); if (env_file == NULL) {

--- a/Modules/main.c +++ b/Modules/main.c @@ -616,7 +616,29 @@ Py_Main(int argc, wchar_t *argv) Py_SetProgramName(buffer); / buffer is now handed off - do not free */ } else { +#ifdef WITH_NEXT_FRAMEWORK

+

+

+

+#else Py_SetProgramName(argv[0]); +#endif } #else Py_SetProgramName(argv[0]);