From 5cb139591d97d873fff3f7b135ba2261a1f81628 2013-11-04 18:53:34
From: MinRK <benjaminrk@gmail.com>
Date: 2013-11-04 18:53:34
Subject: [PATCH] compare realpath in init_virtualenv

should help with symlinked envs

closes #4486
---

diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 31b1b2f..1b13c98 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -716,7 +716,9 @@ class InteractiveShell(SingletonConfigurable):
             # Not in a virtualenv
             return
         
-        if sys.executable.startswith(os.environ['VIRTUAL_ENV']):
+        if os.path.realpath(sys.executable).startswith(
+            os.path.realpath(os.environ['VIRTUAL_ENV'])
+        ):
             # Running properly in the virtualenv, don't need to do anything
             return