Show More
@@ -185,6 +185,17 b' class BaseIPythonApplication(Application):' | |||||
185 | get_ipython_package_dir(), u'config', u'profile', change['new'] |
|
185 | get_ipython_package_dir(), u'config', u'profile', change['new'] | |
186 | ) |
|
186 | ) | |
187 |
|
187 | |||
|
188 | add_ipython_dir_to_sys_path = Bool( | |||
|
189 | False, | |||
|
190 | """Should the IPython profile directory be added to sys path ? | |||
|
191 | ||||
|
192 | This option was non-existing before IPython 8.0, and ipython_dir was added to | |||
|
193 | sys path to allow import of extensions present there. This was historical | |||
|
194 | baggage from when pip did not exist. This now default to false, | |||
|
195 | but can be set to true for legacy reasons. | |||
|
196 | """, | |||
|
197 | ).tag(config=True) | |||
|
198 | ||||
188 | ipython_dir = Unicode( |
|
199 | ipython_dir = Unicode( | |
189 | help=""" |
|
200 | help=""" | |
190 | The name of the IPython directory. This directory is used for logging |
|
201 | The name of the IPython directory. This directory is used for logging | |
@@ -284,21 +295,24 b' class BaseIPythonApplication(Application):' | |||||
284 | str_old = os.path.abspath(old) |
|
295 | str_old = os.path.abspath(old) | |
285 | if str_old in sys.path: |
|
296 | if str_old in sys.path: | |
286 | sys.path.remove(str_old) |
|
297 | sys.path.remove(str_old) | |
287 | str_path = os.path.abspath(new) |
|
298 | if self.add_ipython_dir_to_sys_path: | |
288 |
|
|
299 | str_path = os.path.abspath(new) | |
289 | ensure_dir_exists(new) |
|
300 | sys.path.append(str_path) | |
290 | readme = os.path.join(new, 'README') |
|
301 | ensure_dir_exists(new) | |
291 | readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README') |
|
302 | readme = os.path.join(new, "README") | |
292 | if not os.path.exists(readme) and os.path.exists(readme_src): |
|
303 | readme_src = os.path.join( | |
293 | shutil.copy(readme_src, readme) |
|
304 | get_ipython_package_dir(), "config", "profile", "README" | |
294 | for d in ('extensions', 'nbextensions'): |
|
305 | ) | |
295 | path = os.path.join(new, d) |
|
306 | if not os.path.exists(readme) and os.path.exists(readme_src): | |
296 | try: |
|
307 | shutil.copy(readme_src, readme) | |
297 | ensure_dir_exists(path) |
|
308 | for d in ("extensions", "nbextensions"): | |
298 | except OSError as e: |
|
309 | path = os.path.join(new, d) | |
299 | # this will not be EEXIST |
|
310 | try: | |
300 | self.log.error("couldn't create path %s: %s", path, e) |
|
311 | ensure_dir_exists(path) | |
301 | self.log.debug("IPYTHONDIR set to: %s" % new) |
|
312 | except OSError as e: | |
|
313 | # this will not be EEXIST | |||
|
314 | self.log.error("couldn't create path %s: %s", path, e) | |||
|
315 | self.log.debug("IPYTHONDIR set to: %s" % new) | |||
302 |
|
316 | |||
303 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): |
|
317 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): | |
304 | """Load the config file. |
|
318 | """Load the config file. |
General Comments 0
You need to be logged in to leave comments.
Login now