##// END OF EJS Templates
Merge pull request #10266 from Carreau/ipython-ext-dir...
Matthias Bussonnier -
r23364:cf7e3a38 merge
parent child Browse files
Show More
@@ -0,0 +1,5 b''
1 Loading extensions from ``ipython_extension_dir`` print a warning that this location is pending
2 deprecation. This should only affect users still having extensions installed with ``%install_ext``
3 which has been deprecated since IPython 4.0, and removed in 5.0. extensions still present in
4 ``ipython_extension_dir`` may shadow more recently installed versions using pip. It is thus
5 recommended to clean ``ipython_extension_dir`` of any extension now available as a package.
@@ -5,12 +5,14 b''
5 5 # Distributed under the terms of the Modified BSD License.
6 6
7 7 import os
8 import os.path
9 import warnings
8 10 from shutil import copyfile
9 11 import sys
10 12 from importlib import import_module
11 13
12 14 from traitlets.config.configurable import Configurable
13 from IPython.utils.path import ensure_dir_exists
15 from IPython.utils.path import ensure_dir_exists, compress_user
14 16 from traitlets import Instance
15 17
16 18 try:
@@ -75,13 +77,18 b' class ExtensionManager(Configurable):'
75 77 """
76 78 if module_str in self.loaded:
77 79 return "already loaded"
78
80
79 81 from IPython.utils.syspathcontext import prepended_to_syspath
80
82
81 83 with self.shell.builtin_trap:
82 84 if module_str not in sys.modules:
83 85 with prepended_to_syspath(self.ipython_extension_dir):
84 import_module(module_str)
86 mod = import_module(module_str)
87 if mod.__file__.startswith(self.ipython_extension_dir):
88 print(("Loading extensions from {dir} is deprecated. "
89 "We recommend managing extensions like any "
90 "other Python packages, in site-packages.").format(
91 dir=compress_user(self.ipython_extension_dir)))
85 92 mod = sys.modules[module_str]
86 93 if self._call_load_ipython_extension(mod):
87 94 self.loaded.add(module_str)
@@ -168,3 +175,5 b' class ExtensionManager(Configurable):'
168 175 filename = os.path.join(self.ipython_extension_dir, filename)
169 176 copy(url, filename)
170 177 return filename
178
179
General Comments 0
You need to be logged in to leave comments. Login now