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 | # Distributed under the terms of the Modified BSD License. |
|
5 | # Distributed under the terms of the Modified BSD License. | |
6 |
|
6 | |||
7 | import os |
|
7 | import os | |
|
8 | import os.path | |||
|
9 | import warnings | |||
8 | from shutil import copyfile |
|
10 | from shutil import copyfile | |
9 | import sys |
|
11 | import sys | |
10 | from importlib import import_module |
|
12 | from importlib import import_module | |
11 |
|
13 | |||
12 | from traitlets.config.configurable import Configurable |
|
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 | from traitlets import Instance |
|
16 | from traitlets import Instance | |
15 |
|
17 | |||
16 | try: |
|
18 | try: | |
@@ -81,7 +83,12 b' class ExtensionManager(Configurable):' | |||||
81 | with self.shell.builtin_trap: |
|
83 | with self.shell.builtin_trap: | |
82 | if module_str not in sys.modules: |
|
84 | if module_str not in sys.modules: | |
83 | with prepended_to_syspath(self.ipython_extension_dir): |
|
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 | mod = sys.modules[module_str] |
|
92 | mod = sys.modules[module_str] | |
86 | if self._call_load_ipython_extension(mod): |
|
93 | if self._call_load_ipython_extension(mod): | |
87 | self.loaded.add(module_str) |
|
94 | self.loaded.add(module_str) | |
@@ -168,3 +175,5 b' class ExtensionManager(Configurable):' | |||||
168 | filename = os.path.join(self.ipython_extension_dir, filename) |
|
175 | filename = os.path.join(self.ipython_extension_dir, filename) | |
169 | copy(url, filename) |
|
176 | copy(url, filename) | |
170 | return filename |
|
177 | return filename | |
|
178 | ||||
|
179 |
General Comments 0
You need to be logged in to leave comments.
Login now