virtualenv-pythonw-osx
virtualenv-pythonw-osx copied to clipboard
Overwrite versioned python binary
When I create a virtualenv, the bin directory looks like this:
$ ls -l bin/
-rw-r--r-- 1 XXX XXX 2097 21 Jul 11:59 activate
-rw-r--r-- 1 XXX XXX 1039 21 Jul 11:59 activate.csh
-rw-r--r-- 1 XXX XXX 2237 21 Jul 11:59 activate.fish
-rw-r--r-- 1 XXX XXX 1137 21 Jul 11:59 activate_this.py
-rwxr-xr-x 1 XXX XXX 269 21 Jul 11:59 easy_install
-rwxr-xr-x 1 XXX XXX 269 21 Jul 11:59 easy_install-2.7
-rwxr-xr-x 1 XXX XXX 241 21 Jul 11:59 pip
-rwxr-xr-x 1 XXX XXX 241 21 Jul 11:59 pip2
-rwxr-xr-x 1 XXX XXX 241 21 Jul 11:59 pip2.7
lrwxr-xr-x 1 XXX XXX 9 21 Jul 11:59 python -> python2.7
-rwxr-xr-x 1 XXX XXX 2356 21 Jul 11:59 python-config
lrwxr-xr-x 1 XXX XXX 9 21 Jul 11:59 python2 -> python2.7
-rwxr-xr-x 1 XXX XXX 12568 21 Jul 11:59 python2.7
-rwxr-xr-x 1 XXX XXX 248 21 Jul 11:59 wheel
So you can see the python binary is actually a symlink to python2.7. If I use fix-virtualenv-osx currently, python is overwritten with a new binary which knows about frameworks. But python2.7 isn't. This means, for example, that an installation of ipython does not run the framework-enabled python binary (since pip install uses python2.7).
The following change would seem to DTRT in all cases:
--- a/install_pythonw/__init__.py
+++ b/install_pythonw/__init__.py>
@@ -102,7 +102,11 @@
pythonw_executable,
])
# Compile pythonw to bin directory.
+ import platform
+ suffix = '%s.%s' % platform.python_version_tuple()[:2]
for name in ['python','pythonw']:
+ if name == 'python':
+ name = name + suffix
pythonw_dest = path.join(env_path, 'bin', name)
call([
'cc',
Diff finished. Thu Jul 21 12:04:11 2016