##// END OF EJS Templates
Removed ipapi compatability layer and updated top-level functions....
Brian Granger -
Show More
@@ -1,58 +1,35 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # encoding: utf-8
2 # encoding: utf-8
3 """
3 """
4 Oh my @#*%, where did ipapi go?
4 This module is *completely* deprecated and should no longer be used for
5
5 any purpose. Currently, we have a few parts of the core that have
6 Originally, this module was designed to be a public api for IPython. It is
6 not been componentized and thus, still rely on this module. When everything
7 now deprecated and replaced by :class:`IPython.core.Interactive` shell.
7 has been made into a component, this module will be sent to deathrow.
8 Almost all of the methods that were here are now there, but possibly renamed.
9
10 During our transition, we will keep this simple module with its :func:`get`
11 function. It too will eventually go away when the new component querying
12 interface is fully used.
13
14 Authors:
15
16 * Brian Granger
17 """
8 """
18
9
19 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
20 # Copyright (C) 2008-2009 The IPython Development Team
11 # Copyright (C) 2008-2009 The IPython Development Team
21 #
12 #
22 # Distributed under the terms of the BSD License. The full license is in
13 # Distributed under the terms of the BSD License. The full license is in
23 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
24 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
25
16
26 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
27 # Imports
18 # Imports
28 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
29
20
30 from IPython.core.error import TryNext, UsageError
21 from IPython.core.error import TryNext, UsageError
31
22
32 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
33 # Classes and functions
24 # Classes and functions
34 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
35
26
36 def get():
27 def get():
37 """Get the most recently created InteractiveShell instance."""
28 """Get the most recently created InteractiveShell instance."""
38 from IPython.core.iplib import InteractiveShell
29 from IPython.core.iplib import InteractiveShell
39 insts = InteractiveShell.get_instances()
30 insts = InteractiveShell.get_instances()
40 most_recent = insts[0]
31 most_recent = insts[0]
41 for inst in insts[1:]:
32 for inst in insts[1:]:
42 if inst.created > most_recent.created:
33 if inst.created > most_recent.created:
43 most_recent = inst
34 most_recent = inst
44 return most_recent
35 return most_recent
45
46 def launch_new_instance():
47 """Create a run a full blown IPython instance"""
48 from IPython.core.ipapp import IPythonApp
49 app = IPythonApp()
50 app.start()
51
52
53
54
55
56
57
58
@@ -1,543 +1,545 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # encoding: utf-8
2 # encoding: utf-8
3 """
3 """
4 The main IPython application object
4 The main IPython application object
5
5
6 Authors:
6 Authors:
7
7
8 * Brian Granger
8 * Brian Granger
9 * Fernando Perez
9 * Fernando Perez
10
10
11 Notes
11 Notes
12 -----
12 -----
13 """
13 """
14
14
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16 # Copyright (C) 2008-2009 The IPython Development Team
16 # Copyright (C) 2008-2009 The IPython Development Team
17 #
17 #
18 # Distributed under the terms of the BSD License. The full license is in
18 # Distributed under the terms of the BSD License. The full license is in
19 # the file COPYING, distributed as part of this software.
19 # the file COPYING, distributed as part of this software.
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Imports
23 # Imports
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25
25
26 import logging
26 import logging
27 import os
27 import os
28 import sys
28 import sys
29 import warnings
29 import warnings
30
30
31 from IPython.core.application import Application, IPythonArgParseConfigLoader
31 from IPython.core.application import Application, IPythonArgParseConfigLoader
32 from IPython.core import release
32 from IPython.core import release
33 from IPython.core.iplib import InteractiveShell
33 from IPython.core.iplib import InteractiveShell
34 from IPython.config.loader import (
34 from IPython.config.loader import (
35 NoConfigDefault,
35 NoConfigDefault,
36 Config,
36 Config,
37 ConfigError,
37 ConfigError,
38 PyFileConfigLoader
38 PyFileConfigLoader
39 )
39 )
40
40
41 from IPython.lib import inputhook
41 from IPython.lib import inputhook
42
42
43 from IPython.utils.ipstruct import Struct
43 from IPython.utils.ipstruct import Struct
44 from IPython.utils.genutils import filefind, get_ipython_dir
44 from IPython.utils.genutils import filefind, get_ipython_dir
45
45
46 #-----------------------------------------------------------------------------
46 #-----------------------------------------------------------------------------
47 # Utilities and helpers
47 # Utilities and helpers
48 #-----------------------------------------------------------------------------
48 #-----------------------------------------------------------------------------
49
49
50
50
51 ipython_desc = """
51 ipython_desc = """
52 A Python shell with automatic history (input and output), dynamic object
52 A Python shell with automatic history (input and output), dynamic object
53 introspection, easier configuration, command completion, access to the system
53 introspection, easier configuration, command completion, access to the system
54 shell and more.
54 shell and more.
55 """
55 """
56
56
57 def pylab_warning():
57 def pylab_warning():
58 msg = """
58 msg = """
59
59
60 IPython's -pylab mode has been disabled until matplotlib supports this version
60 IPython's -pylab mode has been disabled until matplotlib supports this version
61 of IPython. This version of IPython has greatly improved GUI integration that
61 of IPython. This version of IPython has greatly improved GUI integration that
62 matplotlib will soon be able to take advantage of. This will eventually
62 matplotlib will soon be able to take advantage of. This will eventually
63 result in greater stability and a richer API for matplotlib under IPython.
63 result in greater stability and a richer API for matplotlib under IPython.
64 However during this transition, you will either need to use an older version
64 However during this transition, you will either need to use an older version
65 of IPython, or do the following to use matplotlib interactively::
65 of IPython, or do the following to use matplotlib interactively::
66
66
67 import matplotlib
67 import matplotlib
68 matplotlib.interactive(True)
68 matplotlib.interactive(True)
69 matplotlib.use('wxagg') # adjust for your backend
69 matplotlib.use('wxagg') # adjust for your backend
70 %gui -a wx # adjust for your GUI
70 %gui -a wx # adjust for your GUI
71 from matplotlib import pyplot as plt
71 from matplotlib import pyplot as plt
72
72
73 See the %gui magic for information on the new interface.
73 See the %gui magic for information on the new interface.
74 """
74 """
75 warnings.warn(msg, category=DeprecationWarning, stacklevel=1)
75 warnings.warn(msg, category=DeprecationWarning, stacklevel=1)
76
76
77
77
78 #-----------------------------------------------------------------------------
78 #-----------------------------------------------------------------------------
79 # Main classes and functions
79 # Main classes and functions
80 #-----------------------------------------------------------------------------
80 #-----------------------------------------------------------------------------
81
81
82 cl_args = (
82 cl_args = (
83 (('-autocall',), dict(
83 (('-autocall',), dict(
84 type=int, dest='InteractiveShell.autocall', default=NoConfigDefault,
84 type=int, dest='InteractiveShell.autocall', default=NoConfigDefault,
85 help='Set the autocall value (0,1,2).',
85 help='Set the autocall value (0,1,2).',
86 metavar='InteractiveShell.autocall')
86 metavar='InteractiveShell.autocall')
87 ),
87 ),
88 (('-autoindent',), dict(
88 (('-autoindent',), dict(
89 action='store_true', dest='InteractiveShell.autoindent', default=NoConfigDefault,
89 action='store_true', dest='InteractiveShell.autoindent', default=NoConfigDefault,
90 help='Turn on autoindenting.')
90 help='Turn on autoindenting.')
91 ),
91 ),
92 (('-noautoindent',), dict(
92 (('-noautoindent',), dict(
93 action='store_false', dest='InteractiveShell.autoindent', default=NoConfigDefault,
93 action='store_false', dest='InteractiveShell.autoindent', default=NoConfigDefault,
94 help='Turn off autoindenting.')
94 help='Turn off autoindenting.')
95 ),
95 ),
96 (('-automagic',), dict(
96 (('-automagic',), dict(
97 action='store_true', dest='InteractiveShell.automagic', default=NoConfigDefault,
97 action='store_true', dest='InteractiveShell.automagic', default=NoConfigDefault,
98 help='Turn on the auto calling of magic commands.')
98 help='Turn on the auto calling of magic commands.')
99 ),
99 ),
100 (('-noautomagic',), dict(
100 (('-noautomagic',), dict(
101 action='store_false', dest='InteractiveShell.automagic', default=NoConfigDefault,
101 action='store_false', dest='InteractiveShell.automagic', default=NoConfigDefault,
102 help='Turn off the auto calling of magic commands.')
102 help='Turn off the auto calling of magic commands.')
103 ),
103 ),
104 (('-autoedit_syntax',), dict(
104 (('-autoedit_syntax',), dict(
105 action='store_true', dest='InteractiveShell.autoedit_syntax', default=NoConfigDefault,
105 action='store_true', dest='InteractiveShell.autoedit_syntax', default=NoConfigDefault,
106 help='Turn on auto editing of files with syntax errors.')
106 help='Turn on auto editing of files with syntax errors.')
107 ),
107 ),
108 (('-noautoedit_syntax',), dict(
108 (('-noautoedit_syntax',), dict(
109 action='store_false', dest='InteractiveShell.autoedit_syntax', default=NoConfigDefault,
109 action='store_false', dest='InteractiveShell.autoedit_syntax', default=NoConfigDefault,
110 help='Turn off auto editing of files with syntax errors.')
110 help='Turn off auto editing of files with syntax errors.')
111 ),
111 ),
112 (('-banner',), dict(
112 (('-banner',), dict(
113 action='store_true', dest='Global.display_banner', default=NoConfigDefault,
113 action='store_true', dest='Global.display_banner', default=NoConfigDefault,
114 help='Display a banner upon starting IPython.')
114 help='Display a banner upon starting IPython.')
115 ),
115 ),
116 (('-nobanner',), dict(
116 (('-nobanner',), dict(
117 action='store_false', dest='Global.display_banner', default=NoConfigDefault,
117 action='store_false', dest='Global.display_banner', default=NoConfigDefault,
118 help="Don't display a banner upon starting IPython.")
118 help="Don't display a banner upon starting IPython.")
119 ),
119 ),
120 (('-cache_size',), dict(
120 (('-cache_size',), dict(
121 type=int, dest='InteractiveShell.cache_size', default=NoConfigDefault,
121 type=int, dest='InteractiveShell.cache_size', default=NoConfigDefault,
122 help="Set the size of the output cache.",
122 help="Set the size of the output cache.",
123 metavar='InteractiveShell.cache_size')
123 metavar='InteractiveShell.cache_size')
124 ),
124 ),
125 (('-classic',), dict(
125 (('-classic',), dict(
126 action='store_true', dest='Global.classic', default=NoConfigDefault,
126 action='store_true', dest='Global.classic', default=NoConfigDefault,
127 help="Gives IPython a similar feel to the classic Python prompt.")
127 help="Gives IPython a similar feel to the classic Python prompt.")
128 ),
128 ),
129 (('-colors',), dict(
129 (('-colors',), dict(
130 type=str, dest='InteractiveShell.colors', default=NoConfigDefault,
130 type=str, dest='InteractiveShell.colors', default=NoConfigDefault,
131 help="Set the color scheme (NoColor, Linux, and LightBG).",
131 help="Set the color scheme (NoColor, Linux, and LightBG).",
132 metavar='InteractiveShell.colors')
132 metavar='InteractiveShell.colors')
133 ),
133 ),
134 (('-color_info',), dict(
134 (('-color_info',), dict(
135 action='store_true', dest='InteractiveShell.color_info', default=NoConfigDefault,
135 action='store_true', dest='InteractiveShell.color_info', default=NoConfigDefault,
136 help="Enable using colors for info related things.")
136 help="Enable using colors for info related things.")
137 ),
137 ),
138 (('-nocolor_info',), dict(
138 (('-nocolor_info',), dict(
139 action='store_false', dest='InteractiveShell.color_info', default=NoConfigDefault,
139 action='store_false', dest='InteractiveShell.color_info', default=NoConfigDefault,
140 help="Disable using colors for info related things.")
140 help="Disable using colors for info related things.")
141 ),
141 ),
142 (('-confirm_exit',), dict(
142 (('-confirm_exit',), dict(
143 action='store_true', dest='InteractiveShell.confirm_exit', default=NoConfigDefault,
143 action='store_true', dest='InteractiveShell.confirm_exit', default=NoConfigDefault,
144 help="Prompt the user when existing.")
144 help="Prompt the user when existing.")
145 ),
145 ),
146 (('-noconfirm_exit',), dict(
146 (('-noconfirm_exit',), dict(
147 action='store_false', dest='InteractiveShell.confirm_exit', default=NoConfigDefault,
147 action='store_false', dest='InteractiveShell.confirm_exit', default=NoConfigDefault,
148 help="Don't prompt the user when existing.")
148 help="Don't prompt the user when existing.")
149 ),
149 ),
150 (('-deep_reload',), dict(
150 (('-deep_reload',), dict(
151 action='store_true', dest='InteractiveShell.deep_reload', default=NoConfigDefault,
151 action='store_true', dest='InteractiveShell.deep_reload', default=NoConfigDefault,
152 help="Enable deep (recursive) reloading by default.")
152 help="Enable deep (recursive) reloading by default.")
153 ),
153 ),
154 (('-nodeep_reload',), dict(
154 (('-nodeep_reload',), dict(
155 action='store_false', dest='InteractiveShell.deep_reload', default=NoConfigDefault,
155 action='store_false', dest='InteractiveShell.deep_reload', default=NoConfigDefault,
156 help="Disable deep (recursive) reloading by default.")
156 help="Disable deep (recursive) reloading by default.")
157 ),
157 ),
158 (('-editor',), dict(
158 (('-editor',), dict(
159 type=str, dest='InteractiveShell.editor', default=NoConfigDefault,
159 type=str, dest='InteractiveShell.editor', default=NoConfigDefault,
160 help="Set the editor used by IPython (default to $EDITOR/vi/notepad).",
160 help="Set the editor used by IPython (default to $EDITOR/vi/notepad).",
161 metavar='InteractiveShell.editor')
161 metavar='InteractiveShell.editor')
162 ),
162 ),
163 (('-log','-l'), dict(
163 (('-log','-l'), dict(
164 action='store_true', dest='InteractiveShell.logstart', default=NoConfigDefault,
164 action='store_true', dest='InteractiveShell.logstart', default=NoConfigDefault,
165 help="Start logging to the default file (./ipython_log.py).")
165 help="Start logging to the default file (./ipython_log.py).")
166 ),
166 ),
167 (('-logfile','-lf'), dict(
167 (('-logfile','-lf'), dict(
168 type=str, dest='InteractiveShell.logfile', default=NoConfigDefault,
168 type=str, dest='InteractiveShell.logfile', default=NoConfigDefault,
169 help="Start logging to logfile.",
169 help="Start logging to logfile.",
170 metavar='InteractiveShell.logfile')
170 metavar='InteractiveShell.logfile')
171 ),
171 ),
172 (('-logappend','-la'), dict(
172 (('-logappend','-la'), dict(
173 type=str, dest='InteractiveShell.logappend', default=NoConfigDefault,
173 type=str, dest='InteractiveShell.logappend', default=NoConfigDefault,
174 help="Start logging to logappend in append mode.",
174 help="Start logging to logappend in append mode.",
175 metavar='InteractiveShell.logfile')
175 metavar='InteractiveShell.logfile')
176 ),
176 ),
177 (('-pdb',), dict(
177 (('-pdb',), dict(
178 action='store_true', dest='InteractiveShell.pdb', default=NoConfigDefault,
178 action='store_true', dest='InteractiveShell.pdb', default=NoConfigDefault,
179 help="Enable auto calling the pdb debugger after every exception.")
179 help="Enable auto calling the pdb debugger after every exception.")
180 ),
180 ),
181 (('-nopdb',), dict(
181 (('-nopdb',), dict(
182 action='store_false', dest='InteractiveShell.pdb', default=NoConfigDefault,
182 action='store_false', dest='InteractiveShell.pdb', default=NoConfigDefault,
183 help="Disable auto calling the pdb debugger after every exception.")
183 help="Disable auto calling the pdb debugger after every exception.")
184 ),
184 ),
185 (('-pprint',), dict(
185 (('-pprint',), dict(
186 action='store_true', dest='InteractiveShell.pprint', default=NoConfigDefault,
186 action='store_true', dest='InteractiveShell.pprint', default=NoConfigDefault,
187 help="Enable auto pretty printing of results.")
187 help="Enable auto pretty printing of results.")
188 ),
188 ),
189 (('-nopprint',), dict(
189 (('-nopprint',), dict(
190 action='store_false', dest='InteractiveShell.pprint', default=NoConfigDefault,
190 action='store_false', dest='InteractiveShell.pprint', default=NoConfigDefault,
191 help="Disable auto auto pretty printing of results.")
191 help="Disable auto auto pretty printing of results.")
192 ),
192 ),
193 (('-prompt_in1','-pi1'), dict(
193 (('-prompt_in1','-pi1'), dict(
194 type=str, dest='InteractiveShell.prompt_in1', default=NoConfigDefault,
194 type=str, dest='InteractiveShell.prompt_in1', default=NoConfigDefault,
195 help="Set the main input prompt ('In [\#]: ')",
195 help="Set the main input prompt ('In [\#]: ')",
196 metavar='InteractiveShell.prompt_in1')
196 metavar='InteractiveShell.prompt_in1')
197 ),
197 ),
198 (('-prompt_in2','-pi2'), dict(
198 (('-prompt_in2','-pi2'), dict(
199 type=str, dest='InteractiveShell.prompt_in2', default=NoConfigDefault,
199 type=str, dest='InteractiveShell.prompt_in2', default=NoConfigDefault,
200 help="Set the secondary input prompt (' .\D.: ')",
200 help="Set the secondary input prompt (' .\D.: ')",
201 metavar='InteractiveShell.prompt_in2')
201 metavar='InteractiveShell.prompt_in2')
202 ),
202 ),
203 (('-prompt_out','-po'), dict(
203 (('-prompt_out','-po'), dict(
204 type=str, dest='InteractiveShell.prompt_out', default=NoConfigDefault,
204 type=str, dest='InteractiveShell.prompt_out', default=NoConfigDefault,
205 help="Set the output prompt ('Out[\#]:')",
205 help="Set the output prompt ('Out[\#]:')",
206 metavar='InteractiveShell.prompt_out')
206 metavar='InteractiveShell.prompt_out')
207 ),
207 ),
208 (('-quick',), dict(
208 (('-quick',), dict(
209 action='store_true', dest='Global.quick', default=NoConfigDefault,
209 action='store_true', dest='Global.quick', default=NoConfigDefault,
210 help="Enable quick startup with no config files.")
210 help="Enable quick startup with no config files.")
211 ),
211 ),
212 (('-readline',), dict(
212 (('-readline',), dict(
213 action='store_true', dest='InteractiveShell.readline_use', default=NoConfigDefault,
213 action='store_true', dest='InteractiveShell.readline_use', default=NoConfigDefault,
214 help="Enable readline for command line usage.")
214 help="Enable readline for command line usage.")
215 ),
215 ),
216 (('-noreadline',), dict(
216 (('-noreadline',), dict(
217 action='store_false', dest='InteractiveShell.readline_use', default=NoConfigDefault,
217 action='store_false', dest='InteractiveShell.readline_use', default=NoConfigDefault,
218 help="Disable readline for command line usage.")
218 help="Disable readline for command line usage.")
219 ),
219 ),
220 (('-screen_length','-sl'), dict(
220 (('-screen_length','-sl'), dict(
221 type=int, dest='InteractiveShell.screen_length', default=NoConfigDefault,
221 type=int, dest='InteractiveShell.screen_length', default=NoConfigDefault,
222 help='Number of lines on screen, used to control printing of long strings.',
222 help='Number of lines on screen, used to control printing of long strings.',
223 metavar='InteractiveShell.screen_length')
223 metavar='InteractiveShell.screen_length')
224 ),
224 ),
225 (('-separate_in','-si'), dict(
225 (('-separate_in','-si'), dict(
226 type=str, dest='InteractiveShell.separate_in', default=NoConfigDefault,
226 type=str, dest='InteractiveShell.separate_in', default=NoConfigDefault,
227 help="Separator before input prompts. Default '\n'.",
227 help="Separator before input prompts. Default '\n'.",
228 metavar='InteractiveShell.separate_in')
228 metavar='InteractiveShell.separate_in')
229 ),
229 ),
230 (('-separate_out','-so'), dict(
230 (('-separate_out','-so'), dict(
231 type=str, dest='InteractiveShell.separate_out', default=NoConfigDefault,
231 type=str, dest='InteractiveShell.separate_out', default=NoConfigDefault,
232 help="Separator before output prompts. Default 0 (nothing).",
232 help="Separator before output prompts. Default 0 (nothing).",
233 metavar='InteractiveShell.separate_out')
233 metavar='InteractiveShell.separate_out')
234 ),
234 ),
235 (('-separate_out2','-so2'), dict(
235 (('-separate_out2','-so2'), dict(
236 type=str, dest='InteractiveShell.separate_out2', default=NoConfigDefault,
236 type=str, dest='InteractiveShell.separate_out2', default=NoConfigDefault,
237 help="Separator after output prompts. Default 0 (nonight).",
237 help="Separator after output prompts. Default 0 (nonight).",
238 metavar='InteractiveShell.separate_out2')
238 metavar='InteractiveShell.separate_out2')
239 ),
239 ),
240 (('-nosep',), dict(
240 (('-nosep',), dict(
241 action='store_true', dest='Global.nosep', default=NoConfigDefault,
241 action='store_true', dest='Global.nosep', default=NoConfigDefault,
242 help="Eliminate all spacing between prompts.")
242 help="Eliminate all spacing between prompts.")
243 ),
243 ),
244 (('-term_title',), dict(
244 (('-term_title',), dict(
245 action='store_true', dest='InteractiveShell.term_title', default=NoConfigDefault,
245 action='store_true', dest='InteractiveShell.term_title', default=NoConfigDefault,
246 help="Enable auto setting the terminal title.")
246 help="Enable auto setting the terminal title.")
247 ),
247 ),
248 (('-noterm_title',), dict(
248 (('-noterm_title',), dict(
249 action='store_false', dest='InteractiveShell.term_title', default=NoConfigDefault,
249 action='store_false', dest='InteractiveShell.term_title', default=NoConfigDefault,
250 help="Disable auto setting the terminal title.")
250 help="Disable auto setting the terminal title.")
251 ),
251 ),
252 (('-xmode',), dict(
252 (('-xmode',), dict(
253 type=str, dest='InteractiveShell.xmode', default=NoConfigDefault,
253 type=str, dest='InteractiveShell.xmode', default=NoConfigDefault,
254 help="Exception mode ('Plain','Context','Verbose')",
254 help="Exception mode ('Plain','Context','Verbose')",
255 metavar='InteractiveShell.xmode')
255 metavar='InteractiveShell.xmode')
256 ),
256 ),
257 (('-ext',), dict(
257 (('-ext',), dict(
258 type=str, dest='Global.extra_extension', default=NoConfigDefault,
258 type=str, dest='Global.extra_extension', default=NoConfigDefault,
259 help="The dotted module name of an IPython extension to load.",
259 help="The dotted module name of an IPython extension to load.",
260 metavar='Global.extra_extension')
260 metavar='Global.extra_extension')
261 ),
261 ),
262 (('-c',), dict(
262 (('-c',), dict(
263 type=str, dest='Global.code_to_run', default=NoConfigDefault,
263 type=str, dest='Global.code_to_run', default=NoConfigDefault,
264 help="Execute the given command string.",
264 help="Execute the given command string.",
265 metavar='Global.code_to_run')
265 metavar='Global.code_to_run')
266 ),
266 ),
267 (('-i',), dict(
267 (('-i',), dict(
268 action='store_true', dest='Global.force_interact', default=NoConfigDefault,
268 action='store_true', dest='Global.force_interact', default=NoConfigDefault,
269 help="If running code from the command line, become interactive afterwards.")
269 help="If running code from the command line, become interactive afterwards.")
270 ),
270 ),
271 (('-wthread',), dict(
271 (('-wthread',), dict(
272 action='store_true', dest='Global.wthread', default=NoConfigDefault,
272 action='store_true', dest='Global.wthread', default=NoConfigDefault,
273 help="Enable wxPython event loop integration.")
273 help="Enable wxPython event loop integration.")
274 ),
274 ),
275 (('-q4thread','-qthread'), dict(
275 (('-q4thread','-qthread'), dict(
276 action='store_true', dest='Global.q4thread', default=NoConfigDefault,
276 action='store_true', dest='Global.q4thread', default=NoConfigDefault,
277 help="Enable Qt4 event loop integration. Qt3 is no longer supported.")
277 help="Enable Qt4 event loop integration. Qt3 is no longer supported.")
278 ),
278 ),
279 (('-gthread',), dict(
279 (('-gthread',), dict(
280 action='store_true', dest='Global.gthread', default=NoConfigDefault,
280 action='store_true', dest='Global.gthread', default=NoConfigDefault,
281 help="Enable GTK event loop integration.")
281 help="Enable GTK event loop integration.")
282 ),
282 ),
283 # # These are only here to get the proper deprecation warnings
283 # # These are only here to get the proper deprecation warnings
284 (('-pylab',), dict(
284 (('-pylab',), dict(
285 action='store_true', dest='Global.pylab', default=NoConfigDefault,
285 action='store_true', dest='Global.pylab', default=NoConfigDefault,
286 help="Disabled. Pylab has been disabled until matplotlib supports this version of IPython.")
286 help="Disabled. Pylab has been disabled until matplotlib supports this version of IPython.")
287 )
287 )
288 )
288 )
289
289
290
290
291 class IPythonAppCLConfigLoader(IPythonArgParseConfigLoader):
291 class IPythonAppCLConfigLoader(IPythonArgParseConfigLoader):
292
292
293 arguments = cl_args
293 arguments = cl_args
294
294
295
295
296 _default_config_file_name = 'ipython_config.py'
296 _default_config_file_name = 'ipython_config.py'
297
297
298 class IPythonApp(Application):
298 class IPythonApp(Application):
299 name = 'ipython'
299 name = 'ipython'
300 config_file_name = _default_config_file_name
300 config_file_name = _default_config_file_name
301
301
302 def create_default_config(self):
302 def create_default_config(self):
303 super(IPythonApp, self).create_default_config()
303 super(IPythonApp, self).create_default_config()
304 self.default_config.Global.display_banner = True
304 self.default_config.Global.display_banner = True
305
305
306 # If the -c flag is given or a file is given to run at the cmd line
306 # If the -c flag is given or a file is given to run at the cmd line
307 # like "ipython foo.py", normally we exit without starting the main
307 # like "ipython foo.py", normally we exit without starting the main
308 # loop. The force_interact config variable allows a user to override
308 # loop. The force_interact config variable allows a user to override
309 # this and interact. It is also set by the -i cmd line flag, just
309 # this and interact. It is also set by the -i cmd line flag, just
310 # like Python.
310 # like Python.
311 self.default_config.Global.force_interact = False
311 self.default_config.Global.force_interact = False
312
312
313 # By default always interact by starting the IPython mainloop.
313 # By default always interact by starting the IPython mainloop.
314 self.default_config.Global.interact = True
314 self.default_config.Global.interact = True
315
315
316 # Let the parent class set the default, but each time log_level
316 # Let the parent class set the default, but each time log_level
317 # changes from config, we need to update self.log_level as that is
317 # changes from config, we need to update self.log_level as that is
318 # what updates the actual log level in self.log.
318 # what updates the actual log level in self.log.
319 self.default_config.Global.log_level = self.log_level
319 self.default_config.Global.log_level = self.log_level
320
320
321 # No GUI integration by default
321 # No GUI integration by default
322 self.default_config.Global.wthread = False
322 self.default_config.Global.wthread = False
323 self.default_config.Global.q4thread = False
323 self.default_config.Global.q4thread = False
324 self.default_config.Global.gthread = False
324 self.default_config.Global.gthread = False
325
325
326 def create_command_line_config(self):
326 def create_command_line_config(self):
327 """Create and return a command line config loader."""
327 """Create and return a command line config loader."""
328 return IPythonAppCLConfigLoader(
328 return IPythonAppCLConfigLoader(
329 description=ipython_desc,
329 description=ipython_desc,
330 version=release.version)
330 version=release.version)
331
331
332 def post_load_command_line_config(self):
332 def post_load_command_line_config(self):
333 """Do actions after loading cl config."""
333 """Do actions after loading cl config."""
334 clc = self.command_line_config
334 clc = self.command_line_config
335
335
336 # Display the deprecation warnings about threaded shells
336 # Display the deprecation warnings about threaded shells
337 if hasattr(clc.Global, 'pylab'):
337 if hasattr(clc.Global, 'pylab'):
338 pylab_warning()
338 pylab_warning()
339 del clc.Global['pylab']
339 del clc.Global['pylab']
340
340
341 def load_file_config(self):
341 def load_file_config(self):
342 if hasattr(self.command_line_config.Global, 'quick'):
342 if hasattr(self.command_line_config.Global, 'quick'):
343 if self.command_line_config.Global.quick:
343 if self.command_line_config.Global.quick:
344 self.file_config = Config()
344 self.file_config = Config()
345 return
345 return
346 super(IPythonApp, self).load_file_config()
346 super(IPythonApp, self).load_file_config()
347
347
348 def post_load_file_config(self):
348 def post_load_file_config(self):
349 if hasattr(self.command_line_config.Global, 'extra_extension'):
349 if hasattr(self.command_line_config.Global, 'extra_extension'):
350 if not hasattr(self.file_config.Global, 'extensions'):
350 if not hasattr(self.file_config.Global, 'extensions'):
351 self.file_config.Global.extensions = []
351 self.file_config.Global.extensions = []
352 self.file_config.Global.extensions.append(
352 self.file_config.Global.extensions.append(
353 self.command_line_config.Global.extra_extension)
353 self.command_line_config.Global.extra_extension)
354 del self.command_line_config.Global.extra_extension
354 del self.command_line_config.Global.extra_extension
355
355
356 def pre_construct(self):
356 def pre_construct(self):
357 config = self.master_config
357 config = self.master_config
358
358
359 if hasattr(config.Global, 'classic'):
359 if hasattr(config.Global, 'classic'):
360 if config.Global.classic:
360 if config.Global.classic:
361 config.InteractiveShell.cache_size = 0
361 config.InteractiveShell.cache_size = 0
362 config.InteractiveShell.pprint = 0
362 config.InteractiveShell.pprint = 0
363 config.InteractiveShell.prompt_in1 = '>>> '
363 config.InteractiveShell.prompt_in1 = '>>> '
364 config.InteractiveShell.prompt_in2 = '... '
364 config.InteractiveShell.prompt_in2 = '... '
365 config.InteractiveShell.prompt_out = ''
365 config.InteractiveShell.prompt_out = ''
366 config.InteractiveShell.separate_in = \
366 config.InteractiveShell.separate_in = \
367 config.InteractiveShell.separate_out = \
367 config.InteractiveShell.separate_out = \
368 config.InteractiveShell.separate_out2 = ''
368 config.InteractiveShell.separate_out2 = ''
369 config.InteractiveShell.colors = 'NoColor'
369 config.InteractiveShell.colors = 'NoColor'
370 config.InteractiveShell.xmode = 'Plain'
370 config.InteractiveShell.xmode = 'Plain'
371
371
372 if hasattr(config.Global, 'nosep'):
372 if hasattr(config.Global, 'nosep'):
373 if config.Global.nosep:
373 if config.Global.nosep:
374 config.InteractiveShell.separate_in = \
374 config.InteractiveShell.separate_in = \
375 config.InteractiveShell.separate_out = \
375 config.InteractiveShell.separate_out = \
376 config.InteractiveShell.separate_out2 = ''
376 config.InteractiveShell.separate_out2 = ''
377
377
378 # if there is code of files to run from the cmd line, don't interact
378 # if there is code of files to run from the cmd line, don't interact
379 # unless the -i flag (Global.force_interact) is true.
379 # unless the -i flag (Global.force_interact) is true.
380 code_to_run = config.Global.get('code_to_run','')
380 code_to_run = config.Global.get('code_to_run','')
381 file_to_run = False
381 file_to_run = False
382 if len(self.extra_args)>=1:
382 if len(self.extra_args)>=1:
383 if self.extra_args[0]:
383 if self.extra_args[0]:
384 file_to_run = True
384 file_to_run = True
385 if file_to_run or code_to_run:
385 if file_to_run or code_to_run:
386 if not config.Global.force_interact:
386 if not config.Global.force_interact:
387 config.Global.interact = False
387 config.Global.interact = False
388
388
389 def construct(self):
389 def construct(self):
390 # I am a little hesitant to put these into InteractiveShell itself.
390 # I am a little hesitant to put these into InteractiveShell itself.
391 # But that might be the place for them
391 # But that might be the place for them
392 sys.path.insert(0, '')
392 sys.path.insert(0, '')
393
393
394 # Create an InteractiveShell instance
394 # Create an InteractiveShell instance
395 self.shell = InteractiveShell(
395 self.shell = InteractiveShell(
396 parent=None,
396 parent=None,
397 config=self.master_config
397 config=self.master_config
398 )
398 )
399
399
400 def post_construct(self):
400 def post_construct(self):
401 """Do actions after construct, but before starting the app."""
401 """Do actions after construct, but before starting the app."""
402 config = self.master_config
402 config = self.master_config
403
403
404 # shell.display_banner should always be False for the terminal
404 # shell.display_banner should always be False for the terminal
405 # based app, because we call shell.show_banner() by hand below
405 # based app, because we call shell.show_banner() by hand below
406 # so the banner shows *before* all extension loading stuff.
406 # so the banner shows *before* all extension loading stuff.
407 self.shell.display_banner = False
407 self.shell.display_banner = False
408
408
409 if config.Global.display_banner and \
409 if config.Global.display_banner and \
410 config.Global.interact:
410 config.Global.interact:
411 self.shell.show_banner()
411 self.shell.show_banner()
412
412
413 # Make sure there is a space below the banner.
413 # Make sure there is a space below the banner.
414 if self.log_level <= logging.INFO: print
414 if self.log_level <= logging.INFO: print
415
415
416 self._enable_gui()
416 self._enable_gui()
417 self._load_extensions()
417 self._load_extensions()
418 self._run_exec_lines()
418 self._run_exec_lines()
419 self._run_exec_files()
419 self._run_exec_files()
420 self._run_cmd_line_code()
420 self._run_cmd_line_code()
421
421
422 def _enable_gui(self):
422 def _enable_gui(self):
423 """Enable GUI event loop integration."""
423 """Enable GUI event loop integration."""
424 config = self.master_config
424 config = self.master_config
425 try:
425 try:
426 # Enable GUI integration
426 # Enable GUI integration
427 if config.Global.wthread:
427 if config.Global.wthread:
428 self.log.info("Enabling wx GUI event loop integration")
428 self.log.info("Enabling wx GUI event loop integration")
429 inputhook.enable_wx(app=True)
429 inputhook.enable_wx(app=True)
430 elif config.Global.q4thread:
430 elif config.Global.q4thread:
431 self.log.info("Enabling Qt4 GUI event loop integration")
431 self.log.info("Enabling Qt4 GUI event loop integration")
432 inputhook.enable_qt4(app=True)
432 inputhook.enable_qt4(app=True)
433 elif config.Global.gthread:
433 elif config.Global.gthread:
434 self.log.info("Enabling GTK GUI event loop integration")
434 self.log.info("Enabling GTK GUI event loop integration")
435 inputhook.enable_gtk(app=True)
435 inputhook.enable_gtk(app=True)
436 except:
436 except:
437 self.log.warn("Error in enabling GUI event loop integration:")
437 self.log.warn("Error in enabling GUI event loop integration:")
438 self.shell.showtraceback()
438 self.shell.showtraceback()
439
439
440 def _load_extensions(self):
440 def _load_extensions(self):
441 """Load all IPython extensions in Global.extensions.
441 """Load all IPython extensions in Global.extensions.
442
442
443 This uses the :meth:`InteractiveShell.load_extensions` to load all
443 This uses the :meth:`InteractiveShell.load_extensions` to load all
444 the extensions listed in ``self.master_config.Global.extensions``.
444 the extensions listed in ``self.master_config.Global.extensions``.
445 """
445 """
446 try:
446 try:
447 if hasattr(self.master_config.Global, 'extensions'):
447 if hasattr(self.master_config.Global, 'extensions'):
448 self.log.debug("Loading IPython extensions...")
448 self.log.debug("Loading IPython extensions...")
449 extensions = self.master_config.Global.extensions
449 extensions = self.master_config.Global.extensions
450 for ext in extensions:
450 for ext in extensions:
451 try:
451 try:
452 self.log.info("Loading IPython extension: %s" % ext)
452 self.log.info("Loading IPython extension: %s" % ext)
453 self.shell.load_extension(ext)
453 self.shell.load_extension(ext)
454 except:
454 except:
455 self.log.warn("Error in loading extension: %s" % ext)
455 self.log.warn("Error in loading extension: %s" % ext)
456 self.shell.showtraceback()
456 self.shell.showtraceback()
457 except:
457 except:
458 self.log.warn("Unknown error in loading extensions:")
458 self.log.warn("Unknown error in loading extensions:")
459 self.shell.showtraceback()
459 self.shell.showtraceback()
460
460
461 def _run_exec_lines(self):
461 def _run_exec_lines(self):
462 """Run lines of code in Global.exec_lines in the user's namespace."""
462 """Run lines of code in Global.exec_lines in the user's namespace."""
463 try:
463 try:
464 if hasattr(self.master_config.Global, 'exec_lines'):
464 if hasattr(self.master_config.Global, 'exec_lines'):
465 self.log.debug("Running code from Global.exec_lines...")
465 self.log.debug("Running code from Global.exec_lines...")
466 exec_lines = self.master_config.Global.exec_lines
466 exec_lines = self.master_config.Global.exec_lines
467 for line in exec_lines:
467 for line in exec_lines:
468 try:
468 try:
469 self.log.info("Running code in user namespace: %s" % line)
469 self.log.info("Running code in user namespace: %s" % line)
470 self.shell.runlines(line)
470 self.shell.runlines(line)
471 except:
471 except:
472 self.log.warn("Error in executing line in user namespace: %s" % line)
472 self.log.warn("Error in executing line in user namespace: %s" % line)
473 self.shell.showtraceback()
473 self.shell.showtraceback()
474 except:
474 except:
475 self.log.warn("Unknown error in handling Global.exec_lines:")
475 self.log.warn("Unknown error in handling Global.exec_lines:")
476 self.shell.showtraceback()
476 self.shell.showtraceback()
477
477
478 def _exec_file(self, fname):
478 def _exec_file(self, fname):
479 full_filename = filefind(fname, ['.', self.ipythondir])
479 full_filename = filefind(fname, ['.', self.ipythondir])
480 if os.path.isfile(full_filename):
480 if os.path.isfile(full_filename):
481 if full_filename.endswith('.py'):
481 if full_filename.endswith('.py'):
482 self.log.info("Running file in user namespace: %s" % full_filename)
482 self.log.info("Running file in user namespace: %s" % full_filename)
483 self.shell.safe_execfile(full_filename, self.shell.user_ns)
483 self.shell.safe_execfile(full_filename, self.shell.user_ns)
484 elif full_filename.endswith('.ipy'):
484 elif full_filename.endswith('.ipy'):
485 self.log.info("Running file in user namespace: %s" % full_filename)
485 self.log.info("Running file in user namespace: %s" % full_filename)
486 self.shell.safe_execfile_ipy(full_filename)
486 self.shell.safe_execfile_ipy(full_filename)
487 else:
487 else:
488 self.log.warn("File does not have a .py or .ipy extension: <%s>" % full_filename)
488 self.log.warn("File does not have a .py or .ipy extension: <%s>" % full_filename)
489
489
490 def _run_exec_files(self):
490 def _run_exec_files(self):
491 try:
491 try:
492 if hasattr(self.master_config.Global, 'exec_files'):
492 if hasattr(self.master_config.Global, 'exec_files'):
493 self.log.debug("Running files in Global.exec_files...")
493 self.log.debug("Running files in Global.exec_files...")
494 exec_files = self.master_config.Global.exec_files
494 exec_files = self.master_config.Global.exec_files
495 for fname in exec_files:
495 for fname in exec_files:
496 self._exec_file(fname)
496 self._exec_file(fname)
497 except:
497 except:
498 self.log.warn("Unknown error in handling Global.exec_files:")
498 self.log.warn("Unknown error in handling Global.exec_files:")
499 self.shell.showtraceback()
499 self.shell.showtraceback()
500
500
501 def _run_cmd_line_code(self):
501 def _run_cmd_line_code(self):
502 if hasattr(self.master_config.Global, 'code_to_run'):
502 if hasattr(self.master_config.Global, 'code_to_run'):
503 line = self.master_config.Global.code_to_run
503 line = self.master_config.Global.code_to_run
504 try:
504 try:
505 self.log.info("Running code given at command line (-c): %s" % line)
505 self.log.info("Running code given at command line (-c): %s" % line)
506 self.shell.runlines(line)
506 self.shell.runlines(line)
507 except:
507 except:
508 self.log.warn("Error in executing line in user namespace: %s" % line)
508 self.log.warn("Error in executing line in user namespace: %s" % line)
509 self.shell.showtraceback()
509 self.shell.showtraceback()
510 return
510 return
511 # Like Python itself, ignore the second if the first of these is present
511 # Like Python itself, ignore the second if the first of these is present
512 try:
512 try:
513 fname = self.extra_args[0]
513 fname = self.extra_args[0]
514 except:
514 except:
515 pass
515 pass
516 else:
516 else:
517 try:
517 try:
518 self._exec_file(fname)
518 self._exec_file(fname)
519 except:
519 except:
520 self.log.warn("Error in executing file in user namespace: %s" % fname)
520 self.log.warn("Error in executing file in user namespace: %s" % fname)
521 self.shell.showtraceback()
521 self.shell.showtraceback()
522
522
523 def start_app(self):
523 def start_app(self):
524 if self.master_config.Global.interact:
524 if self.master_config.Global.interact:
525 self.log.debug("Starting IPython's mainloop...")
525 self.log.debug("Starting IPython's mainloop...")
526 self.shell.mainloop()
526 self.shell.mainloop()
527
527
528
528
529 def load_default_config(ipythondir=None):
529 def load_default_config(ipythondir=None):
530 """Load the default config file from the default ipythondir.
530 """Load the default config file from the default ipythondir.
531
531
532 This is useful for embedded shells.
532 This is useful for embedded shells.
533 """
533 """
534 if ipythondir is None:
534 if ipythondir is None:
535 ipythondir = get_ipython_dir()
535 ipythondir = get_ipython_dir()
536 cl = PyFileConfigLoader(_default_config_file_name, ipythondir)
536 cl = PyFileConfigLoader(_default_config_file_name, ipythondir)
537 config = cl.load_config()
537 config = cl.load_config()
538 return config
538 return config
539
539
540
540
541 if __name__ == '__main__':
541 def launch_new_instance():
542 """Create a run a full blown IPython instance"""
542 app = IPythonApp()
543 app = IPythonApp()
543 app.start()
544 app.start()
545
@@ -1,28 +1,6 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """IPython -- An enhanced Interactive Python
4
3
5 This is just the startup wrapper script, kept deliberately to a minimum.
4 from IPython.core.ipapp import launch_new_instance
6
7 The shell's mainloop() takes an optional argument, sys_exit (default=0). If
8 set to 1, it calls sys.exit() at exit time. You can use the following code in
9 your PYTHONSTARTUP file:
10
11 import IPython
12 IPython.Shell.IPShell().mainloop(sys_exit=1)
13
14 [or simply IPython.Shell.IPShell().mainloop(1) ]
15
16 and IPython will be your working environment when you start python. The final
17 sys.exit() call will make python exit transparently when IPython finishes, so
18 you don't have an extra prompt to get out of.
19
20 This is probably useful to developers who manage multiple Python versions and
21 don't want to have correspondingly multiple IPython versions. Note that in
22 this mode, there is no way to pass IPython any command-line options, as those
23 are trapped first by Python itself.
24 """
25
26 from IPython.core.ipapi import launch_new_instance
27
5
28 launch_new_instance()
6 launch_new_instance()
@@ -1,37 +1,36 b''
1 include ipython.py
1 include ipython.py
2 include setupbase.py
2 include setupbase.py
3 include setupegg.py
3 include setupegg.py
4
4
5 graft setupext
5 graft setupext
6
6
7 graft scripts
7 graft scripts
8 graft IPython/kernel
8 graft IPython/kernel
9 graft IPython/config
9 graft IPython/config
10 graft IPython/core
10 graft IPython/core
11 graft IPython/deathrow
11 graft IPython/deathrow
12 graft IPython/external
12 graft IPython/external
13 graft IPython/frontend
13 graft IPython/frontend
14 graft IPython/gui
14 graft IPython/gui
15 graft IPython/lib
15 graft IPython/lib
16 graft IPython/quarantine
16 graft IPython/quarantine
17 graft IPython/scripts
17 graft IPython/scripts
18 graft IPython/testing
18 graft IPython/testing
19 graft IPython/utils
19 graft IPython/utils
20
20
21 recursive-include IPython/extensions igrid_help*
22
21
23 graft docs
22 graft docs
24 exclude docs/\#*
23 exclude docs/\#*
25 exclude docs/man/*.1
24 exclude docs/man/*.1
26
25
27 # docs subdirs we want to skip
26 # docs subdirs we want to skip
28 prune docs/attic
27 prune docs/attic
29 prune docs/build
28 prune docs/build
30
29
31 global-exclude *~
30 global-exclude *~
32 global-exclude *.flc
31 global-exclude *.flc
33 global-exclude *.pyc
32 global-exclude *.pyc
34 global-exclude .dircopy.log
33 global-exclude .dircopy.log
35 global-exclude .svn
34 global-exclude .svn
36 global-exclude .bzr
35 global-exclude .bzr
37 global-exclude .hgignore
36 global-exclude .hgignore
@@ -1,214 +1,210 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """Setup script for IPython.
3 """Setup script for IPython.
4
4
5 Under Posix environments it works like a typical setup.py script.
5 Under Posix environments it works like a typical setup.py script.
6 Under Windows, the command sdist is not supported, since IPython
6 Under Windows, the command sdist is not supported, since IPython
7 requires utilities which are not available under Windows."""
7 requires utilities which are not available under Windows."""
8
8
9 #-------------------------------------------------------------------------------
9 #-------------------------------------------------------------------------------
10 # Copyright (C) 2008 The IPython Development Team
10 # Copyright (C) 2008 The IPython Development Team
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #-------------------------------------------------------------------------------
14 #-------------------------------------------------------------------------------
15
15
16 #-------------------------------------------------------------------------------
16 #-------------------------------------------------------------------------------
17 # Imports
17 # Imports
18 #-------------------------------------------------------------------------------
18 #-------------------------------------------------------------------------------
19
19
20 # Stdlib imports
20 # Stdlib imports
21 import os
21 import os
22 import sys
22 import sys
23
23
24 from glob import glob
24 from glob import glob
25
25
26 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
26 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
27 # update it when the contents of directories change.
27 # update it when the contents of directories change.
28 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
28 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
29
29
30 from distutils.core import setup
30 from distutils.core import setup
31
31
32 from IPython.utils.genutils import target_update
32 from IPython.utils.genutils import target_update
33
33
34 from setupbase import (
34 from setupbase import (
35 setup_args,
35 setup_args,
36 find_packages,
36 find_packages,
37 find_package_data,
37 find_package_data,
38 find_scripts,
38 find_scripts,
39 find_data_files,
39 find_data_files,
40 check_for_dependencies
40 check_for_dependencies
41 )
41 )
42
42
43 isfile = os.path.isfile
43 isfile = os.path.isfile
44 pjoin = os.path.join
44 pjoin = os.path.join
45
45
46 #-------------------------------------------------------------------------------
46 #-------------------------------------------------------------------------------
47 # Handle OS specific things
47 # Handle OS specific things
48 #-------------------------------------------------------------------------------
48 #-------------------------------------------------------------------------------
49
49
50 if os.name == 'posix':
50 if os.name == 'posix':
51 os_name = 'posix'
51 os_name = 'posix'
52 elif os.name in ['nt','dos']:
52 elif os.name in ['nt','dos']:
53 os_name = 'windows'
53 os_name = 'windows'
54 else:
54 else:
55 print 'Unsupported operating system:',os.name
55 print 'Unsupported operating system:',os.name
56 sys.exit(1)
56 sys.exit(1)
57
57
58 # Under Windows, 'sdist' has not been supported. Now that the docs build with
58 # Under Windows, 'sdist' has not been supported. Now that the docs build with
59 # Sphinx it might work, but let's not turn it on until someone confirms that it
59 # Sphinx it might work, but let's not turn it on until someone confirms that it
60 # actually works.
60 # actually works.
61 if os_name == 'windows' and 'sdist' in sys.argv:
61 if os_name == 'windows' and 'sdist' in sys.argv:
62 print 'The sdist command is not available under Windows. Exiting.'
62 print 'The sdist command is not available under Windows. Exiting.'
63 sys.exit(1)
63 sys.exit(1)
64
64
65 #-------------------------------------------------------------------------------
65 #-------------------------------------------------------------------------------
66 # Things related to the IPython documentation
66 # Things related to the IPython documentation
67 #-------------------------------------------------------------------------------
67 #-------------------------------------------------------------------------------
68
68
69 # update the manuals when building a source dist
69 # update the manuals when building a source dist
70 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
70 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
71 import textwrap
71 import textwrap
72
72
73 # List of things to be updated. Each entry is a triplet of args for
73 # List of things to be updated. Each entry is a triplet of args for
74 # target_update()
74 # target_update()
75 to_update = [
75 to_update = [
76 # FIXME - Disabled for now: we need to redo an automatic way
76 # FIXME - Disabled for now: we need to redo an automatic way
77 # of generating the magic info inside the rst.
77 # of generating the magic info inside the rst.
78 #('docs/magic.tex',
78 #('docs/magic.tex',
79 #['IPython/Magic.py'],
79 #['IPython/Magic.py'],
80 #"cd doc && ./update_magic.sh" ),
80 #"cd doc && ./update_magic.sh" ),
81
81
82 ('docs/man/ipcluster.1.gz',
82 ('docs/man/ipcluster.1.gz',
83 ['docs/man/ipcluster.1'],
83 ['docs/man/ipcluster.1'],
84 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
84 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
85
85
86 ('docs/man/ipcontroller.1.gz',
86 ('docs/man/ipcontroller.1.gz',
87 ['docs/man/ipcontroller.1'],
87 ['docs/man/ipcontroller.1'],
88 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
88 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
89
89
90 ('docs/man/ipengine.1.gz',
90 ('docs/man/ipengine.1.gz',
91 ['docs/man/ipengine.1'],
91 ['docs/man/ipengine.1'],
92 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
92 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
93
93
94 ('docs/man/ipython.1.gz',
94 ('docs/man/ipython.1.gz',
95 ['docs/man/ipython.1'],
95 ['docs/man/ipython.1'],
96 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
96 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
97
97
98 ('docs/man/ipython-wx.1.gz',
98 ('docs/man/ipython-wx.1.gz',
99 ['docs/man/ipython-wx.1'],
99 ['docs/man/ipython-wx.1'],
100 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'),
100 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'),
101
101
102 ('docs/man/ipythonx.1.gz',
102 ('docs/man/ipythonx.1.gz',
103 ['docs/man/ipythonx.1'],
103 ['docs/man/ipythonx.1'],
104 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'),
104 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'),
105
105
106 ('docs/man/irunner.1.gz',
106 ('docs/man/irunner.1.gz',
107 ['docs/man/irunner.1'],
107 ['docs/man/irunner.1'],
108 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
108 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
109
109
110 ('docs/man/pycolor.1.gz',
110 ('docs/man/pycolor.1.gz',
111 ['docs/man/pycolor.1'],
111 ['docs/man/pycolor.1'],
112 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
112 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
113 ]
113 ]
114
114
115 # Only build the docs if sphinx is present
115 # Only build the docs if sphinx is present
116 try:
116 try:
117 import sphinx
117 import sphinx
118 except ImportError:
118 except ImportError:
119 pass
119 pass
120 else:
120 else:
121 # The Makefile calls the do_sphinx scripts to build html and pdf, so
121 # The Makefile calls the do_sphinx scripts to build html and pdf, so
122 # just one target is enough to cover all manual generation
122 # just one target is enough to cover all manual generation
123
123
124 # First, compute all the dependencies that can force us to rebuild the
124 # First, compute all the dependencies that can force us to rebuild the
125 # docs. Start with the main release file that contains metadata
125 # docs. Start with the main release file that contains metadata
126 docdeps = ['IPython/core/release.py']
126 docdeps = ['IPython/core/release.py']
127 # Inculde all the reST sources
127 # Inculde all the reST sources
128 pjoin = os.path.join
128 pjoin = os.path.join
129 for dirpath,dirnames,filenames in os.walk('docs/source'):
129 for dirpath,dirnames,filenames in os.walk('docs/source'):
130 if dirpath in ['_static','_templates']:
130 if dirpath in ['_static','_templates']:
131 continue
131 continue
132 docdeps += [ pjoin(dirpath,f) for f in filenames
132 docdeps += [ pjoin(dirpath,f) for f in filenames
133 if f.endswith('.txt') ]
133 if f.endswith('.txt') ]
134 # and the examples
134 # and the examples
135 for dirpath,dirnames,filenames in os.walk('docs/example'):
135 for dirpath,dirnames,filenames in os.walk('docs/example'):
136 docdeps += [ pjoin(dirpath,f) for f in filenames
136 docdeps += [ pjoin(dirpath,f) for f in filenames
137 if not f.endswith('~') ]
137 if not f.endswith('~') ]
138 # then, make them all dependencies for the main PDF (the html will get
138 # then, make them all dependencies for the main PDF (the html will get
139 # auto-generated as well).
139 # auto-generated as well).
140 to_update.append(
140 to_update.append(
141 ('docs/dist/ipython.pdf',
141 ('docs/dist/ipython.pdf',
142 docdeps,
142 docdeps,
143 "cd docs && make dist")
143 "cd docs && make dist")
144 )
144 )
145
145
146 [ target_update(*t) for t in to_update ]
146 [ target_update(*t) for t in to_update ]
147
147
148
148
149 #---------------------------------------------------------------------------
149 #---------------------------------------------------------------------------
150 # Find all the packages, package data, scripts and data_files
150 # Find all the packages, package data, scripts and data_files
151 #---------------------------------------------------------------------------
151 #---------------------------------------------------------------------------
152
152
153 packages = find_packages()
153 packages = find_packages()
154 package_data = find_package_data()
154 package_data = find_package_data()
155 scripts = find_scripts()
155 scripts = find_scripts()
156 data_files = find_data_files()
156 data_files = find_data_files()
157
157
158 #---------------------------------------------------------------------------
158 #---------------------------------------------------------------------------
159 # Handle dependencies and setuptools specific things
159 # Handle dependencies and setuptools specific things
160 #---------------------------------------------------------------------------
160 #---------------------------------------------------------------------------
161
161
162 # This dict is used for passing extra arguments that are setuptools
162 # This dict is used for passing extra arguments that are setuptools
163 # specific to setup
163 # specific to setup
164 setuptools_extra_args = {}
164 setuptools_extra_args = {}
165
165
166 if 'setuptools' in sys.modules:
166 if 'setuptools' in sys.modules:
167 setuptools_extra_args['zip_safe'] = False
167 setuptools_extra_args['zip_safe'] = False
168 setuptools_extra_args['entry_points'] = {
168 setuptools_extra_args['entry_points'] = {
169 'console_scripts': [
169 'console_scripts': [
170 'ipython = IPython.core.ipapi:launch_new_instance',
170 'ipython = IPython.core.ipapp:launch_new_instance',
171 'pycolor = IPython.utils.PyColorize:main',
171 'pycolor = IPython.utils.PyColorize:main',
172 'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
172 'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
173 'ipengine = IPython.kernel.scripts.ipengine:main',
173 'ipengine = IPython.kernel.scripts.ipengine:main',
174 'ipcluster = IPython.kernel.scripts.ipcluster:main',
174 'ipcluster = IPython.kernel.scripts.ipcluster:main',
175 'ipythonx = IPython.frontend.wx.ipythonx:main',
175 'ipythonx = IPython.frontend.wx.ipythonx:main',
176 'iptest = IPython.testing.iptest:main',
176 'iptest = IPython.testing.iptest:main',
177 'irunner = IPython.lib.irunner:main'
177 'irunner = IPython.lib.irunner:main'
178 ]
178 ]
179 }
179 }
180 setup_args['extras_require'] = dict(
180 setup_args['extras_require'] = dict(
181 kernel = [
181 kernel = [
182 'zope.interface>=3.4.1',
182 'zope.interface>=3.4.1',
183 'Twisted>=8.0.1',
183 'Twisted>=8.0.1',
184 'foolscap>=0.2.6'
184 'foolscap>=0.2.6'
185 ],
185 ],
186 doc='Sphinx>=0.3',
186 doc='Sphinx>=0.3',
187 test='nose>=0.10.1',
187 test='nose>=0.10.1',
188 security='pyOpenSSL>=0.6'
188 security='pyOpenSSL>=0.6'
189 )
189 )
190 # Allow setuptools to handle the scripts
190 # Allow setuptools to handle the scripts
191 scripts = []
191 scripts = []
192 else:
192 else:
193 # package_data of setuptools was introduced to distutils in 2.4
194 cfgfiles = filter(isfile, glob(pjoin('IPython','config','userconfig')))
195 if sys.version_info < (2,4):
196 data_files.append(('lib', pjoin('IPython','config','userconfig'), cfgfiles))
197 # If we are running without setuptools, call this function which will
193 # If we are running without setuptools, call this function which will
198 # check for dependencies an inform the user what is needed. This is
194 # check for dependencies an inform the user what is needed. This is
199 # just to make life easy for users.
195 # just to make life easy for users.
200 check_for_dependencies()
196 check_for_dependencies()
201
197
202
198
203 #---------------------------------------------------------------------------
199 #---------------------------------------------------------------------------
204 # Do the actual setup now
200 # Do the actual setup now
205 #---------------------------------------------------------------------------
201 #---------------------------------------------------------------------------
206
202
207 setup_args['packages'] = packages
203 setup_args['packages'] = packages
208 setup_args['package_data'] = package_data
204 setup_args['package_data'] = package_data
209 setup_args['scripts'] = scripts
205 setup_args['scripts'] = scripts
210 setup_args['data_files'] = data_files
206 setup_args['data_files'] = data_files
211 setup_args.update(setuptools_extra_args)
207 setup_args.update(setuptools_extra_args)
212
208
213 if __name__ == '__main__':
209 if __name__ == '__main__':
214 setup(**setup_args)
210 setup(**setup_args)
@@ -1,320 +1,320 b''
1 # encoding: utf-8
1 # encoding: utf-8
2
2
3 """
3 """
4 This module defines the things that are used in setup.py for building IPython
4 This module defines the things that are used in setup.py for building IPython
5
5
6 This includes:
6 This includes:
7
7
8 * The basic arguments to setup
8 * The basic arguments to setup
9 * Functions for finding things like packages, package data, etc.
9 * Functions for finding things like packages, package data, etc.
10 * A function for checking dependencies.
10 * A function for checking dependencies.
11 """
11 """
12
12
13 __docformat__ = "restructuredtext en"
13 __docformat__ = "restructuredtext en"
14
14
15 #-------------------------------------------------------------------------------
15 #-------------------------------------------------------------------------------
16 # Copyright (C) 2008 The IPython Development Team
16 # Copyright (C) 2008 The IPython Development Team
17 #
17 #
18 # Distributed under the terms of the BSD License. The full license is in
18 # Distributed under the terms of the BSD License. The full license is in
19 # the file COPYING, distributed as part of this software.
19 # the file COPYING, distributed as part of this software.
20 #-------------------------------------------------------------------------------
20 #-------------------------------------------------------------------------------
21
21
22 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
23 # Imports
23 # Imports
24 #-------------------------------------------------------------------------------
24 #-------------------------------------------------------------------------------
25
25
26 import os, sys
26 import os, sys
27
27
28 from glob import glob
28 from glob import glob
29
29
30 from setupext import install_data_ext
30 from setupext import install_data_ext
31
31
32 #-------------------------------------------------------------------------------
32 #-------------------------------------------------------------------------------
33 # Useful globals and utility functions
33 # Useful globals and utility functions
34 #-------------------------------------------------------------------------------
34 #-------------------------------------------------------------------------------
35
35
36 # A few handy globals
36 # A few handy globals
37 isfile = os.path.isfile
37 isfile = os.path.isfile
38 pjoin = os.path.join
38 pjoin = os.path.join
39
39
40 def oscmd(s):
40 def oscmd(s):
41 print ">", s
41 print ">", s
42 os.system(s)
42 os.system(s)
43
43
44 # A little utility we'll need below, since glob() does NOT allow you to do
44 # A little utility we'll need below, since glob() does NOT allow you to do
45 # exclusion on multiple endings!
45 # exclusion on multiple endings!
46 def file_doesnt_endwith(test,endings):
46 def file_doesnt_endwith(test,endings):
47 """Return true if test is a file and its name does NOT end with any
47 """Return true if test is a file and its name does NOT end with any
48 of the strings listed in endings."""
48 of the strings listed in endings."""
49 if not isfile(test):
49 if not isfile(test):
50 return False
50 return False
51 for e in endings:
51 for e in endings:
52 if test.endswith(e):
52 if test.endswith(e):
53 return False
53 return False
54 return True
54 return True
55
55
56 #---------------------------------------------------------------------------
56 #---------------------------------------------------------------------------
57 # Basic project information
57 # Basic project information
58 #---------------------------------------------------------------------------
58 #---------------------------------------------------------------------------
59
59
60 # release.py contains version, authors, license, url, keywords, etc.
60 # release.py contains version, authors, license, url, keywords, etc.
61 execfile(pjoin('IPython','core','release.py'))
61 execfile(pjoin('IPython','core','release.py'))
62
62
63 # Create a dict with the basic information
63 # Create a dict with the basic information
64 # This dict is eventually passed to setup after additional keys are added.
64 # This dict is eventually passed to setup after additional keys are added.
65 setup_args = dict(
65 setup_args = dict(
66 name = name,
66 name = name,
67 version = version,
67 version = version,
68 description = description,
68 description = description,
69 long_description = long_description,
69 long_description = long_description,
70 author = author,
70 author = author,
71 author_email = author_email,
71 author_email = author_email,
72 url = url,
72 url = url,
73 download_url = download_url,
73 download_url = download_url,
74 license = license,
74 license = license,
75 platforms = platforms,
75 platforms = platforms,
76 keywords = keywords,
76 keywords = keywords,
77 cmdclass = {'install_data': install_data_ext},
77 cmdclass = {'install_data': install_data_ext},
78 )
78 )
79
79
80
80
81 #---------------------------------------------------------------------------
81 #---------------------------------------------------------------------------
82 # Find packages
82 # Find packages
83 #---------------------------------------------------------------------------
83 #---------------------------------------------------------------------------
84
84
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
86 others=None):
86 others=None):
87 """
87 """
88 Add a package to the list of packages, including certain subpackages.
88 Add a package to the list of packages, including certain subpackages.
89 """
89 """
90 packages.append('.'.join(['IPython',pname]))
90 packages.append('.'.join(['IPython',pname]))
91 if config:
91 if config:
92 packages.append('.'.join(['IPython',pname,'config']))
92 packages.append('.'.join(['IPython',pname,'config']))
93 if tests:
93 if tests:
94 packages.append('.'.join(['IPython',pname,'tests']))
94 packages.append('.'.join(['IPython',pname,'tests']))
95 if scripts:
95 if scripts:
96 packages.append('.'.join(['IPython',pname,'scripts']))
96 packages.append('.'.join(['IPython',pname,'scripts']))
97 if others is not None:
97 if others is not None:
98 for o in others:
98 for o in others:
99 packages.append('.'.join(['IPython',pname,o]))
99 packages.append('.'.join(['IPython',pname,o]))
100
100
101 def find_packages():
101 def find_packages():
102 """
102 """
103 Find all of IPython's packages.
103 Find all of IPython's packages.
104 """
104 """
105 packages = ['IPython']
105 packages = ['IPython']
106 add_package(packages, 'config', tests=True)
106 add_package(packages, 'config', tests=True, others=['default','profile'])
107 add_package(packages, 'core', tests=True)
107 add_package(packages, 'core', tests=True)
108 add_package(packages, 'deathrow', tests=True)
108 add_package(packages, 'deathrow', tests=True)
109 add_package(packages , 'extensions')
109 add_package(packages , 'extensions')
110 add_package(packages, 'external')
110 add_package(packages, 'external')
111 add_package(packages, 'frontend', tests=True)
111 add_package(packages, 'frontend', tests=True)
112 # Don't include the cocoa frontend for now as it is not stable
112 # Don't include the cocoa frontend for now as it is not stable
113 if sys.platform == 'darwin' and False:
113 if sys.platform == 'darwin' and False:
114 add_package(packages, 'frontend.cocoa', tests=True, others=['plugin'])
114 add_package(packages, 'frontend.cocoa', tests=True, others=['plugin'])
115 add_package(packages, 'frontend.cocoa.examples')
115 add_package(packages, 'frontend.cocoa.examples')
116 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox')
116 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox')
117 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox.English.lproj')
117 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox.English.lproj')
118 add_package(packages, 'frontend.process')
118 add_package(packages, 'frontend.process')
119 add_package(packages, 'frontend.wx')
119 add_package(packages, 'frontend.wx')
120 add_package(packages, 'gui')
120 add_package(packages, 'gui')
121 add_package(packages, 'gui.wx')
121 add_package(packages, 'gui.wx')
122 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
122 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
123 add_package(packages, 'kernel.core', config=True, tests=True)
123 add_package(packages, 'kernel.core', config=True, tests=True)
124 add_package(packages, 'lib', tests=True)
124 add_package(packages, 'lib', tests=True)
125 add_package(packages, 'quarantine', tests=True)
125 add_package(packages, 'quarantine', tests=True)
126 add_package(packages, 'scripts')
126 add_package(packages, 'scripts')
127 add_package(packages, 'testing', tests=True)
127 add_package(packages, 'testing', tests=True)
128 add_package(packages, 'testing.plugin', tests=False)
128 add_package(packages, 'testing.plugin', tests=False)
129 add_package(packages, 'utils', tests=True)
129 add_package(packages, 'utils', tests=True)
130 return packages
130 return packages
131
131
132 #---------------------------------------------------------------------------
132 #---------------------------------------------------------------------------
133 # Find package data
133 # Find package data
134 #---------------------------------------------------------------------------
134 #---------------------------------------------------------------------------
135
135
136 def find_package_data():
136 def find_package_data():
137 """
137 """
138 Find IPython's package_data.
138 Find IPython's package_data.
139 """
139 """
140 # This is not enough for these things to appear in an sdist.
140 # This is not enough for these things to appear in an sdist.
141 # We need to muck with the MANIFEST to get this to work
141 # We need to muck with the MANIFEST to get this to work
142 package_data = {
142 package_data = {
143 'IPython.config.userconfig' : ['*'],
143 'IPython.config.userconfig' : ['*'],
144 'IPython.testing' : ['*.txt']
144 'IPython.testing' : ['*.txt']
145 }
145 }
146 return package_data
146 return package_data
147
147
148
148
149 #---------------------------------------------------------------------------
149 #---------------------------------------------------------------------------
150 # Find data files
150 # Find data files
151 #---------------------------------------------------------------------------
151 #---------------------------------------------------------------------------
152
152
153 def make_dir_struct(tag,base,out_base):
153 def make_dir_struct(tag,base,out_base):
154 """Make the directory structure of all files below a starting dir.
154 """Make the directory structure of all files below a starting dir.
155
155
156 This is just a convenience routine to help build a nested directory
156 This is just a convenience routine to help build a nested directory
157 hierarchy because distutils is too stupid to do this by itself.
157 hierarchy because distutils is too stupid to do this by itself.
158
158
159 XXX - this needs a proper docstring!
159 XXX - this needs a proper docstring!
160 """
160 """
161
161
162 # we'll use these a lot below
162 # we'll use these a lot below
163 lbase = len(base)
163 lbase = len(base)
164 pathsep = os.path.sep
164 pathsep = os.path.sep
165 lpathsep = len(pathsep)
165 lpathsep = len(pathsep)
166
166
167 out = []
167 out = []
168 for (dirpath,dirnames,filenames) in os.walk(base):
168 for (dirpath,dirnames,filenames) in os.walk(base):
169 # we need to strip out the dirpath from the base to map it to the
169 # we need to strip out the dirpath from the base to map it to the
170 # output (installation) path. This requires possibly stripping the
170 # output (installation) path. This requires possibly stripping the
171 # path separator, because otherwise pjoin will not work correctly
171 # path separator, because otherwise pjoin will not work correctly
172 # (pjoin('foo/','/bar') returns '/bar').
172 # (pjoin('foo/','/bar') returns '/bar').
173
173
174 dp_eff = dirpath[lbase:]
174 dp_eff = dirpath[lbase:]
175 if dp_eff.startswith(pathsep):
175 if dp_eff.startswith(pathsep):
176 dp_eff = dp_eff[lpathsep:]
176 dp_eff = dp_eff[lpathsep:]
177 # The output path must be anchored at the out_base marker
177 # The output path must be anchored at the out_base marker
178 out_path = pjoin(out_base,dp_eff)
178 out_path = pjoin(out_base,dp_eff)
179 # Now we can generate the final filenames. Since os.walk only produces
179 # Now we can generate the final filenames. Since os.walk only produces
180 # filenames, we must join back with the dirpath to get full valid file
180 # filenames, we must join back with the dirpath to get full valid file
181 # paths:
181 # paths:
182 pfiles = [pjoin(dirpath,f) for f in filenames]
182 pfiles = [pjoin(dirpath,f) for f in filenames]
183 # Finally, generate the entry we need, which is a triple of (tag,output
183 # Finally, generate the entry we need, which is a triple of (tag,output
184 # path, files) for use as a data_files parameter in install_data.
184 # path, files) for use as a data_files parameter in install_data.
185 out.append((tag,out_path,pfiles))
185 out.append((tag,out_path,pfiles))
186
186
187 return out
187 return out
188
188
189
189
190 def find_data_files():
190 def find_data_files():
191 """
191 """
192 Find IPython's data_files.
192 Find IPython's data_files.
193
193
194 Most of these are docs.
194 Most of these are docs.
195 """
195 """
196
196
197 docdirbase = pjoin('share', 'doc', 'ipython')
197 docdirbase = pjoin('share', 'doc', 'ipython')
198 manpagebase = pjoin('share', 'man', 'man1')
198 manpagebase = pjoin('share', 'man', 'man1')
199
199
200 # Simple file lists can be made by hand
200 # Simple file lists can be made by hand
201 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
201 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
202 igridhelpfiles = filter(isfile, glob(pjoin('IPython','extensions','igrid_help.*')))
202 igridhelpfiles = filter(isfile, glob(pjoin('IPython','extensions','igrid_help.*')))
203
203
204 # For nested structures, use the utility above
204 # For nested structures, use the utility above
205 example_files = make_dir_struct(
205 example_files = make_dir_struct(
206 'data',
206 'data',
207 pjoin('docs','examples'),
207 pjoin('docs','examples'),
208 pjoin(docdirbase,'examples')
208 pjoin(docdirbase,'examples')
209 )
209 )
210 manual_files = make_dir_struct(
210 manual_files = make_dir_struct(
211 'data',
211 'data',
212 pjoin('docs','dist'),
212 pjoin('docs','dist'),
213 pjoin(docdirbase,'manual')
213 pjoin(docdirbase,'manual')
214 )
214 )
215
215
216 # And assemble the entire output list
216 # And assemble the entire output list
217 data_files = [ ('data',manpagebase, manpages),
217 data_files = [ ('data',manpagebase, manpages),
218 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
218 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
219 ] + manual_files + example_files
219 ] + manual_files + example_files
220
220
221 ## import pprint # dbg
221 ## import pprint # dbg
222 ## print '*'*80
222 ## print '*'*80
223 ## print 'data files'
223 ## print 'data files'
224 ## pprint.pprint(data_files)
224 ## pprint.pprint(data_files)
225 ## print '*'*80
225 ## print '*'*80
226
226
227 return data_files
227 return data_files
228
228
229
229
230 def make_man_update_target(manpage):
230 def make_man_update_target(manpage):
231 """Return a target_update-compliant tuple for the given manpage.
231 """Return a target_update-compliant tuple for the given manpage.
232
232
233 Parameters
233 Parameters
234 ----------
234 ----------
235 manpage : string
235 manpage : string
236 Name of the manpage, must include the section number (trailing number).
236 Name of the manpage, must include the section number (trailing number).
237
237
238 Example
238 Example
239 -------
239 -------
240
240
241 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
241 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
242 ('docs/man/ipython.1.gz',
242 ('docs/man/ipython.1.gz',
243 ['docs/man/ipython.1'],
243 ['docs/man/ipython.1'],
244 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
244 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
245 """
245 """
246 man_dir = pjoin('docs', 'man')
246 man_dir = pjoin('docs', 'man')
247 manpage_gz = manpage + '.gz'
247 manpage_gz = manpage + '.gz'
248 manpath = pjoin(man_dir, manpage)
248 manpath = pjoin(man_dir, manpage)
249 manpath_gz = pjoin(man_dir, manpage_gz)
249 manpath_gz = pjoin(man_dir, manpage_gz)
250 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
250 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
251 locals() )
251 locals() )
252 return (manpath_gz, [manpath], gz_cmd)
252 return (manpath_gz, [manpath], gz_cmd)
253
253
254 #---------------------------------------------------------------------------
254 #---------------------------------------------------------------------------
255 # Find scripts
255 # Find scripts
256 #---------------------------------------------------------------------------
256 #---------------------------------------------------------------------------
257
257
258 def find_scripts():
258 def find_scripts():
259 """
259 """
260 Find IPython's scripts.
260 Find IPython's scripts.
261 """
261 """
262 kernel_scripts = pjoin('IPython','kernel','scripts')
262 kernel_scripts = pjoin('IPython','kernel','scripts')
263 main_scripts = pjoin('IPython','scripts')
263 main_scripts = pjoin('IPython','scripts')
264 scripts = [pjoin(kernel_scripts, 'ipengine'),
264 scripts = [pjoin(kernel_scripts, 'ipengine'),
265 pjoin(kernel_scripts, 'ipcontroller'),
265 pjoin(kernel_scripts, 'ipcontroller'),
266 pjoin(kernel_scripts, 'ipcluster'),
266 pjoin(kernel_scripts, 'ipcluster'),
267 pjoin(main_scripts, 'ipython'),
267 pjoin(main_scripts, 'ipython'),
268 pjoin(main_scripts, 'ipythonx'),
268 pjoin(main_scripts, 'ipythonx'),
269 pjoin(main_scripts, 'ipython-wx'),
269 pjoin(main_scripts, 'ipython-wx'),
270 pjoin(main_scripts, 'pycolor'),
270 pjoin(main_scripts, 'pycolor'),
271 pjoin(main_scripts, 'irunner'),
271 pjoin(main_scripts, 'irunner'),
272 pjoin(main_scripts, 'iptest')
272 pjoin(main_scripts, 'iptest')
273 ]
273 ]
274
274
275 # Script to be run by the windows binary installer after the default setup
275 # Script to be run by the windows binary installer after the default setup
276 # routine, to add shortcuts and similar windows-only things. Windows
276 # routine, to add shortcuts and similar windows-only things. Windows
277 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
277 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
278 # doesn't find them.
278 # doesn't find them.
279 if 'bdist_wininst' in sys.argv:
279 if 'bdist_wininst' in sys.argv:
280 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
280 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
281 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
281 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
282 sys.exit(1)
282 sys.exit(1)
283 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
283 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
284
284
285 return scripts
285 return scripts
286
286
287 #---------------------------------------------------------------------------
287 #---------------------------------------------------------------------------
288 # Verify all dependencies
288 # Verify all dependencies
289 #---------------------------------------------------------------------------
289 #---------------------------------------------------------------------------
290
290
291 def check_for_dependencies():
291 def check_for_dependencies():
292 """Check for IPython's dependencies.
292 """Check for IPython's dependencies.
293
293
294 This function should NOT be called if running under setuptools!
294 This function should NOT be called if running under setuptools!
295 """
295 """
296 from setupext.setupext import (
296 from setupext.setupext import (
297 print_line, print_raw, print_status, print_message,
297 print_line, print_raw, print_status, print_message,
298 check_for_zopeinterface, check_for_twisted,
298 check_for_zopeinterface, check_for_twisted,
299 check_for_foolscap, check_for_pyopenssl,
299 check_for_foolscap, check_for_pyopenssl,
300 check_for_sphinx, check_for_pygments,
300 check_for_sphinx, check_for_pygments,
301 check_for_nose, check_for_pexpect
301 check_for_nose, check_for_pexpect
302 )
302 )
303 print_line()
303 print_line()
304 print_raw("BUILDING IPYTHON")
304 print_raw("BUILDING IPYTHON")
305 print_status('python', sys.version)
305 print_status('python', sys.version)
306 print_status('platform', sys.platform)
306 print_status('platform', sys.platform)
307 if sys.platform == 'win32':
307 if sys.platform == 'win32':
308 print_status('Windows version', sys.getwindowsversion())
308 print_status('Windows version', sys.getwindowsversion())
309
309
310 print_raw("")
310 print_raw("")
311 print_raw("OPTIONAL DEPENDENCIES")
311 print_raw("OPTIONAL DEPENDENCIES")
312
312
313 check_for_zopeinterface()
313 check_for_zopeinterface()
314 check_for_twisted()
314 check_for_twisted()
315 check_for_foolscap()
315 check_for_foolscap()
316 check_for_pyopenssl()
316 check_for_pyopenssl()
317 check_for_sphinx()
317 check_for_sphinx()
318 check_for_pygments()
318 check_for_pygments()
319 check_for_nose()
319 check_for_nose()
320 check_for_pexpect()
320 check_for_pexpect()
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now