Show More
@@ -0,0 +1,5 b'' | |||
|
1 | * Previous versions of IPython on Linux would use the XDG config directory, | |
|
2 | creating :file:`~/.config/ipython` by default. We have decided to go | |
|
3 | back to :file:`~/.ipython` for consistency among systems. IPython will | |
|
4 | issue a warning if it finds the XDG location, and will move it to the new | |
|
5 | location if there isn't already a directory there. |
@@ -45,10 +45,9 b' Usage' | |||
|
45 | 45 | |
|
46 | 46 | This file is typically installed in the `IPYTHONDIR` directory, and there |
|
47 | 47 | is a separate configuration directory for each profile. The default profile |
|
48 |
directory will be located in $IPYTHONDIR/profile_default. |
|
|
49 | IPYTHONDIR defaults to `$HOME/.config/ipython`, and for other Unix systems | |
|
50 | to `$HOME/.ipython`. For Windows users, $HOME resolves to C:\\Documents | |
|
51 | and Settings\\YourUserName in most instances. | |
|
48 | directory will be located in $IPYTHONDIR/profile_default. IPYTHONDIR | |
|
49 | defaults to to `$HOME/.ipython`. For Windows users, $HOME resolves to | |
|
50 | C:\\Documents and Settings\\YourUserName in most instances. | |
|
52 | 51 | |
|
53 | 52 | To initialize a profile with the default configuration file, do:: |
|
54 | 53 |
@@ -273,7 +273,6 b' def get_ipython_dir():' | |||
|
273 | 273 | |
|
274 | 274 | |
|
275 | 275 | ipdir_def = '.ipython' |
|
276 | xdg_def = 'ipython' | |
|
277 | 276 | |
|
278 | 277 | home_dir = get_home_dir() |
|
279 | 278 | xdg_dir = get_xdg_dir() |
@@ -284,20 +283,21 b' def get_ipython_dir():' | |||
|
284 | 283 | 'Please use IPYTHONDIR instead.') |
|
285 | 284 | ipdir = env.get('IPYTHONDIR', env.get('IPYTHON_DIR', None)) |
|
286 | 285 | if ipdir is None: |
|
287 |
# not set explicitly, use |
|
|
288 |
|
|
|
286 | # not set explicitly, use ~/.ipython | |
|
287 | ipdir = pjoin(home_dir, ipdir_def) | |
|
289 | 288 | if xdg_dir: |
|
290 | # use XDG, as long as the user isn't already | |
|
291 | # using $HOME/.ipython and *not* XDG/ipython | |
|
292 | ||
|
293 | xdg_ipdir = pjoin(xdg_dir, xdg_def) | |
|
294 | ||
|
295 | if _writable_dir(xdg_ipdir) or not _writable_dir(home_ipdir): | |
|
296 |
ipdir |
|
|
297 | ||
|
298 | if ipdir is None: | |
|
299 |
|
|
|
300 | ipdir = home_ipdir | |
|
289 | # Several IPython versions (up to 1.x) defaulted to .config/ipython | |
|
290 | # on Linux. We have decided to go back to using .ipython everywhere | |
|
291 | xdg_ipdir = pjoin(xdg_dir, 'ipython') | |
|
292 | ||
|
293 | if _writable_dir(xdg_ipdir): | |
|
294 | cu = compress_user | |
|
295 | if os.path.exists(ipdir): | |
|
296 | warnings.warn(('Ignoring {0} in favour of {1}. Remove {0} ' | |
|
297 | 'to get rid of this message').format(cu(xdg_ipdir), cu(ipdir))) | |
|
298 | else: | |
|
299 | warnings.warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir))) | |
|
300 | os.rename(xdg_ipdir, ipdir) | |
|
301 | 301 | |
|
302 | 302 | ipdir = os.path.normpath(os.path.expanduser(ipdir)) |
|
303 | 303 |
@@ -14,10 +14,12 b'' | |||
|
14 | 14 | |
|
15 | 15 | from __future__ import with_statement |
|
16 | 16 | |
|
17 | import errno | |
|
17 | 18 | import os |
|
18 | 19 | import shutil |
|
19 | 20 | import sys |
|
20 | 21 | import tempfile |
|
22 | import warnings | |
|
21 | 23 | from contextlib import contextmanager |
|
22 | 24 | |
|
23 | 25 | from os.path import join, abspath, split |
@@ -128,6 +130,15 b' def teardown_environment():' | |||
|
128 | 130 | # Build decorator that uses the setup_environment/setup_environment |
|
129 | 131 | with_environment = with_setup(setup_environment, teardown_environment) |
|
130 | 132 | |
|
133 | @contextmanager | |
|
134 | def patch_get_home_dir(dirpath): | |
|
135 | orig_get_home_dir = path.get_home_dir | |
|
136 | path.get_home_dir = lambda : dirpath | |
|
137 | try: | |
|
138 | yield | |
|
139 | finally: | |
|
140 | path.get_home_dir = orig_get_home_dir | |
|
141 | ||
|
131 | 142 | @skip_if_not_win32 |
|
132 | 143 | @with_environment |
|
133 | 144 | def test_get_home_dir_1(): |
@@ -225,74 +236,96 b' def test_get_ipython_dir_1():' | |||
|
225 | 236 | @with_environment |
|
226 | 237 | def test_get_ipython_dir_2(): |
|
227 | 238 | """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" |
|
228 |
|
|
|
229 | path.get_xdg_dir = lambda : None | |
|
230 | path._writable_dir = lambda path: True | |
|
231 | os.name = "posix" | |
|
232 | env.pop('IPYTHON_DIR', None) | |
|
233 | env.pop('IPYTHONDIR', None) | |
|
234 | env.pop('XDG_CONFIG_HOME', None) | |
|
235 | ipdir = path.get_ipython_dir() | |
|
236 | nt.assert_equal(ipdir, os.path.join("someplace", ".ipython")) | |
|
239 | with patch_get_home_dir('someplace'): | |
|
240 | path.get_xdg_dir = lambda : None | |
|
241 | path._writable_dir = lambda path: True | |
|
242 | os.name = "posix" | |
|
243 | env.pop('IPYTHON_DIR', None) | |
|
244 | env.pop('IPYTHONDIR', None) | |
|
245 | env.pop('XDG_CONFIG_HOME', None) | |
|
246 | ipdir = path.get_ipython_dir() | |
|
247 | nt.assert_equal(ipdir, os.path.join("someplace", ".ipython")) | |
|
237 | 248 | |
|
238 | 249 | @with_environment |
|
239 | 250 | def test_get_ipython_dir_3(): |
|
240 |
"""test_get_ipython_dir_3, |
|
|
241 | path.get_home_dir = lambda : "someplace" | |
|
242 | path._writable_dir = lambda path: True | |
|
243 | os.name = "posix" | |
|
244 | env.pop('IPYTHON_DIR', None) | |
|
245 | env.pop('IPYTHONDIR', None) | |
|
246 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
247 | ipdir = path.get_ipython_dir() | |
|
248 | if sys.platform == "darwin": | |
|
249 | expected = os.path.join("someplace", ".ipython") | |
|
250 | else: | |
|
251 | expected = os.path.join(XDG_TEST_DIR, "ipython") | |
|
252 | nt.assert_equal(ipdir, expected) | |
|
251 | """test_get_ipython_dir_3, move XDG if defined, and .ipython doesn't exist.""" | |
|
252 | tmphome = TemporaryDirectory() | |
|
253 | try: | |
|
254 | with patch_get_home_dir(tmphome.name): | |
|
255 | os.name = "posix" | |
|
256 | env.pop('IPYTHON_DIR', None) | |
|
257 | env.pop('IPYTHONDIR', None) | |
|
258 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
259 | ||
|
260 | with warnings.catch_warnings(record=True) as w: | |
|
261 | ipdir = path.get_ipython_dir() | |
|
262 | ||
|
263 | nt.assert_equal(ipdir, os.path.join(tmphome.name, ".ipython")) | |
|
264 | if sys.platform != 'darwin': | |
|
265 | nt.assert_equal(len(w), 1) | |
|
266 | nt.assert_in('Moving', str(w[0])) | |
|
267 | finally: | |
|
268 | tmphome.cleanup() | |
|
253 | 269 | |
|
254 | 270 | @with_environment |
|
255 | 271 | def test_get_ipython_dir_4(): |
|
256 |
"""test_get_ipython_dir_4, |
|
|
257 |
|
|
|
258 | os.name = "posix" | |
|
259 | env.pop('IPYTHON_DIR', None) | |
|
260 | env.pop('IPYTHONDIR', None) | |
|
261 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
262 | ipdir = path.get_ipython_dir() | |
|
263 | if sys.platform == "darwin": | |
|
264 | expected = os.path.join(HOME_TEST_DIR, ".ipython") | |
|
265 | else: | |
|
266 | expected = os.path.join(XDG_TEST_DIR, "ipython") | |
|
267 | nt.assert_equal(ipdir, expected) | |
|
272 | """test_get_ipython_dir_4, warn if XDG and home both exist.""" | |
|
273 | with patch_get_home_dir(HOME_TEST_DIR): | |
|
274 | os.name = "posix" | |
|
275 | env.pop('IPYTHON_DIR', None) | |
|
276 | env.pop('IPYTHONDIR', None) | |
|
277 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
278 | try: | |
|
279 | os.mkdir(os.path.join(XDG_TEST_DIR, 'ipython')) | |
|
280 | except OSError as e: | |
|
281 | if e.errno != errno.EEXIST: | |
|
282 | raise | |
|
283 | ||
|
284 | with warnings.catch_warnings(record=True) as w: | |
|
285 | ipdir = path.get_ipython_dir() | |
|
286 | ||
|
287 | nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, ".ipython")) | |
|
288 | if sys.platform != 'darwin': | |
|
289 | nt.assert_equal(len(w), 1) | |
|
290 | nt.assert_in('Ignoring', str(w[0])) | |
|
268 | 291 | |
|
269 | 292 | @with_environment |
|
270 | 293 | def test_get_ipython_dir_5(): |
|
271 | 294 | """test_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist.""" |
|
272 |
|
|
|
273 | os.name = "posix" | |
|
274 | env.pop('IPYTHON_DIR', None) | |
|
275 | env.pop('IPYTHONDIR', None) | |
|
276 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
277 | os.rmdir(os.path.join(XDG_TEST_DIR, 'ipython')) | |
|
278 | ipdir = path.get_ipython_dir() | |
|
279 | nt.assert_equal(ipdir, IP_TEST_DIR) | |
|
295 | with patch_get_home_dir(HOME_TEST_DIR): | |
|
296 | os.name = "posix" | |
|
297 | env.pop('IPYTHON_DIR', None) | |
|
298 | env.pop('IPYTHONDIR', None) | |
|
299 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR | |
|
300 | try: | |
|
301 | os.rmdir(os.path.join(XDG_TEST_DIR, 'ipython')) | |
|
302 | except OSError as e: | |
|
303 | if e.errno != errno.ENOENT: | |
|
304 | raise | |
|
305 | ipdir = path.get_ipython_dir() | |
|
306 | nt.assert_equal(ipdir, IP_TEST_DIR) | |
|
280 | 307 | |
|
281 | 308 | @with_environment |
|
282 | 309 | def test_get_ipython_dir_6(): |
|
283 | """test_get_ipython_dir_6, use XDG if defined and neither exist.""" | |
|
310 | """test_get_ipython_dir_6, use home over XDG if defined and neither exist.""" | |
|
284 | 311 | xdg = os.path.join(HOME_TEST_DIR, 'somexdg') |
|
285 | 312 | os.mkdir(xdg) |
|
286 | 313 | shutil.rmtree(os.path.join(HOME_TEST_DIR, '.ipython')) |
|
287 |
|
|
|
288 | path.get_xdg_dir = lambda : xdg | |
|
289 | os.name = "posix" | |
|
290 | env.pop('IPYTHON_DIR', None) | |
|
291 | env.pop('IPYTHONDIR', None) | |
|
292 |
env.pop(' |
|
|
293 | xdg_ipdir = os.path.join(xdg, "ipython") | |
|
294 | ipdir = path.get_ipython_dir() | |
|
295 | nt.assert_equal(ipdir, xdg_ipdir) | |
|
314 | with patch_get_home_dir(HOME_TEST_DIR): | |
|
315 | orig_get_xdg_dir = path.get_xdg_dir | |
|
316 | path.get_xdg_dir = lambda : xdg | |
|
317 | try: | |
|
318 | os.name = "posix" | |
|
319 | env.pop('IPYTHON_DIR', None) | |
|
320 | env.pop('IPYTHONDIR', None) | |
|
321 | env.pop('XDG_CONFIG_HOME', None) | |
|
322 | with warnings.catch_warnings(record=True) as w: | |
|
323 | ipdir = path.get_ipython_dir() | |
|
324 | ||
|
325 | nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, '.ipython')) | |
|
326 | nt.assert_equal(len(w), 0) | |
|
327 | finally: | |
|
328 | path.get_xdg_dir = orig_get_xdg_dir | |
|
296 | 329 | |
|
297 | 330 | @with_environment |
|
298 | 331 | def test_get_ipython_dir_7(): |
@@ -45,8 +45,7 b" or 'ipython \\-\\-help\\-all' for all available command\\(hyline options." | |||
|
45 | 45 | \fIIPYTHONDIR\fR |
|
46 | 46 | .RS 4 |
|
47 | 47 | This is the location where IPython stores all its configuration files. The default |
|
48 | on most platforms is $HOME/.ipython, but on Linux IPython respects the XDG config | |
|
49 | specification, which will put IPYTHONDIR in $HOME/.config/ipython by default. | |
|
48 | is $HOME/.ipython if IPYTHONDIR is not defined. | |
|
50 | 49 | |
|
51 | 50 | You can see the computed value of IPYTHONDIR with `ipython locate`. |
|
52 | 51 |
@@ -12,8 +12,7 b' Outdated configuration information that might still be useful' | |||
|
12 | 12 | This section will help you set various things in your environment for |
|
13 | 13 | your IPython sessions to be as efficient as possible. All of IPython's |
|
14 | 14 | configuration information, along with several example files, is stored |
|
15 |
in a directory named by default $HOME/. |
|
|
16 | exists (Linux), or $HOME/.ipython as a secondary default. You can change this by | |
|
15 | in a directory named by default $HOME/.ipython. You can change this by | |
|
17 | 16 | defining the environment variable IPYTHONDIR, or at runtime with the |
|
18 | 17 | command line option -ipythondir. |
|
19 | 18 |
@@ -270,21 +270,17 b' following algorithm:' | |||
|
270 | 270 | |
|
271 | 271 | * If not, the value returned by :func:`IPython.utils.path.get_ipython_dir` |
|
272 | 272 | is used. This function will first look at the :envvar:`IPYTHONDIR` |
|
273 |
environment variable and then default to |
|
|
273 | environment variable and then default to :file:`~/.ipython`. | |
|
274 | 274 | Historical support for the :envvar:`IPYTHON_DIR` environment variable will |
|
275 | 275 | be removed in a future release. |
|
276 | 276 | |
|
277 | On posix systems (Linux, Unix, etc.), IPython respects the ``$XDG_CONFIG_HOME`` | |
|
278 | part of the `XDG Base Directory`_ specification. If ``$XDG_CONFIG_HOME`` is | |
|
279 | defined and exists ( ``XDG_CONFIG_HOME`` has a default interpretation of | |
|
280 | :file:`$HOME/.config`), then IPython's config directory will be located in | |
|
281 | :file:`$XDG_CONFIG_HOME/ipython`. If users still have an IPython directory | |
|
282 | in :file:`$HOME/.ipython`, then that will be used. in preference to the | |
|
283 | system default. | |
|
277 | For most users, the configuration directory will be :file:`~/.ipython`. | |
|
284 | 278 | |
|
285 | For most users, the default value will simply be something like | |
|
286 | :file:`$HOME/.config/ipython` on Linux, or :file:`$HOME/.ipython` | |
|
287 | elsewhere. | |
|
279 | Previous versions of IPython on Linux would use the XDG config directory, | |
|
280 | creating :file:`~/.config/ipython` by default. We have decided to go | |
|
281 | back to :file:`~/.ipython` for consistency among systems. IPython will | |
|
282 | issue a warning if it finds the XDG location, and will move it to the new | |
|
283 | location if there isn't already a directory there. | |
|
288 | 284 | |
|
289 | 285 | Once the location of the IPython directory has been determined, you need to know |
|
290 | 286 | which profile you are using. For users with a single configuration, this will |
@@ -531,5 +527,3 b' Here are the main requirements we wanted our configuration system to have:' | |||
|
531 | 527 | dynamic language and you don't always know everything that needs to be |
|
532 | 528 | configured when a program starts. |
|
533 | 529 | |
|
534 | ||
|
535 | .. _`XDG Base Directory`: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html |
@@ -26,10 +26,10 b' the command line, simply because they are not practical here. Look into' | |||
|
26 | 26 | your configuration files for details on those. There are separate configuration |
|
27 | 27 | files for each profile, and the files look like "ipython_config.py" or |
|
28 | 28 | "ipython_config_<frontendname>.py". Profile directories look like |
|
29 |
"profile_profilename" and are typically installed in the IPYTHONDIR directory |
|
|
30 | For Linux users, this will be $HOME/.config/ipython, and for other users it | |
|
31 | will be $HOME/.ipython. For Windows users, $HOME resolves to C:\\Documents and | |
|
32 | Settings\\YourUserName in most instances. | |
|
29 | "profile_profilename" and are typically installed in the IPYTHONDIR directory, | |
|
30 | which defaults to :file:`$HOME/.ipython`. For Windows users, :envvar:`HOME` | |
|
31 | resolves to :file:`C:\\Documents and Settings\\YourUserName` in most | |
|
32 | instances. | |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | Eventloop integration |
@@ -181,8 +181,7 b' Configuration' | |||
|
181 | 181 | Much of IPython can be tweaked through :ref:`configuration <config_overview>`. |
|
182 | 182 | To get started, use the command ``ipython profile create`` to produce the |
|
183 | 183 | default config files. These will be placed in |
|
184 |
:file:`~/.ipython/profile_default` |
|
|
185 | :file:`~/.config/ipython/profile_default`, and contain comments explaining | |
|
184 | :file:`~/.ipython/profile_default`, and contain comments explaining | |
|
186 | 185 | what the various options do. |
|
187 | 186 | |
|
188 | 187 | Profiles allow you to use IPython for different tasks, keeping separate config |
@@ -627,7 +627,7 b' the engines.' | |||
|
627 | 627 | .. note:: |
|
628 | 628 | |
|
629 | 629 | The log output of ipcontroller above shows you where the json files were written. |
|
630 |
They will be in :file:`~/.ipython` |
|
|
630 | They will be in :file:`~/.ipython` under | |
|
631 | 631 | :file:`profile_default/security/ipcontroller-engine.json` |
|
632 | 632 | |
|
633 | 633 | 3. start the engines, using the connection file:: |
@@ -644,7 +644,7 b' A couple of notes:' | |||
|
644 | 644 | then you need not specify its path directly, only the profile (assumes the path exists, |
|
645 | 645 | otherwise you must create it first):: |
|
646 | 646 | |
|
647 |
[engine.host.n] $ scp controller.host:.ipython/profile_default/security/ipcontroller-engine.json ~/. |
|
|
647 | [engine.host.n] $ scp controller.host:.ipython/profile_default/security/ipcontroller-engine.json ~/.ipython/profile_ssh/security/ | |
|
648 | 648 | [engine.host.n] $ ipengine --profile=ssh |
|
649 | 649 | |
|
650 | 650 | Of course, if you fetch the file into the default profile, no arguments must be passed to |
General Comments 0
You need to be logged in to leave comments.
Login now