##// END OF EJS Templates
Update setup and support tools to include new man pages.
Fernando Perez -
Show More
@@ -1,189 +1,213 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) 2008 The IPython Development Team
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 #-------------------------------------------------------------------------------
17 17 # Imports
18 18 #-------------------------------------------------------------------------------
19 19
20 20 # Stdlib imports
21 21 import os
22 22 import sys
23 23
24 24 from glob import glob
25 25
26 26 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
27 27 # update it when the contents of directories change.
28 28 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
29 29
30 30 from distutils.core import setup
31 31
32 32 # Local imports
33 33 from IPython.genutils import target_update
34 34
35 35 from setupbase import (
36 36 setup_args,
37 37 find_packages,
38 38 find_package_data,
39 39 find_scripts,
40 40 find_data_files,
41 41 check_for_dependencies
42 42 )
43 43
44 44 isfile = os.path.isfile
45 45
46 46 #-------------------------------------------------------------------------------
47 47 # Handle OS specific things
48 48 #-------------------------------------------------------------------------------
49 49
50 50 if os.name == 'posix':
51 51 os_name = 'posix'
52 52 elif os.name in ['nt','dos']:
53 53 os_name = 'windows'
54 54 else:
55 55 print 'Unsupported operating system:',os.name
56 56 sys.exit(1)
57 57
58 58 # Under Windows, 'sdist' has not been supported. Now that the docs build with
59 59 # Sphinx it might work, but let's not turn it on until someone confirms that it
60 60 # actually works.
61 61 if os_name == 'windows' and 'sdist' in sys.argv:
62 62 print 'The sdist command is not available under Windows. Exiting.'
63 63 sys.exit(1)
64 64
65 65 #-------------------------------------------------------------------------------
66 66 # Things related to the IPython documentation
67 67 #-------------------------------------------------------------------------------
68 68
69 69 # update the manuals when building a source dist
70 70 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
71 71 import textwrap
72 72
73 73 # List of things to be updated. Each entry is a triplet of args for
74 74 # target_update()
75 75 to_update = [
76 76 # FIXME - Disabled for now: we need to redo an automatic way
77 77 # of generating the magic info inside the rst.
78 78 #('docs/magic.tex',
79 79 #['IPython/Magic.py'],
80 80 #"cd doc && ./update_magic.sh" ),
81
81
82 ('docs/man/ipcluster.1.gz',
83 ['docs/man/ipcluster.1'],
84 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
85
86 ('docs/man/ipcontroller.1.gz',
87 ['docs/man/ipcontroller.1'],
88 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
89
90 ('docs/man/ipengine.1.gz',
91 ['docs/man/ipengine.1'],
92 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
93
82 94 ('docs/man/ipython.1.gz',
83 95 ['docs/man/ipython.1'],
84 "cd docs/man && gzip -9c ipython.1 > ipython.1.gz"),
96 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
97
98 ('docs/man/ipython-wx.1.gz',
99 ['docs/man/ipython-wx.1'],
100 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'),
101
102 ('docs/man/ipythonx.1.gz',
103 ['docs/man/ipythonx.1'],
104 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'),
105
106 ('docs/man/irunner.1.gz',
107 ['docs/man/irunner.1'],
108 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
85 109
86 110 ('docs/man/pycolor.1.gz',
87 111 ['docs/man/pycolor.1'],
88 "cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz"),
112 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
89 113 ]
90 114
91 115 # Only build the docs if sphinx is present
92 116 try:
93 117 import sphinx
94 118 except ImportError:
95 119 pass
96 120 else:
97 121 # The Makefile calls the do_sphinx scripts to build html and pdf, so
98 122 # just one target is enough to cover all manual generation
99 123
100 124 # First, compute all the dependencies that can force us to rebuild the
101 125 # docs. Start with the main release file that contains metadata
102 126 docdeps = ['IPython/Release.py']
103 127 # Inculde all the reST sources
104 128 pjoin = os.path.join
105 129 for dirpath,dirnames,filenames in os.walk('docs/source'):
106 130 if dirpath in ['_static','_templates']:
107 131 continue
108 132 docdeps += [ pjoin(dirpath,f) for f in filenames
109 133 if f.endswith('.txt') ]
110 134 # and the examples
111 135 for dirpath,dirnames,filenames in os.walk('docs/example'):
112 136 docdeps += [ pjoin(dirpath,f) for f in filenames
113 137 if not f.endswith('~') ]
114 138 # then, make them all dependencies for the main PDF (the html will get
115 139 # auto-generated as well).
116 140 to_update.append(
117 141 ('docs/dist/ipython.pdf',
118 142 docdeps,
119 143 "cd docs && make dist")
120 144 )
121 145
122 146 [ target_update(*t) for t in to_update ]
123 147
124 148
125 149 #---------------------------------------------------------------------------
126 150 # Find all the packages, package data, scripts and data_files
127 151 #---------------------------------------------------------------------------
128 152
129 153 packages = find_packages()
130 154 package_data = find_package_data()
131 155 scripts = find_scripts()
132 156 data_files = find_data_files()
133 157
134 158 #---------------------------------------------------------------------------
135 159 # Handle dependencies and setuptools specific things
136 160 #---------------------------------------------------------------------------
137 161
138 162 # This dict is used for passing extra arguments that are setuptools
139 163 # specific to setup
140 164 setuptools_extra_args = {}
141 165
142 166 if 'setuptools' in sys.modules:
143 167 setuptools_extra_args['zip_safe'] = False
144 168 setuptools_extra_args['entry_points'] = {
145 169 'console_scripts': [
146 170 'ipython = IPython.ipapi:launch_new_instance',
147 171 'pycolor = IPython.PyColorize:main',
148 172 'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
149 173 'ipengine = IPython.kernel.scripts.ipengine:main',
150 174 'ipcluster = IPython.kernel.scripts.ipcluster:main',
151 175 'ipythonx = IPython.frontend.wx.ipythonx:main',
152 176 'iptest = IPython.testing.iptest:main',
153 177 ]
154 178 }
155 179 setup_args['extras_require'] = dict(
156 180 kernel = [
157 181 'zope.interface>=3.4.1',
158 182 'Twisted>=8.0.1',
159 183 'foolscap>=0.2.6'
160 184 ],
161 185 doc='Sphinx>=0.3',
162 186 test='nose>=0.10.1',
163 187 security='pyOpenSSL>=0.6'
164 188 )
165 189 # Allow setuptools to handle the scripts
166 190 scripts = []
167 191 else:
168 192 # package_data of setuptools was introduced to distutils in 2.4
169 193 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
170 194 if sys.version_info < (2,4):
171 195 data_files.append(('lib', 'IPython/UserConfig', cfgfiles))
172 196 # If we are running without setuptools, call this function which will
173 197 # check for dependencies an inform the user what is needed. This is
174 198 # just to make life easy for users.
175 199 check_for_dependencies()
176 200
177 201
178 202 #---------------------------------------------------------------------------
179 203 # Do the actual setup now
180 204 #---------------------------------------------------------------------------
181 205
182 206 setup_args['packages'] = packages
183 207 setup_args['package_data'] = package_data
184 208 setup_args['scripts'] = scripts
185 209 setup_args['data_files'] = data_files
186 210 setup_args.update(setuptools_extra_args)
187 211
188 212 if __name__ == '__main__':
189 213 setup(**setup_args)
@@ -1,279 +1,304 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,
86 86 others=None):
87 87 """
88 88 Add a package to the list of packages, including certain subpackages.
89 89 """
90 90 packages.append('.'.join(['IPython',pname]))
91 91 if config:
92 92 packages.append('.'.join(['IPython',pname,'config']))
93 93 if tests:
94 94 packages.append('.'.join(['IPython',pname,'tests']))
95 95 if scripts:
96 96 packages.append('.'.join(['IPython',pname,'scripts']))
97 97 if others is not None:
98 98 for o in others:
99 99 packages.append('.'.join(['IPython',pname,o]))
100 100
101 101 def find_packages():
102 102 """
103 103 Find all of IPython's packages.
104 104 """
105 105 packages = ['IPython']
106 106 add_package(packages, 'config', tests=True)
107 107 add_package(packages , 'Extensions')
108 108 add_package(packages, 'external')
109 109 add_package(packages, 'gui')
110 110 add_package(packages, 'gui.wx')
111 111 add_package(packages, 'frontend', tests=True)
112 112 add_package(packages, 'frontend.process')
113 113 add_package(packages, 'frontend.wx')
114 114 add_package(packages, 'frontend.cocoa', tests=True)
115 115 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
116 116 add_package(packages, 'kernel.core', config=True, tests=True)
117 117 add_package(packages, 'testing', tests=True)
118 118 add_package(packages, 'tests')
119 119 add_package(packages, 'testing.plugin', tests=False)
120 120 add_package(packages, 'tools', tests=True)
121 121 add_package(packages, 'UserConfig')
122 122 return packages
123 123
124 124 #---------------------------------------------------------------------------
125 125 # Find package data
126 126 #---------------------------------------------------------------------------
127 127
128 128 def find_package_data():
129 129 """
130 130 Find IPython's package_data.
131 131 """
132 132 # This is not enough for these things to appear in an sdist.
133 133 # We need to muck with the MANIFEST to get this to work
134 134 package_data = {
135 135 'IPython.UserConfig' : ['*'],
136 136 'IPython.tools.tests' : ['*.txt'],
137 137 'IPython.testing' : ['*.txt']
138 138 }
139 139 return package_data
140 140
141 141
142 142 #---------------------------------------------------------------------------
143 143 # Find data files
144 144 #---------------------------------------------------------------------------
145 145
146 146 def make_dir_struct(tag,base,out_base):
147 147 """Make the directory structure of all files below a starting dir.
148 148
149 149 This is just a convenience routine to help build a nested directory
150 150 hierarchy because distutils is too stupid to do this by itself.
151 151
152 152 XXX - this needs a proper docstring!
153 153 """
154 154
155 155 # we'll use these a lot below
156 156 lbase = len(base)
157 157 pathsep = os.path.sep
158 158 lpathsep = len(pathsep)
159 159
160 160 out = []
161 161 for (dirpath,dirnames,filenames) in os.walk(base):
162 162 # we need to strip out the dirpath from the base to map it to the
163 163 # output (installation) path. This requires possibly stripping the
164 164 # path separator, because otherwise pjoin will not work correctly
165 165 # (pjoin('foo/','/bar') returns '/bar').
166 166
167 167 dp_eff = dirpath[lbase:]
168 168 if dp_eff.startswith(pathsep):
169 169 dp_eff = dp_eff[lpathsep:]
170 170 # The output path must be anchored at the out_base marker
171 171 out_path = pjoin(out_base,dp_eff)
172 172 # Now we can generate the final filenames. Since os.walk only produces
173 173 # filenames, we must join back with the dirpath to get full valid file
174 174 # paths:
175 175 pfiles = [pjoin(dirpath,f) for f in filenames]
176 176 # Finally, generate the entry we need, which is a triple of (tag,output
177 177 # path, files) for use as a data_files parameter in install_data.
178 178 out.append((tag,out_path,pfiles))
179 179
180 180 return out
181 181
182 182
183 183 def find_data_files():
184 184 """
185 185 Find IPython's data_files.
186 186
187 187 Most of these are docs.
188 188 """
189 189
190 190 docdirbase = 'share/doc/ipython'
191 191 manpagebase = 'share/man/man1'
192 192
193 193 # Simple file lists can be made by hand
194 194 manpages = filter(isfile, glob('docs/man/*.1.gz'))
195 195 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
196 196
197 197 # For nested structures, use the utility above
198 198 example_files = make_dir_struct('data','docs/examples',
199 199 pjoin(docdirbase,'examples'))
200 200 manual_files = make_dir_struct('data','docs/dist',pjoin(docdirbase,'manual'))
201 201
202 202 # And assemble the entire output list
203 203 data_files = [ ('data',manpagebase, manpages),
204 204 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
205 205 ] + manual_files + example_files
206 206
207 207 ## import pprint # dbg
208 208 ## print '*'*80
209 209 ## print 'data files'
210 210 ## pprint.pprint(data_files)
211 211 ## print '*'*80
212 212
213 213 return data_files
214 214
215
216 def make_man_update_target(manpage):
217 """Return a target_update-compliant tuple for the given manpage.
218
219 Parameters
220 ----------
221 manpage : string
222 Name of the manpage, must include the section number (trailing number).
223
224 Example
225 -------
226
227 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
228 ('docs/man/ipython.1.gz',
229 ['docs/man/ipython.1'],
230 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
231 """
232 man_dir = pjoin('docs', 'man')
233 manpage_gz = manpage + '.gz'
234 manpath = pjoin(man_dir, manpage)
235 manpath_gz = pjoin(man_dir, manpage_gz)
236 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
237 locals() )
238 return (manpath_gz, [manpath], gz_cmd)
239
215 240 #---------------------------------------------------------------------------
216 241 # Find scripts
217 242 #---------------------------------------------------------------------------
218 243
219 244 def find_scripts():
220 245 """
221 246 Find IPython's scripts.
222 247 """
223 248 scripts = ['IPython/kernel/scripts/ipengine',
224 249 'IPython/kernel/scripts/ipcontroller',
225 250 'IPython/kernel/scripts/ipcluster',
226 251 'scripts/ipython',
227 252 'scripts/ipythonx',
228 253 'scripts/ipython-wx',
229 254 'scripts/pycolor',
230 255 'scripts/irunner',
231 256 'scripts/iptest',
232 257 ]
233 258
234 259 # Script to be run by the windows binary installer after the default setup
235 260 # routine, to add shortcuts and similar windows-only things. Windows
236 261 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
237 262 # doesn't find them.
238 263 if 'bdist_wininst' in sys.argv:
239 264 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
240 265 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
241 266 sys.exit(1)
242 267 scripts.append('scripts/ipython_win_post_install.py')
243 268
244 269 return scripts
245 270
246 271 #---------------------------------------------------------------------------
247 272 # Verify all dependencies
248 273 #---------------------------------------------------------------------------
249 274
250 275 def check_for_dependencies():
251 276 """Check for IPython's dependencies.
252 277
253 278 This function should NOT be called if running under setuptools!
254 279 """
255 280 from setupext.setupext import (
256 281 print_line, print_raw, print_status, print_message,
257 282 check_for_zopeinterface, check_for_twisted,
258 283 check_for_foolscap, check_for_pyopenssl,
259 284 check_for_sphinx, check_for_pygments,
260 285 check_for_nose, check_for_pexpect
261 286 )
262 287 print_line()
263 288 print_raw("BUILDING IPYTHON")
264 289 print_status('python', sys.version)
265 290 print_status('platform', sys.platform)
266 291 if sys.platform == 'win32':
267 292 print_status('Windows version', sys.getwindowsversion())
268 293
269 294 print_raw("")
270 295 print_raw("OPTIONAL DEPENDENCIES")
271 296
272 297 check_for_zopeinterface()
273 298 check_for_twisted()
274 299 check_for_foolscap()
275 300 check_for_pyopenssl()
276 301 check_for_sphinx()
277 302 check_for_pygments()
278 303 check_for_nose()
279 304 check_for_pexpect()
General Comments 0
You need to be logged in to leave comments. Login now