Show More
@@ -0,0 +1,11 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | # -*- coding: utf-8 -*- | |
|
3 | """IPythonX -- An enhanced Interactive Python | |
|
4 | ||
|
5 | This script starts the Wx graphical frontend. This is experimental so | |
|
6 | far. | |
|
7 | """ | |
|
8 | ||
|
9 | from IPython.frontend.wx import ipythonx | |
|
10 | ||
|
11 | ipythonx.main() |
@@ -1,104 +1,103 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | 1 |
|
|
3 | 2 | Entry point for a simple application giving a graphical frontend to |
|
4 | 3 | ipython. |
|
5 | 4 | """ |
|
6 | 5 | |
|
7 | 6 | try: |
|
8 | 7 | import wx |
|
9 | 8 | except ImportError, e: |
|
10 | 9 | e.message = """%s |
|
11 | 10 | ________________________________________________________________________________ |
|
12 | 11 | You need wxPython to run this application. |
|
13 | 12 | """ % e.message |
|
14 | 13 | e.args = (e.message, ) + e.args[1:] |
|
15 | 14 | raise e |
|
16 | 15 | |
|
17 | 16 | from wx_frontend import WxController |
|
18 | 17 | import __builtin__ |
|
19 | 18 | |
|
20 | 19 | class IPythonXController(WxController): |
|
21 | 20 | """ Sub class of WxController that adds some application-specific |
|
22 | 21 | bindings. |
|
23 | 22 | """ |
|
24 | 23 | |
|
25 | 24 | debug = False |
|
26 | 25 | |
|
27 | 26 | def __init__(self, *args, **kwargs): |
|
28 | 27 | WxController.__init__(self, *args, **kwargs) |
|
29 | 28 | self.ipython0.ask_exit = self.do_exit |
|
30 | 29 | |
|
31 | 30 | |
|
32 | 31 | def _on_key_down(self, event, skip=True): |
|
33 | 32 | # Intercept Ctrl-D to quit |
|
34 | 33 | if event.KeyCode == ord('D') and event.ControlDown() and \ |
|
35 | 34 | self.input_buffer == '' and \ |
|
36 | 35 | self._input_state == 'readline': |
|
37 | 36 | wx.CallAfter(self.ask_exit) |
|
38 | 37 | else: |
|
39 | 38 | WxController._on_key_down(self, event, skip=skip) |
|
40 | 39 | |
|
41 | 40 | |
|
42 | 41 | def ask_exit(self): |
|
43 | 42 | """ Ask the user whether to exit. |
|
44 | 43 | """ |
|
45 | 44 | self._input_state = 'subprocess' |
|
46 | 45 | self.write('\n', refresh=False) |
|
47 | 46 | self.capture_output() |
|
48 | 47 | self.ipython0.shell.exit() |
|
49 | 48 | self.release_output() |
|
50 | 49 | if not self.ipython0.exit_now: |
|
51 | 50 | wx.CallAfter(self.new_prompt, |
|
52 | 51 | self.input_prompt_template.substitute( |
|
53 | 52 | number=self.last_result['number'] + 1)) |
|
54 | 53 | |
|
55 | 54 | |
|
56 | 55 | def do_exit(self): |
|
57 | 56 | """ Exits the interpreter, kills the windows. |
|
58 | 57 | """ |
|
59 | 58 | WxController.do_exit(self) |
|
60 | 59 | self.release_output() |
|
61 | 60 | wx.CallAfter(wx.Exit) |
|
62 | 61 | |
|
63 | 62 | |
|
64 | 63 | |
|
65 | 64 | class IPythonX(wx.Frame): |
|
66 | 65 | """ Main frame of the IPythonX app. |
|
67 | 66 | """ |
|
68 | 67 | |
|
69 | 68 | def __init__(self, parent, id, title, debug=False): |
|
70 | 69 | wx.Frame.__init__(self, parent, id, title, size=(300,250)) |
|
71 | 70 | self._sizer = wx.BoxSizer(wx.VERTICAL) |
|
72 | 71 | self.shell = IPythonXController(self, debug=debug) |
|
73 | 72 | self._sizer.Add(self.shell, 1, wx.EXPAND) |
|
74 | 73 | self.SetSizer(self._sizer) |
|
75 | 74 | self.SetAutoLayout(1) |
|
76 | 75 | self.Show(True) |
|
77 | 76 | |
|
78 | 77 | |
|
79 | 78 | def main(): |
|
80 | 79 | from optparse import OptionParser |
|
81 | 80 | usage = """usage: %prog [options] |
|
82 | 81 | |
|
83 | 82 | Simple graphical frontend to IPython, using WxWidgets.""" |
|
84 | 83 | parser = OptionParser(usage=usage) |
|
85 | 84 | parser.add_option("-d", "--debug", |
|
86 | 85 | action="store_true", dest="debug", default=False, |
|
87 | 86 | help="Enable debug message for the wx frontend.") |
|
88 | 87 | |
|
89 | 88 | options, args = parser.parse_args() |
|
90 | 89 | |
|
91 | 90 | # Clear the options, to avoid having the ipython0 instance complain |
|
92 | 91 | import sys |
|
93 | 92 | sys.argv = sys.argv[:1] |
|
94 | 93 | |
|
95 | 94 | app = wx.PySimpleApp() |
|
96 | 95 | frame = IPythonX(None, wx.ID_ANY, 'IPythonX', debug=options.debug) |
|
97 | 96 | frame.shell.SetFocus() |
|
98 | 97 | frame.shell.app = app |
|
99 | 98 | frame.SetSize((680, 460)) |
|
100 | 99 | |
|
101 | 100 | app.MainLoop() |
|
102 | 101 | |
|
103 | 102 | if __name__ == '__main__': |
|
104 | 103 | main() |
@@ -1,236 +1,237 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """ |
|
4 | 4 | This module defines the things that are used in setup.py for building IPython |
|
5 | 5 | |
|
6 | 6 | This includes: |
|
7 | 7 | |
|
8 | 8 | * The basic arguments to setup |
|
9 | 9 | * Functions for finding things like packages, package data, etc. |
|
10 | 10 | * A function for checking dependencies. |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | __docformat__ = "restructuredtext en" |
|
14 | 14 | |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | # Copyright (C) 2008 The IPython Development Team |
|
17 | 17 | # |
|
18 | 18 | # Distributed under the terms of the BSD License. The full license is in |
|
19 | 19 | # the file COPYING, distributed as part of this software. |
|
20 | 20 | #------------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | #------------------------------------------------------------------------------- |
|
23 | 23 | # Imports |
|
24 | 24 | #------------------------------------------------------------------------------- |
|
25 | 25 | |
|
26 | 26 | import os, sys |
|
27 | 27 | |
|
28 | 28 | from glob import glob |
|
29 | 29 | |
|
30 | 30 | from setupext import install_data_ext |
|
31 | 31 | |
|
32 | 32 | #------------------------------------------------------------------------------- |
|
33 | 33 | # Useful globals and utility functions |
|
34 | 34 | #------------------------------------------------------------------------------- |
|
35 | 35 | |
|
36 | 36 | # A few handy globals |
|
37 | 37 | isfile = os.path.isfile |
|
38 | 38 | pjoin = os.path.join |
|
39 | 39 | |
|
40 | 40 | def oscmd(s): |
|
41 | 41 | print ">", s |
|
42 | 42 | os.system(s) |
|
43 | 43 | |
|
44 | 44 | # A little utility we'll need below, since glob() does NOT allow you to do |
|
45 | 45 | # exclusion on multiple endings! |
|
46 | 46 | def file_doesnt_endwith(test,endings): |
|
47 | 47 | """Return true if test is a file and its name does NOT end with any |
|
48 | 48 | of the strings listed in endings.""" |
|
49 | 49 | if not isfile(test): |
|
50 | 50 | return False |
|
51 | 51 | for e in endings: |
|
52 | 52 | if test.endswith(e): |
|
53 | 53 | return False |
|
54 | 54 | return True |
|
55 | 55 | |
|
56 | 56 | #--------------------------------------------------------------------------- |
|
57 | 57 | # Basic project information |
|
58 | 58 | #--------------------------------------------------------------------------- |
|
59 | 59 | |
|
60 | 60 | # Release.py contains version, authors, license, url, keywords, etc. |
|
61 | 61 | execfile(pjoin('IPython','Release.py')) |
|
62 | 62 | |
|
63 | 63 | # Create a dict with the basic information |
|
64 | 64 | # This dict is eventually passed to setup after additional keys are added. |
|
65 | 65 | setup_args = dict( |
|
66 | 66 | name = name, |
|
67 | 67 | version = version, |
|
68 | 68 | description = description, |
|
69 | 69 | long_description = long_description, |
|
70 | 70 | author = author, |
|
71 | 71 | author_email = author_email, |
|
72 | 72 | url = url, |
|
73 | 73 | download_url = download_url, |
|
74 | 74 | license = license, |
|
75 | 75 | platforms = platforms, |
|
76 | 76 | keywords = keywords, |
|
77 | 77 | cmdclass = {'install_data': install_data_ext}, |
|
78 | 78 | ) |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | #--------------------------------------------------------------------------- |
|
82 | 82 | # Find packages |
|
83 | 83 | #--------------------------------------------------------------------------- |
|
84 | 84 | |
|
85 | 85 | def add_package(packages, pname, config=False, tests=False, scripts=False, others=None): |
|
86 | 86 | """ |
|
87 | 87 | Add a package to the list of packages, including certain subpackages. |
|
88 | 88 | """ |
|
89 | 89 | packages.append('.'.join(['IPython',pname])) |
|
90 | 90 | if config: |
|
91 | 91 | packages.append('.'.join(['IPython',pname,'config'])) |
|
92 | 92 | if tests: |
|
93 | 93 | packages.append('.'.join(['IPython',pname,'tests'])) |
|
94 | 94 | if scripts: |
|
95 | 95 | packages.append('.'.join(['IPython',pname,'scripts'])) |
|
96 | 96 | if others is not None: |
|
97 | 97 | for o in others: |
|
98 | 98 | packages.append('.'.join(['IPython',pname,o])) |
|
99 | 99 | |
|
100 | 100 | def find_packages(): |
|
101 | 101 | """ |
|
102 | 102 | Find all of IPython's packages. |
|
103 | 103 | """ |
|
104 | 104 | packages = ['IPython'] |
|
105 | 105 | add_package(packages, 'config', tests=True) |
|
106 | 106 | add_package(packages , 'Extensions') |
|
107 | 107 | add_package(packages, 'external') |
|
108 | 108 | add_package(packages, 'gui') |
|
109 | 109 | add_package(packages, 'gui.wx') |
|
110 | add_package(packages, 'frontend') | |
|
110 | add_package(packages, 'frontend', tests=True) | |
|
111 | 111 | add_package(packages, 'frontend._process') |
|
112 | 112 | add_package(packages, 'frontend.wx') |
|
113 | add_package(packages, 'frontend.cocoa') | |
|
113 | add_package(packages, 'frontend.cocoa', tests=True) | |
|
114 | 114 | add_package(packages, 'kernel', config=True, tests=True, scripts=True) |
|
115 | 115 | add_package(packages, 'kernel.core', config=True, tests=True) |
|
116 | 116 | add_package(packages, 'testing', tests=True) |
|
117 | 117 | add_package(packages, 'tools', tests=True) |
|
118 | 118 | add_package(packages, 'UserConfig') |
|
119 | 119 | return packages |
|
120 | 120 | |
|
121 | 121 | #--------------------------------------------------------------------------- |
|
122 | 122 | # Find package data |
|
123 | 123 | #--------------------------------------------------------------------------- |
|
124 | 124 | |
|
125 | 125 | def find_package_data(): |
|
126 | 126 | """ |
|
127 | 127 | Find IPython's package_data. |
|
128 | 128 | """ |
|
129 | 129 | # This is not enough for these things to appear in an sdist. |
|
130 | 130 | # We need to muck with the MANIFEST to get this to work |
|
131 | 131 | package_data = { |
|
132 | 132 | 'IPython.UserConfig' : ['*'], |
|
133 | 133 | 'IPython.tools.tests' : ['*.txt'], |
|
134 | 134 | 'IPython.testing' : ['*.txt'] |
|
135 | 135 | } |
|
136 | 136 | return package_data |
|
137 | 137 | |
|
138 | 138 | |
|
139 | 139 | #--------------------------------------------------------------------------- |
|
140 | 140 | # Find data files |
|
141 | 141 | #--------------------------------------------------------------------------- |
|
142 | 142 | |
|
143 | 143 | def find_data_files(): |
|
144 | 144 | """ |
|
145 | 145 | Find IPython's data_files. |
|
146 | 146 | """ |
|
147 | 147 | |
|
148 | 148 | # I can't find how to make distutils create a nested dir. structure, so |
|
149 | 149 | # in the meantime do it manually. Butt ugly. |
|
150 | 150 | # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain |
|
151 | 151 | # information on how to do this more cleanly once python 2.4 can be assumed. |
|
152 | 152 | # Thanks to Noel for the tip. |
|
153 | 153 | docdirbase = 'share/doc/ipython' |
|
154 | 154 | manpagebase = 'share/man/man1' |
|
155 | 155 | |
|
156 | 156 | # We only need to exclude from this things NOT already excluded in the |
|
157 | 157 | # MANIFEST.in file. |
|
158 | 158 | exclude = ('.sh','.1.gz') |
|
159 | 159 | # We need to figure out how we want to package all of our rst docs? |
|
160 | 160 | # docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('docs/*')) |
|
161 | 161 | examfiles = filter(isfile, glob('docs/examples/core/*.py')) |
|
162 | 162 | examfiles.append(filter(isfile, glob('docs/examples/kernel/*.py'))) |
|
163 | 163 | manpages = filter(isfile, glob('docs/man/*.1.gz')) |
|
164 | 164 | igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*')) |
|
165 | 165 | |
|
166 | 166 | data_files = [#('data', docdirbase, docfiles), |
|
167 | 167 | ('data', pjoin(docdirbase, 'examples'),examfiles), |
|
168 | 168 | ('data', manpagebase, manpages), |
|
169 | 169 | ('data',pjoin(docdirbase, 'extensions'),igridhelpfiles), |
|
170 | 170 | ] |
|
171 | 171 | # import pprint |
|
172 | 172 | # pprint.pprint(data_files) |
|
173 | 173 | return [] |
|
174 | 174 | |
|
175 | 175 | #--------------------------------------------------------------------------- |
|
176 | 176 | # Find scripts |
|
177 | 177 | #--------------------------------------------------------------------------- |
|
178 | 178 | |
|
179 | 179 | def find_scripts(): |
|
180 | 180 | """ |
|
181 | 181 | Find IPython's scripts. |
|
182 | 182 | """ |
|
183 | 183 | scripts = [] |
|
184 | 184 | scripts.append('IPython/kernel/scripts/ipengine') |
|
185 | 185 | scripts.append('IPython/kernel/scripts/ipcontroller') |
|
186 | 186 | scripts.append('IPython/kernel/scripts/ipcluster') |
|
187 | 187 | scripts.append('scripts/ipython') |
|
188 | scripts.append('scripts/ipythonx') | |
|
188 | 189 | scripts.append('scripts/pycolor') |
|
189 | 190 | scripts.append('scripts/irunner') |
|
190 | 191 | |
|
191 | 192 | # Script to be run by the windows binary installer after the default setup |
|
192 | 193 | # routine, to add shortcuts and similar windows-only things. Windows |
|
193 | 194 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
194 | 195 | # doesn't find them. |
|
195 | 196 | if 'bdist_wininst' in sys.argv: |
|
196 | 197 | if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
197 | 198 | print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting." |
|
198 | 199 | sys.exit(1) |
|
199 | 200 | scripts.append('scripts/ipython_win_post_install.py') |
|
200 | 201 | |
|
201 | 202 | return scripts |
|
202 | 203 | |
|
203 | 204 | #--------------------------------------------------------------------------- |
|
204 | 205 | # Find scripts |
|
205 | 206 | #--------------------------------------------------------------------------- |
|
206 | 207 | |
|
207 | 208 | def check_for_dependencies(): |
|
208 | 209 | """Check for IPython's dependencies. |
|
209 | 210 | |
|
210 | 211 | This function should NOT be called if running under setuptools! |
|
211 | 212 | """ |
|
212 | 213 | from setupext.setupext import ( |
|
213 | 214 | print_line, print_raw, print_status, print_message, |
|
214 | 215 | check_for_zopeinterface, check_for_twisted, |
|
215 | 216 | check_for_foolscap, check_for_pyopenssl, |
|
216 | 217 | check_for_sphinx, check_for_pygments, |
|
217 | 218 | check_for_nose, check_for_pexpect |
|
218 | 219 | ) |
|
219 | 220 | print_line() |
|
220 | 221 | print_raw("BUILDING IPYTHON") |
|
221 | 222 | print_status('python', sys.version) |
|
222 | 223 | print_status('platform', sys.platform) |
|
223 | 224 | if sys.platform == 'win32': |
|
224 | 225 | print_status('Windows version', sys.getwindowsversion()) |
|
225 | 226 | |
|
226 | 227 | print_raw("") |
|
227 | 228 | print_raw("OPTIONAL DEPENDENCIES") |
|
228 | 229 | |
|
229 | 230 | check_for_zopeinterface() |
|
230 | 231 | check_for_twisted() |
|
231 | 232 | check_for_foolscap() |
|
232 | 233 | check_for_pyopenssl() |
|
233 | 234 | check_for_sphinx() |
|
234 | 235 | check_for_pygments() |
|
235 | 236 | check_for_nose() |
|
236 | 237 | check_for_pexpect() |
General Comments 0
You need to be logged in to leave comments.
Login now