From 4c7bf357d57d8c2919eed1589e1ed60e12cbe246 2013-10-29 19:50:48 From: Thomas Kluyver Date: 2013-10-29 19:50:48 Subject: [PATCH] Switch default IPython directory back to ~/.ipython As discussed at the dev meeting, we care more about a consistent default across platforms than half-heartedly following the XDG specs. --- diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 21b5dec..417013f 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -273,7 +273,6 @@ def get_ipython_dir(): ipdir_def = '.ipython' - xdg_def = 'ipython' home_dir = get_home_dir() xdg_dir = get_xdg_dir() @@ -284,20 +283,21 @@ def get_ipython_dir(): 'Please use IPYTHONDIR instead.') ipdir = env.get('IPYTHONDIR', env.get('IPYTHON_DIR', None)) if ipdir is None: - # not set explicitly, use XDG_CONFIG_HOME or HOME - home_ipdir = pjoin(home_dir, ipdir_def) + # not set explicitly, use ~/.ipython + ipdir = pjoin(home_dir, ipdir_def) if xdg_dir: - # use XDG, as long as the user isn't already - # using $HOME/.ipython and *not* XDG/ipython - - xdg_ipdir = pjoin(xdg_dir, xdg_def) - - if _writable_dir(xdg_ipdir) or not _writable_dir(home_ipdir): - ipdir = xdg_ipdir - - if ipdir is None: - # not using XDG - ipdir = home_ipdir + # Several IPython versions (up to 1.x) defaulted to .config/ipython + # on Linux. We have decided to go back to using .ipython everywhere + xdg_ipdir = pjoin(xdg_dir, 'ipython') + + if _writable_dir(xdg_ipdir): + cu = compress_user + if os.path.exists(ipdir): + warnings.warn(('Ignoring {0} in favour of {1}. Remove {0} ' + 'to get rid of this message').format(cu(xdg_ipdir), cu(ipdir))) + else: + warnings.warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir))) + os.rename(xdg_ipdir, ipdir) ipdir = os.path.normpath(os.path.expanduser(ipdir))