diff --git a/IPython/genutils.py b/IPython/genutils.py index 38f93ef..2dbe37a 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -928,12 +928,17 @@ def get_home_dir(): # first, check py2exe distribution root directory for _ipython. # This overrides all. Normally does not exist. - if '\\library.zip\\' in IPython.__file__.lower(): - root, rest = IPython.__file__.lower().split('library.zip') - if isdir(root + '_ipython'): + if hasattr(sys, "frozen"): #Is frozen by py2exe + if '\\library.zip\\' in IPython.__file__.lower():#libraries compressed to zip-file + root, rest = IPython.__file__.lower().split('library.zip') + if isdir(root + '_ipython'): + os.environ["IPYKITROOT"] = root.rstrip('\\') + return root + else: + root=os.path.abspath(os.path.join(os.path.split(IPython.__file__)[0],"../../")) + if isdir(os.path.join(root, '_ipython')): os.environ["IPYKITROOT"] = root.rstrip('\\') return root - try: homedir = env['HOME'] if not isdir(homedir): diff --git a/IPython/tests/test_genutils.py b/IPython/tests/test_genutils.py index 9072ec1..7e4bb78 100644 --- a/IPython/tests/test_genutils.py +++ b/IPython/tests/test_genutils.py @@ -16,12 +16,26 @@ __docformat__ = "restructuredtext en" #----------------------------------------------------------------------------- from IPython import genutils +import os +env = os.environ -def test_get_home_dir(): +def test_get_home_dir_1(): """Make sure we can get the home directory.""" home_dir = genutils.get_home_dir() +def test_get_home_dir_2(): + """Make sure we can get the home directory.""" + old=env["HOME"] + env["HOME"]=os.path.join(".","home_test_dir") + home_dir = genutils.get_home_dir() + assert home_dir==env["HOME"] + env["HOME"]=old + + + + + def test_get_ipython_dir(): """Make sure we can get the ipython directory.""" ipdir = genutils.get_ipython_dir()