##// END OF EJS Templates
Merge pull request #10652 from ipython/auto-backport-of-pr-10644...
Matthias Bussonnier -
r23769:61da6efb 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.
@@ -44,6 +44,14 b' else:'
44 "/etc/ipython",
44 "/etc/ipython",
45 ]
45 ]
46
46
47
48 ENV_CONFIG_DIRS = []
49 _env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython')
50 if _env_config_dir not in SYSTEM_CONFIG_DIRS:
51 # only add ENV_CONFIG if sys.prefix is not already included
52 ENV_CONFIG_DIRS.append(_env_config_dir)
53
54
47 _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
55 _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
48 if _envvar in {None, ''}:
56 if _envvar in {None, ''}:
49 IPYTHON_SUPPRESS_CONFIG_ERRORS = None
57 IPYTHON_SUPPRESS_CONFIG_ERRORS = None
@@ -403,6 +411,7 b' class BaseIPythonApplication(Application):'
403
411
404 def init_config_files(self):
412 def init_config_files(self):
405 """[optionally] copy default config files into profile dir."""
413 """[optionally] copy default config files into profile dir."""
414 self.config_file_paths.extend(ENV_CONFIG_DIRS)
406 self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
415 self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
407 # copy config files
416 # copy config files
408 path = self.builtin_profile_dir
417 path = self.builtin_profile_dir
@@ -11,12 +11,14 b' from __future__ import absolute_import'
11 from __future__ import print_function
11 from __future__ import print_function
12
12
13 import glob
13 import glob
14 from itertools import chain
14 import os
15 import os
15 import sys
16 import sys
16
17
17 from traitlets.config.application import boolean_flag
18 from traitlets.config.application import boolean_flag
18 from traitlets.config.configurable import Configurable
19 from traitlets.config.configurable import Configurable
19 from traitlets.config.loader import Config
20 from traitlets.config.loader import Config
21 from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS
20 from IPython.core import pylabtools
22 from IPython.core import pylabtools
21 from IPython.utils import py3compat
23 from IPython.utils import py3compat
22 from IPython.utils.contexts import preserve_keys
24 from IPython.utils.contexts import preserve_keys
@@ -331,7 +333,9 b' class InteractiveShellApp(Configurable):'
331
333
332 def _run_startup_files(self):
334 def _run_startup_files(self):
333 """Run files from profile startup directory"""
335 """Run files from profile startup directory"""
334 startup_dir = self.profile_dir.startup_dir
336 startup_dirs = [self.profile_dir.startup_dir] + [
337 os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS)
338 ]
335 startup_files = []
339 startup_files = []
336
340
337 if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \
341 if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \
@@ -343,9 +347,9 b' class InteractiveShellApp(Configurable):'
343 except:
347 except:
344 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
348 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
345 self.shell.showtraceback()
349 self.shell.showtraceback()
346
350 for startup_dir in startup_dirs[::-1]:
347 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
351 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
348 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
352 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
349 if not startup_files:
353 if not startup_files:
350 return
354 return
351
355
General Comments 0
You need to be logged in to leave comments. Login now