##// END OF EJS Templates
add configuration controlling whether the CWD gets added to sys.path
Nathan Goldbaum -
Show More
@@ -60,6 +60,10 b" addflag('color-info', 'InteractiveShell.color_info',"
60 colours.""",
60 colours.""",
61 "Disable using colors for info related things."
61 "Disable using colors for info related things."
62 )
62 )
63 addflag('ignore-cwd', 'InteractiveShellApp.ignore_cwd',
64 "Exclude the current working directory from sys.path",
65 "Include the current working directory in sys.path",
66 )
63 nosep_config = Config()
67 nosep_config = Config()
64 nosep_config.InteractiveShell.separate_in = ''
68 nosep_config.InteractiveShell.separate_in = ''
65 nosep_config.InteractiveShell.separate_out = ''
69 nosep_config.InteractiveShell.separate_out = ''
@@ -168,6 +172,12 b' class InteractiveShellApp(Configurable):'
168 When False, pylab mode should not import any names into the user namespace.
172 When False, pylab mode should not import any names into the user namespace.
169 """
173 """
170 ).tag(config=True)
174 ).tag(config=True)
175 ignore_cwd = Bool(
176 False,
177 help="""If True, IPython will not add the current working directory to sys.path.
178 When False, the current working directory is added to sys.path, allowing imports
179 of modules defined in the current directory."""
180 ).tag(config=True)
171 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',
181 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',
172 allow_none=True)
182 allow_none=True)
173 # whether interact-loop should start
183 # whether interact-loop should start
@@ -189,8 +199,10 b' class InteractiveShellApp(Configurable):'
189
199
190 .. versionchanged:: 7.2
200 .. versionchanged:: 7.2
191 Try to insert after the standard library, instead of first.
201 Try to insert after the standard library, instead of first.
202 .. versionchanged:: 8.0
203 Allow optionally not including the current directory in sys.path
192 """
204 """
193 if '' in sys.path:
205 if '' in sys.path or self.ignore_cwd:
194 return
206 return
195 for idx, path in enumerate(sys.path):
207 for idx, path in enumerate(sys.path):
196 parent, last_part = os.path.split(path)
208 parent, last_part = os.path.split(path)
General Comments 0
You need to be logged in to leave comments. Login now