##// END OF EJS Templates
%store for macros works again
vivainio -
Show More
@@ -1,44 +1,44 b''
1 1 """Support for interactive macros in IPython"""
2 2
3 3 #*****************************************************************************
4 4 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
5 5 #
6 6 # Distributed under the terms of the BSD License. The full license is in
7 7 # the file COPYING, distributed as part of this software.
8 8 #*****************************************************************************
9 9
10 10 import IPython.ipapi
11 11
12 12
13 13 from IPython.genutils import Term
14 14 from IPython.ipapi import IPyAutocall
15 15
16 16 class Macro(IPyAutocall):
17 17 """Simple class to store the value of macros as strings.
18 18
19 19 Macro is just a callable that executes a string of IPython
20 20 input when called.
21 21
22 22 Args to macro are available in _margv list if you need them.
23 23 """
24 24
25 25 def __init__(self,data):
26 26
27 27 # store the macro value, as a single string which can be evaluated by
28 28 # runlines()
29 29 self.value = ''.join(data).rstrip()+'\n'
30 30
31 31 def __str__(self):
32 32 return self.value
33 33
34 34 def __repr__(self):
35 35 return 'IPython.macro.Macro(%s)' % repr(self.value)
36 36
37 37 def __call__(self,*args):
38 38 Term.cout.flush()
39 39 self._ip.user_ns['_margv'] = args
40 40 self._ip.runlines(self.value)
41 41
42 def getstate(self):
42 def __getstate__(self):
43 43 """ needed for safe pickling via %store """
44 44 return {'value': self.value} No newline at end of file
@@ -1,178 +1,54 b''
1 1 #!/usr/bin/env python
2 2 # -*- coding: utf-8 -*-
3 3 """Setup script for IPython.
4 4
5 5 Under Posix environments it works like a typical setup.py script.
6 6 Under Windows, the command sdist is not supported, since IPython
7 7 requires utilities, which are not available under Windows."""
8 8
9 9 #*****************************************************************************
10 10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
11 11 #
12 12 # Distributed under the terms of the BSD License. The full license is in
13 13 # the file COPYING, distributed as part of this software.
14 14 #*****************************************************************************
15 15
16 16 # Stdlib imports
17 17 import os
18 18 import sys
19
19 import py2exe
20 20 from glob import glob
21 21 from setupext import install_data_ext
22 22
23 from distutils.core import setup
24
23 25 # A few handy globals
24 26 isfile = os.path.isfile
25 27 pjoin = os.path.join
26 28
27 29 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
28 # update it when the contents of directories change.
29 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
30
31 if os.name == 'posix':
32 os_name = 'posix'
33 elif os.name in ['nt','dos']:
34 os_name = 'windows'
35 else:
36 print 'Unsupported operating system:',os.name
37 sys.exit(1)
38
39 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
40 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
41 if os_name == 'windows' and 'sdist' in sys.argv:
42 print 'The sdist command is not available under Windows. Exiting.'
43 sys.exit(1)
44
45 from distutils.core import setup
46
47 # update the manuals when building a source dist
48 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
49 from IPython.genutils import target_update
50 # list of things to be updated. Each entry is a triplet of args for
51 # target_update()
52 to_update = [('doc/magic.tex',
53 ['IPython/Magic.py'],
54 "cd doc && ./update_magic.sh" ),
55
56 ('doc/manual.lyx',
57 ['IPython/Release.py','doc/manual_base.lyx'],
58 "cd doc && ./update_version.sh" ),
59
60 ('doc/manual/manual.html',
61 ['doc/manual.lyx',
62 'doc/magic.tex',
63 'doc/examples/example-gnuplot.py',
64 'doc/examples/example-embed.py',
65 'doc/examples/example-embed-short.py',
66 'IPython/UserConfig/ipythonrc',
67 ],
68 "cd doc && "
69 "lyxport -tt --leave --pdf "
70 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
71
72 ('doc/new_design.pdf',
73 ['doc/new_design.lyx'],
74 "cd doc && lyxport -tt --pdf new_design.lyx"),
75
76 ('doc/ipython.1.gz',
77 ['doc/ipython.1'],
78 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
79
80 ('doc/pycolor.1.gz',
81 ['doc/pycolor.1'],
82 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
83 ]
84 for target in to_update:
85 target_update(*target)
86 30
87 31 # Release.py contains version, authors, license, url, keywords, etc.
88 32 execfile(pjoin('IPython','Release.py'))
89 33
90 34 # A little utility we'll need below, since glob() does NOT allow you to do
91 35 # exclusion on multiple endings!
92 36 def file_doesnt_endwith(test,endings):
93 37 """Return true if test is a file and its name does NOT end with any
94 38 of the strings listed in endings."""
95 39 if not isfile(test):
96 40 return False
97 41 for e in endings:
98 42 if test.endswith(e):
99 43 return False
100 44 return True
101 45
102 # I can't find how to make distutils create a nested dir. structure, so
103 # in the meantime do it manually. Butt ugly.
104 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
105 # information on how to do this more cleanly once python 2.4 can be assumed.
106 # Thanks to Noel for the tip.
107 docdirbase = 'share/doc/ipython-%s' % version
108 manpagebase = 'share/man/man1'
109
110 # We only need to exclude from this things NOT already excluded in the
111 # MANIFEST.in file.
112 exclude = ('.sh','.1.gz')
113 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
114
115 examfiles = filter(isfile, glob('doc/examples/*.py'))
116 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
117 filter(isfile, glob('doc/manual/*.css')) + \
118 filter(isfile, glob('doc/manual/*.png'))
119 manpages = filter(isfile, glob('doc/*.1.gz'))
120 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
121 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor',
122 'scripts/irunner'])
123 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
124
125 # Script to be run by the windows binary installer after the default setup
126 # routine, to add shortcuts and similar windows-only things. Windows
127 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
128 # doesn't find them.
129 if 'bdist_wininst' in sys.argv:
130 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
131 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
132 sys.exit(1)
133 scriptfiles.append('scripts/ipython_win_post_install.py')
134
135 datafiles = [('data', docdirbase, docfiles),
136 ('data', pjoin(docdirbase, 'examples'),examfiles),
137 ('data', pjoin(docdirbase, 'manual'),manfiles),
138 ('data', manpagebase, manpages),
139 ('lib', 'IPython/UserConfig', cfgfiles),
140 ('data',pjoin(docdirbase, 'extensions'),igridhelpfiles),
141 ]
142
143 if 'setuptools' in sys.modules:
144 # setuptools config for egg building
145 egg_extra_kwds = {
146 'entry_points': {
147 'console_scripts': [
148 'ipython = IPython.ipapi:launch_new_instance',
149 'pycolor = IPython.PyColorize:main'
150 ]}
151 }
152 scriptfiles = []
153 # eggs will lack docs, examples XXX not anymore
154 #datafiles = [('lib', 'IPython/UserConfig', cfgfiles)]
155 else:
156 egg_extra_kwds = {}
157
158 46
159 47 # Call the setup() routine which does most of the work
160 48 setup(name = name,
161 49 version = version,
162 description = description,
163 long_description = long_description,
164 author = authors['Fernando'][0],
165 author_email = authors['Fernando'][1],
166 url = url,
167 download_url = download_url,
168 license = license,
169 platforms = platforms,
170 keywords = keywords,
171 50 packages = ['IPython', 'IPython.Extensions', 'IPython.external'],
172 scripts = scriptfiles,
173
174 cmdclass = {'install_data': install_data_ext},
175 data_files = datafiles,
51 console = ['ipython.py'],
52 scripts = ['ipython.py'],
176 53 # extra params needed for eggs
177 **egg_extra_kwds
178 54 )
General Comments 0
You need to be logged in to leave comments. Login now