##// END OF EJS Templates
Merge pull request #10644 from minrk/env-config...
Matthias Bussonnier -
r23767:2118e16d merge
parent child Browse files
Show More
@@ -0,0 +1,5 b''
1
2 - IPython now looks for config files in ``{sys.prefix}/etc/ipython``
3 for environment-specific configuration.
4 - Startup files can be found in ``/etc/ipython/startup`` or ``{sys.prefix}/etc/ipython/startup``
5 in addition to the profile directory, for system-wide or env-specific startup files.
@@ -43,6 +43,14 b' else:'
43 43 "/etc/ipython",
44 44 ]
45 45
46
47 ENV_CONFIG_DIRS = []
48 _env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython')
49 if _env_config_dir not in SYSTEM_CONFIG_DIRS:
50 # only add ENV_CONFIG if sys.prefix is not already included
51 ENV_CONFIG_DIRS.append(_env_config_dir)
52
53
46 54 _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
47 55 if _envvar in {None, ''}:
48 56 IPYTHON_SUPPRESS_CONFIG_ERRORS = None
@@ -398,6 +406,7 b' class BaseIPythonApplication(Application):'
398 406
399 407 def init_config_files(self):
400 408 """[optionally] copy default config files into profile dir."""
409 self.config_file_paths.extend(ENV_CONFIG_DIRS)
401 410 self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
402 411 # copy config files
403 412 path = self.builtin_profile_dir
@@ -8,12 +8,14 b' launch InteractiveShell instances, load extensions, etc.'
8 8 # Distributed under the terms of the Modified BSD License.
9 9
10 10 import glob
11 from itertools import chain
11 12 import os
12 13 import sys
13 14
14 15 from traitlets.config.application import boolean_flag
15 16 from traitlets.config.configurable import Configurable
16 17 from traitlets.config.loader import Config
18 from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS
17 19 from IPython.core import pylabtools
18 20 from IPython.utils.contexts import preserve_keys
19 21 from IPython.utils.path import filefind
@@ -324,7 +326,9 b' class InteractiveShellApp(Configurable):'
324 326
325 327 def _run_startup_files(self):
326 328 """Run files from profile startup directory"""
327 startup_dir = self.profile_dir.startup_dir
329 startup_dirs = [self.profile_dir.startup_dir] + [
330 os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS)
331 ]
328 332 startup_files = []
329 333
330 334 if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \
@@ -336,9 +340,9 b' class InteractiveShellApp(Configurable):'
336 340 except:
337 341 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
338 342 self.shell.showtraceback()
339
340 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
341 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
343 for startup_dir in startup_dirs[::-1]:
344 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
345 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
342 346 if not startup_files:
343 347 return
344 348
General Comments 0
You need to be logged in to leave comments. Login now