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,6 +5,9 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 | |
|
10 | import textwrap | |
|
8 | 11 | from shutil import copyfile |
|
9 | 12 | import sys |
|
10 | 13 | from importlib import import_module |
@@ -75,13 +78,34 b' class ExtensionManager(Configurable):' | |||
|
75 | 78 | """ |
|
76 | 79 | if module_str in self.loaded: |
|
77 | 80 | return "already loaded" |
|
78 | ||
|
81 | ||
|
79 | 82 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
80 | ||
|
83 | ||
|
81 | 84 | with self.shell.builtin_trap: |
|
82 | 85 | if module_str not in sys.modules: |
|
83 | 86 | with prepended_to_syspath(self.ipython_extension_dir): |
|
84 | import_module(module_str) | |
|
87 | mod = import_module(module_str) | |
|
88 | if mod.__file__.startswith(self.ipython_extension_dir): | |
|
89 | print(textwrap.dedent( | |
|
90 | """ | |
|
91 | Warning, you are attempting to load and IPython extensions from legacy | |
|
92 | location. | |
|
93 | ||
|
94 | IPythonhas been requested to load extension `{ext}` which has been found in | |
|
95 | `ipython_extension_dir` (`{dir}`). | |
|
96 | ||
|
97 | It is likely you previously installed an extension using the `%install_ext` | |
|
98 | mechanism which has been deprecated since IPython 4.0. Loading extensions | |
|
99 | from the above directory is still supported but will be deprecated in a | |
|
100 | future version of IPython. | |
|
101 | ||
|
102 | Extensions should now be installed and managed as Python packages. We | |
|
103 | recommend you update your extensions accordingly. | |
|
104 | ||
|
105 | Old extensions files present in `ipython_extension_dir` may cause newly | |
|
106 | installed extensions to not be recognized. Thus you may need to clean | |
|
107 | the content of above mentioned directory. | |
|
108 | """.format(dir=self.ipython_extension_dir, ext=module_str))) | |
|
85 | 109 | mod = sys.modules[module_str] |
|
86 | 110 | if self._call_load_ipython_extension(mod): |
|
87 | 111 | self.loaded.add(module_str) |
@@ -168,3 +192,5 b' class ExtensionManager(Configurable):' | |||
|
168 | 192 | filename = os.path.join(self.ipython_extension_dir, filename) |
|
169 | 193 | copy(url, filename) |
|
170 | 194 | return filename |
|
195 | ||
|
196 |
General Comments 0
You need to be logged in to leave comments.
Login now