Show More
@@ -185,6 +185,17 b' class BaseIPythonApplication(Application):' | |||
|
185 | 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 | 199 | ipython_dir = Unicode( |
|
189 | 200 | help=""" |
|
190 | 201 | The name of the IPython directory. This directory is used for logging |
@@ -284,21 +295,24 b' class BaseIPythonApplication(Application):' | |||
|
284 | 295 | str_old = os.path.abspath(old) |
|
285 | 296 | if str_old in sys.path: |
|
286 | 297 | sys.path.remove(str_old) |
|
287 | str_path = os.path.abspath(new) | |
|
288 |
|
|
|
289 | ensure_dir_exists(new) | |
|
290 | readme = os.path.join(new, 'README') | |
|
291 | readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README') | |
|
292 | if not os.path.exists(readme) and os.path.exists(readme_src): | |
|
293 | shutil.copy(readme_src, readme) | |
|
294 | for d in ('extensions', 'nbextensions'): | |
|
295 | path = os.path.join(new, d) | |
|
296 | try: | |
|
297 | ensure_dir_exists(path) | |
|
298 | except OSError as e: | |
|
299 | # this will not be EEXIST | |
|
300 | self.log.error("couldn't create path %s: %s", path, e) | |
|
301 | self.log.debug("IPYTHONDIR set to: %s" % new) | |
|
298 | if self.add_ipython_dir_to_sys_path: | |
|
299 | str_path = os.path.abspath(new) | |
|
300 | sys.path.append(str_path) | |
|
301 | ensure_dir_exists(new) | |
|
302 | readme = os.path.join(new, "README") | |
|
303 | readme_src = os.path.join( | |
|
304 | get_ipython_package_dir(), "config", "profile", "README" | |
|
305 | ) | |
|
306 | if not os.path.exists(readme) and os.path.exists(readme_src): | |
|
307 | shutil.copy(readme_src, readme) | |
|
308 | for d in ("extensions", "nbextensions"): | |
|
309 | path = os.path.join(new, d) | |
|
310 | try: | |
|
311 | ensure_dir_exists(path) | |
|
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 | 317 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): |
|
304 | 318 | """Load the config file. |
General Comments 0
You need to be logged in to leave comments.
Login now