From dbeeefd16d5339437700ebc6eb55359ca6232bea 2012-05-04 17:41:06 From: Min RK Date: 2012-05-04 17:41:06 Subject: [PATCH] Merge pull request #1693 from bfroehle/_1167_ipythondir deprecate IPYTHON_DIR in favor of IPYTHONDIR IPYTHON_DIR was a proposed rename, whose added complexity does not outweigh any potential benefit, and is reverted. closes #1167 --- diff --git a/IPython/core/application.py b/IPython/core/application.py index 4b49a94..42ba4e6 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -118,7 +118,7 @@ class BaseIPythonApplication(Application): The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $HOME/.ipython. This options can also be specified through - the environment variable IPYTHON_DIR. + the environment variable IPYTHONDIR. """ ) @@ -148,7 +148,7 @@ class BaseIPythonApplication(Application): def __init__(self, **kwargs): super(BaseIPythonApplication, self).__init__(**kwargs) - # ensure even default IPYTHON_DIR exists + # ensure even default IPYTHONDIR exists if not os.path.exists(self.ipython_dir): self._ipython_dir_changed('ipython_dir', self.ipython_dir, self.ipython_dir) @@ -186,7 +186,7 @@ class BaseIPythonApplication(Application): if not os.path.exists(readme): path = os.path.join(get_ipython_package_dir(), u'config', u'profile') shutil.copy(os.path.join(path, 'README'), readme) - self.log.debug("IPYTHON_DIR set to: %s" % new) + self.log.debug("IPYTHONDIR set to: %s" % new) def load_config_file(self, suppress_errors=True): """Load the config file. diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py index dc1b382..4520c4a 100644 --- a/IPython/core/profileapp.py +++ b/IPython/core/profileapp.py @@ -135,7 +135,7 @@ class ProfileList(Application): The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $HOME/.ipython. This options can also be specified through - the environment variable IPYTHON_DIR. + the environment variable IPYTHONDIR. """ ) diff --git a/IPython/core/usage.py b/IPython/core/usage.py index 303106f..90506b3 100644 --- a/IPython/core/usage.py +++ b/IPython/core/usage.py @@ -39,10 +39,10 @@ Usage configuration, look into your `ipython_config.py` configuration file for details. - This file is typically installed in the `IPYTHON_DIR` directory, and there + This file is typically installed in the `IPYTHONDIR` directory, and there is a separate configuration directory for each profile. The default profile - directory will be located in $IPYTHON_DIR/profile_default. For Linux users, - IPYTHON_DIR defaults to `$HOME/.config/ipython`, and for other Unix systems + directory will be located in $IPYTHONDIR/profile_default. For Linux users, + IPYTHONDIR defaults to `$HOME/.config/ipython`, and for other Unix systems to `$HOME/.ipython`. For Windows users, $HOME resolves to C:\\Documents and Settings\\YourUserName in most instances. @@ -50,10 +50,10 @@ Usage $> ipython profile create - and start editing `IPYTHON_DIR/profile_default/ipython_config.py` + and start editing `IPYTHONDIR/profile_default/ipython_config.py` In IPython's documentation, we will refer to this directory as - `IPYTHON_DIR`, you can change its default location by creating an + `IPYTHONDIR`, you can change its default location by creating an environment variable with this name and setting it to the desired path. For more information, see the manual available in HTML and PDF in your diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 36f7f14..86aa04b 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -260,7 +260,10 @@ def get_ipython_dir(): xdg_dir = get_xdg_dir() # import pdb; pdb.set_trace() # dbg - ipdir = env.get('IPYTHON_DIR', env.get('IPYTHONDIR', None)) + if 'IPYTHON_DIR' in env: + warnings.warn('The environment variable IPYTHON_DIR is deprecated. ' + '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) @@ -318,7 +321,7 @@ def get_ipython_module_path(module_str): def locate_profile(profile='default'): """Find the path to the folder associated with a given profile. - I.e. find $IPYTHON_DIR/profile_whatever. + I.e. find $IPYTHONDIR/profile_whatever. """ from IPython.core.profiledir import ProfileDir, ProfileDirError try: diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py index fa3c182..cc69739 100644 --- a/IPython/utils/tests/test_path.py +++ b/IPython/utils/tests/test_path.py @@ -206,7 +206,7 @@ def test_get_ipython_dir_1(): """test_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions.""" env_ipdir = os.path.join("someplace", ".ipython") path._writable_dir = lambda path: True - env['IPYTHON_DIR'] = env_ipdir + env['IPYTHONDIR'] = env_ipdir ipdir = path.get_ipython_dir() nt.assert_equal(ipdir, env_ipdir) @@ -278,10 +278,10 @@ def test_get_ipython_dir_6(): @with_environment def test_get_ipython_dir_7(): - """test_get_ipython_dir_7, test home directory expansion on IPYTHON_DIR""" + """test_get_ipython_dir_7, test home directory expansion on IPYTHONDIR""" path._writable_dir = lambda path: True home_dir = os.path.expanduser('~') - env['IPYTHON_DIR'] = os.path.join('~', 'somewhere') + env['IPYTHONDIR'] = os.path.join('~', 'somewhere') ipdir = path.get_ipython_dir() nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere')) diff --git a/docs/man/ipcluster.1 b/docs/man/ipcluster.1 index 48a7c9b..5aeeac3 100644 --- a/docs/man/ipcluster.1 +++ b/docs/man/ipcluster.1 @@ -11,7 +11,7 @@ ipcluster is a control tool for IPython's parallel computing functions. IPython cluster startup. This starts a controller and engines using various -approaches. Use the IPYTHON_DIR environment variable to change your IPython +approaches. Use the IPYTHONDIR environment variable to change your IPython directory from the default of ~/.ipython or ~/.config/ipython. The log and security subdirectories of your IPython directory will be used by this script for log files and security files. diff --git a/docs/man/ipcontroller.1 b/docs/man/ipcontroller.1 index 4c03881..3b6d8da 100644 --- a/docs/man/ipcontroller.1 +++ b/docs/man/ipcontroller.1 @@ -100,7 +100,7 @@ Default: u'/Users/minrk/.ipython' The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $HOME/.ipython. This options can also be specified through the -environment variable IPYTHON_DIR. +environment variable IPYTHONDIR. .TP .B \-\-url= (HubFactory.url) Default: '' diff --git a/docs/man/iplogger.1 b/docs/man/iplogger.1 index 92245f8..98c0011 100644 --- a/docs/man/iplogger.1 +++ b/docs/man/iplogger.1 @@ -51,7 +51,7 @@ whether to log to a file The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $XDG_CONFIG_HOME/ipython. This options can also be specified -through the environment variable IPYTHON_DIR. +through the environment variable IPYTHONDIR. .TP .B \-\-url= (LogWatcher.url) . diff --git a/docs/man/ipython.1 b/docs/man/ipython.1 index 48be69c..a21a3ae 100644 --- a/docs/man/ipython.1 +++ b/docs/man/ipython.1 @@ -182,7 +182,7 @@ Default: u'/Users/minrk/.ipython' The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $HOME/.ipython. This options can also be specified through the -environment variable IPYTHON_DIR. +environment variable IPYTHONDIR. .TP .B \-\-gui= (TerminalIPythonApp.gui) Default: None diff --git a/docs/source/config/old.txt b/docs/source/config/old.txt index fe6e0bd..e166fbc 100644 --- a/docs/source/config/old.txt +++ b/docs/source/config/old.txt @@ -95,7 +95,7 @@ sequences. You can go to a 'no color' mode by typing '%colors NoColor'. You can try using a different terminal emulator program (Emacs users, see below). To permanently set your color preferences, edit the file -$IPYTHON_DIR/ipythonrc and set the colors option to the desired value. +$IPYTHONDIR/ipythonrc and set the colors option to the desired value. Object details (types, docstrings, source code, etc.) diff --git a/docs/source/config/overview.txt b/docs/source/config/overview.txt index 6837aa1..a0f6a0b 100644 --- a/docs/source/config/overview.txt +++ b/docs/source/config/overview.txt @@ -284,8 +284,10 @@ following algorithm: * If the ``ipython_dir`` command line flag is given, its value is used. * If not, the value returned by :func:`IPython.utils.path.get_ipython_dir` - is used. This function will first look at the :envvar:`IPYTHON_DIR` + is used. This function will first look at the :envvar:`IPYTHONDIR` environment variable and then default to a platform-specific default. + Historical support for the :envvar:`IPYTHON_DIR` environment variable will + be removed in a future release. On posix systems (Linux, Unix, etc.), IPython respects the ``$XDG_CONFIG_HOME`` part of the `XDG Base Directory`_ specification. If ``$XDG_CONFIG_HOME`` is @@ -302,7 +304,7 @@ elsewhere. Once the location of the IPython directory has been determined, you need to know which profile you are using. For users with a single configuration, this will simply be 'default', and will be located in -:file:`/profile_default`. +:file:`/profile_default`. The next thing you need to know is what to call your configuration file. The basic idea is that each application has its own default configuration filename. @@ -344,7 +346,7 @@ Let's start by showing how a profile is used: This tells the :command:`ipython` command line program to get its configuration from the "sympy" profile. The file names for various profiles do not change. The only difference is that profiles are named in a special way. In the case above, -the "sympy" profile means looking for :file:`ipython_config.py` in :file:`/profile_sympy`. +the "sympy" profile means looking for :file:`ipython_config.py` in :file:`/profile_sympy`. The general pattern is this: simply create a new profile with: diff --git a/docs/source/interactive/qtconsole.txt b/docs/source/interactive/qtconsole.txt index f1f76f1..6f65002 100644 --- a/docs/source/interactive/qtconsole.txt +++ b/docs/source/interactive/qtconsole.txt @@ -400,9 +400,9 @@ generate this key, but the default is just to generate a new UUID. You can gener private key with:: # generate 1024b of random data, and store in a file only you can read: - # (assumes IPYTHON_DIR is defined, otherwise use your IPython directory) - $> python -c "import os; print os.urandom(128).encode('base64')" > $IPYTHON_DIR/sessionkey - $> chmod 600 $IPYTHON_DIR/sessionkey + # (assumes IPYTHONDIR is defined, otherwise use your IPython directory) + $> python -c "import os; print os.urandom(128).encode('base64')" > $IPYTHONDIR/sessionkey + $> chmod 600 $IPYTHONDIR/sessionkey The *contents* of this file will be stored in the JSON connection file, so that file contains everything you need to connect to and use a kernel. @@ -411,7 +411,7 @@ To use this generated key, simply specify the ``Session.keyfile`` configurable in :file:`ipython_config.py` or at the command-line, as in:: # instruct IPython to sign messages with that key, instead of a new UUID - $> ipython qtconsole --Session.keyfile=$IPYTHON_DIR/sessionkey + $> ipython qtconsole --Session.keyfile=$IPYTHONDIR/sessionkey .. _ssh_tunnels: diff --git a/docs/source/interactive/reference.txt b/docs/source/interactive/reference.txt index 48064a2..9a78c8c 100644 --- a/docs/source/interactive/reference.txt +++ b/docs/source/interactive/reference.txt @@ -26,7 +26,7 @@ the command line, simply because they are not practical here. Look into your configuration files for details on those. There are separate configuration files for each profile, and the files look like "ipython_config.py" or "ipython_config_.py". Profile directories look like -"profile_profilename" and are typically installed in the IPYTHON_DIR directory. +"profile_profilename" and are typically installed in the IPYTHONDIR directory. For Linux users, this will be $HOME/.config/ipython, and for other users it will be $HOME/.ipython. For Windows users, $HOME resolves to C:\\Documents and Settings\\YourUserName in most instances. @@ -249,7 +249,7 @@ Persistent command history across sessions IPython will save your input history when it leaves and reload it next time you restart it. By default, the history file is named -$IPYTHON_DIR/profile_/history.sqlite. This allows you to keep +$IPYTHONDIR/profile_/history.sqlite. This allows you to keep separate histories related to various tasks: commands related to numerical work will not be clobbered by a system shell history, for example. diff --git a/docs/source/interactive/shell.txt b/docs/source/interactive/shell.txt index 306db9a..a1690c7 100644 --- a/docs/source/interactive/shell.txt +++ b/docs/source/interactive/shell.txt @@ -26,7 +26,7 @@ the "pysh" shortcut in start menu. If you want to use the features of sh profile as your defaults (which might be a good idea if you use other profiles a lot of the time but still want the convenience of sh profile), add ``import ipy_profile_sh`` -to your $IPYTHON_DIR/ipy_user_conf.py. +to your $IPYTHONDIR/ipy_user_conf.py. The 'sh' profile is different from the default profile in that: diff --git a/docs/source/parallel/parallel_multiengine.txt b/docs/source/parallel/parallel_multiengine.txt index 9f035f2..f51fe41 100644 --- a/docs/source/parallel/parallel_multiengine.txt +++ b/docs/source/parallel/parallel_multiengine.txt @@ -37,7 +37,7 @@ module and then create a :class:`.Client` instance: In [2]: rc = Client() This form assumes that the default connection information (stored in -:file:`ipcontroller-client.json` found in :file:`IPYTHON_DIR/profile_default/security`) is +:file:`ipcontroller-client.json` found in :file:`IPYTHONDIR/profile_default/security`) is accurate. If the controller was started on a remote machine, you must copy that connection file to the client machine, or enter its contents as arguments to the Client constructor: diff --git a/docs/source/whatsnew/development.txt b/docs/source/whatsnew/development.txt index 1023655..8ddd483 100644 --- a/docs/source/whatsnew/development.txt +++ b/docs/source/whatsnew/development.txt @@ -15,4 +15,9 @@ Other new features * **%install_ext**: A new magic function to install an IPython extension from a URL. E.g. ``%install_ext https://bitbucket.org/birkenfeld/ipython-physics/raw/d1310a2ab15d/physics.py``. +* The :envvar:`IPYTHON_DIR` environment variable, introduced in the Great + Reorganization of 0.11 and existing only in versions 0.11-0.13, has been + deprecated. As described in :ghissue:`1167`, the complexity and confusion of + migrating to this variable is not worth the aesthetic improvement. Please use + the historical :envvar:`IPYTHONDIR` environment variable instead.