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 | "/etc/ipython", |
|
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 | _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS') |
|
54 | _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS') | |
47 | if _envvar in {None, ''}: |
|
55 | if _envvar in {None, ''}: | |
48 | IPYTHON_SUPPRESS_CONFIG_ERRORS = None |
|
56 | IPYTHON_SUPPRESS_CONFIG_ERRORS = None | |
@@ -398,6 +406,7 b' class BaseIPythonApplication(Application):' | |||||
398 |
|
406 | |||
399 | def init_config_files(self): |
|
407 | def init_config_files(self): | |
400 | """[optionally] copy default config files into profile dir.""" |
|
408 | """[optionally] copy default config files into profile dir.""" | |
|
409 | self.config_file_paths.extend(ENV_CONFIG_DIRS) | |||
401 | self.config_file_paths.extend(SYSTEM_CONFIG_DIRS) |
|
410 | self.config_file_paths.extend(SYSTEM_CONFIG_DIRS) | |
402 | # copy config files |
|
411 | # copy config files | |
403 | path = self.builtin_profile_dir |
|
412 | path = self.builtin_profile_dir |
@@ -8,12 +8,14 b' launch InteractiveShell instances, load extensions, etc.' | |||||
8 | # Distributed under the terms of the Modified BSD License. |
|
8 | # Distributed under the terms of the Modified BSD License. | |
9 |
|
9 | |||
10 | import glob |
|
10 | import glob | |
|
11 | from itertools import chain | |||
11 | import os |
|
12 | import os | |
12 | import sys |
|
13 | import sys | |
13 |
|
14 | |||
14 | from traitlets.config.application import boolean_flag |
|
15 | from traitlets.config.application import boolean_flag | |
15 | from traitlets.config.configurable import Configurable |
|
16 | from traitlets.config.configurable import Configurable | |
16 | from traitlets.config.loader import Config |
|
17 | from traitlets.config.loader import Config | |
|
18 | from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS | |||
17 | from IPython.core import pylabtools |
|
19 | from IPython.core import pylabtools | |
18 | from IPython.utils.contexts import preserve_keys |
|
20 | from IPython.utils.contexts import preserve_keys | |
19 | from IPython.utils.path import filefind |
|
21 | from IPython.utils.path import filefind | |
@@ -324,7 +326,9 b' class InteractiveShellApp(Configurable):' | |||||
324 |
|
326 | |||
325 | def _run_startup_files(self): |
|
327 | def _run_startup_files(self): | |
326 | """Run files from profile startup directory""" |
|
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 | startup_files = [] |
|
332 | startup_files = [] | |
329 |
|
333 | |||
330 | if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \ |
|
334 | if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \ | |
@@ -336,9 +340,9 b' class InteractiveShellApp(Configurable):' | |||||
336 | except: |
|
340 | except: | |
337 | self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup) |
|
341 | self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup) | |
338 | self.shell.showtraceback() |
|
342 | self.shell.showtraceback() | |
339 |
|
343 | for startup_dir in startup_dirs[::-1]: | ||
340 | startup_files += glob.glob(os.path.join(startup_dir, '*.py')) |
|
344 | startup_files += glob.glob(os.path.join(startup_dir, '*.py')) | |
341 | startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) |
|
345 | startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) | |
342 | if not startup_files: |
|
346 | if not startup_files: | |
343 | return |
|
347 | return | |
344 |
|
348 |
General Comments 0
You need to be logged in to leave comments.
Login now