##// END OF EJS Templates
Remove duplicate code in setup2/3 and move it to setupbase.
Fernando Perez -
Show More
@@ -1,243 +1,235 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-2011, IPython Development Team.
11 11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
12 12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
13 13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
14 14 #
15 15 # Distributed under the terms of the Modified BSD License.
16 16 #
17 17 # The full license is in the file COPYING.txt, distributed with this software.
18 18 #-----------------------------------------------------------------------------
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Minimal Python version sanity check
22 22 #-----------------------------------------------------------------------------
23 23
24 24 import sys
25 25
26 26 # This check is also made in IPython/__init__, don't forget to update both when
27 27 # changing Python version requirements.
28 28 if sys.version[0:3] < '2.6':
29 29 error = """\
30 30 ERROR: 'IPython requires Python Version 2.6 or above.'
31 31 Exiting."""
32 32 print >> sys.stderr, error
33 33 sys.exit(1)
34 34
35 35 # At least we're on the python version we need, move on.
36 36
37 37 #-------------------------------------------------------------------------------
38 38 # Imports
39 39 #-------------------------------------------------------------------------------
40 40
41 41 # Stdlib imports
42 42 import os
43 43 import shutil
44 44
45 45 from glob import glob
46 46
47 47 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
48 48 # update it when the contents of directories change.
49 49 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
50 50
51 51 from distutils.core import setup
52 52
53 53 # Our own imports
54 54 from IPython.utils.path import target_update
55 55
56 56 from setupbase import (
57 57 setup_args,
58 58 find_packages,
59 59 find_package_data,
60 60 find_scripts,
61 61 find_data_files,
62 62 check_for_dependencies,
63 63 record_commit_info,
64 bdist_wininst_options,
64 65 )
65 66 from setupext import setupext
66 67
67 68 isfile = os.path.isfile
68 69 pjoin = os.path.join
69 70
70 71 #-----------------------------------------------------------------------------
71 72 # Function definitions
72 73 #-----------------------------------------------------------------------------
73 74
74 75 def cleanup():
75 76 """Clean up the junk left around by the build process"""
76 77 if "develop" not in sys.argv:
77 78 try:
78 79 shutil.rmtree('ipython.egg-info')
79 80 except:
80 81 try:
81 82 os.unlink('ipython.egg-info')
82 83 except:
83 84 pass
84 85
85 86 #-------------------------------------------------------------------------------
86 87 # Handle OS specific things
87 88 #-------------------------------------------------------------------------------
88 89
89 90 if os.name == 'posix':
90 91 os_name = 'posix'
91 92 elif os.name in ['nt','dos']:
92 93 os_name = 'windows'
93 94 else:
94 95 print 'Unsupported operating system:',os.name
95 96 sys.exit(1)
96 97
97 98 # Under Windows, 'sdist' has not been supported. Now that the docs build with
98 99 # Sphinx it might work, but let's not turn it on until someone confirms that it
99 100 # actually works.
100 101 if os_name == 'windows' and 'sdist' in sys.argv:
101 102 print 'The sdist command is not available under Windows. Exiting.'
102 103 sys.exit(1)
103 104
104 105 #-------------------------------------------------------------------------------
105 106 # Things related to the IPython documentation
106 107 #-------------------------------------------------------------------------------
107 108
108 109 # update the manuals when building a source dist
109 110 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
110 111 import textwrap
111 112
112 113 # List of things to be updated. Each entry is a triplet of args for
113 114 # target_update()
114 115 to_update = [
115 116 # FIXME - Disabled for now: we need to redo an automatic way
116 117 # of generating the magic info inside the rst.
117 118 #('docs/magic.tex',
118 119 #['IPython/Magic.py'],
119 120 #"cd doc && ./update_magic.sh" ),
120 121
121 122 ('docs/man/ipcluster.1.gz',
122 123 ['docs/man/ipcluster.1'],
123 124 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
124 125
125 126 ('docs/man/ipcontroller.1.gz',
126 127 ['docs/man/ipcontroller.1'],
127 128 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
128 129
129 130 ('docs/man/ipengine.1.gz',
130 131 ['docs/man/ipengine.1'],
131 132 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
132 133
133 134 ('docs/man/iplogger.1.gz',
134 135 ['docs/man/iplogger.1'],
135 136 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'),
136 137
137 138 ('docs/man/ipython.1.gz',
138 139 ['docs/man/ipython.1'],
139 140 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
140 141
141 142 ('docs/man/irunner.1.gz',
142 143 ['docs/man/irunner.1'],
143 144 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
144 145
145 146 ('docs/man/pycolor.1.gz',
146 147 ['docs/man/pycolor.1'],
147 148 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'),
148 149 ]
149 150
150 151
151 152 [ target_update(*t) for t in to_update ]
152 153
153 154 #---------------------------------------------------------------------------
154 155 # Find all the packages, package data, and data_files
155 156 #---------------------------------------------------------------------------
156 157
157 158 packages = find_packages()
158 159 package_data = find_package_data()
159 160 data_files = find_data_files()
160 161
161 162 #---------------------------------------------------------------------------
162 163 # Handle scripts, dependencies, and setuptools specific things
163 164 #---------------------------------------------------------------------------
164 165
165 166 # For some commands, use setuptools. Note that we do NOT list install here!
166 167 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
167 168 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
168 169 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
169 170 'egg_info', 'easy_install', 'upload',
170 171 ))
171 172 if sys.platform == 'win32':
172 173 # Depend on setuptools for install on *Windows only*
173 174 # If we get script-installation working without setuptools,
174 175 # then we can back off, but until then use it.
175 176 # See Issue #369 on GitHub for more
176 177 needs_setuptools.add('install')
177 178
178 179 if len(needs_setuptools.intersection(sys.argv)) > 0:
179 180 import setuptools
180 181
181 182 # This dict is used for passing extra arguments that are setuptools
182 183 # specific to setup
183 184 setuptools_extra_args = {}
184 185
185 186 if 'setuptools' in sys.modules:
186 187 setuptools_extra_args['zip_safe'] = False
187 188 setuptools_extra_args['entry_points'] = find_scripts(True)
188 189 setup_args['extras_require'] = dict(
189 190 parallel = 'pyzmq>=2.1.4',
190 191 zmq = 'pyzmq>=2.1.4',
191 192 doc = 'Sphinx>=0.3',
192 193 test = 'nose>=0.10.1',
193 194 notebook = 'tornado>=2.0'
194 195 )
195 196 requires = setup_args.setdefault('install_requires', [])
196 197 setupext.display_status = False
197 198 if not setupext.check_for_readline():
198 199 if sys.platform == 'darwin':
199 200 requires.append('readline')
200 elif sys.platform.startswith('win') and sys.maxsize < 2**32:
201 # only require pyreadline on 32b Windows, due to 64b bug in pyreadline:
202 # https://bugs.launchpad.net/pyreadline/+bug/787574
203 requires.append('pyreadline')
201 elif sys.platform.startswith('win') and \
202 not 'bdist_wininst' in sys.argv:
203 # We must avoid listing pyreadline when *building* the binary windows
204 # installers, because if we do so, then at runtime ipython will fail
205 # to find a pyreadline that could have been installed without
206 # setuptools (such as the one from the binary pyreadline installer).
207 requires.append('pyreadline')
204 208 else:
205 209 pass
206 # do we want to install readline here?
207
208 # Script to be run by the windows binary installer after the default setup
209 # routine, to add shortcuts and similar windows-only things. Windows
210 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
211 # doesn't find them.
212 if 'bdist_wininst' in sys.argv:
213 if len(sys.argv) > 2 and \
214 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
215 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
216 sys.exit(1)
217 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
218 setup_args['options'] = {"bdist_wininst":
219 {"install_script":
220 "ipython_win_post_install.py"}}
210 setup_args.update(bdist_wininst_options())
221 211 else:
222 212 # If we are running without setuptools, call this function which will
223 213 # check for dependencies an inform the user what is needed. This is
224 214 # just to make life easy for users.
225 215 check_for_dependencies()
226 216 setup_args['scripts'] = find_scripts(False)
227 217
228 218 #---------------------------------------------------------------------------
229 219 # Do the actual setup now
230 220 #---------------------------------------------------------------------------
231 221
232 222 setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')}
233 223 setup_args['packages'] = packages
234 224 setup_args['package_data'] = package_data
235 225 setup_args['data_files'] = data_files
236 226 setup_args.update(setuptools_extra_args)
237 227
228
238 229 def main():
239 230 setup(**setup_args)
240 231 cleanup()
241 232
233
242 234 if __name__ == '__main__':
243 235 main()
@@ -1,36 +1,26 b''
1 1 import os.path
2 2 import sys
3 3 from setuptools import setup
4 4 from setuptools.command.build_py import build_py
5 5
6 6 from setupbase import (setup_args,
7 7 find_scripts,
8 8 find_packages,
9 9 find_package_data,
10 10 record_commit_info,
11 bdist_wininst_options,
11 12 )
12 13
13 14 setup_args['entry_points'] = find_scripts(True, suffix='3')
14 15 setup_args['packages'] = find_packages()
15 16 setup_args['package_data'] = find_package_data()
16 setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)}
17 setup_args['cmdclass'] = {'build_py':
18 record_commit_info('IPython', build_cmd=build_py)}
17 19
18 # Script to be run by the windows binary installer after the default setup
19 # routine, to add shortcuts and similar windows-only things. Windows
20 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
21 # doesn't find them.
22 if 'bdist_wininst' in sys.argv:
23 if len(sys.argv) > 2 and \
24 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
25 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
26 sys.exit(1)
27 setup_args['scripts'] = [os.path.join('scripts','ipython_win_post_install.py')]
28 setup_args['options'] = {"bdist_wininst":
29 {"install_script":
30 "ipython_win_post_install.py"}}
20 setup_args.update(bdist_wininst_options())
31 21
32 22 def main():
33 23 setup(use_2to3 = True, **setup_args)
34 24
35 25 if __name__ == "__main__":
36 26 main()
@@ -1,360 +1,389 b''
1 1 # encoding: utf-8
2 2 """
3 3 This module defines the things that are used in setup.py for building IPython
4 4
5 5 This includes:
6 6
7 7 * The basic arguments to setup
8 8 * Functions for finding things like packages, package data, etc.
9 9 * A function for checking dependencies.
10 10 """
11 11 from __future__ import print_function
12 12
13 13 #-------------------------------------------------------------------------------
14 14 # Copyright (C) 2008 The IPython Development Team
15 15 #
16 16 # Distributed under the terms of the BSD License. The full license is in
17 17 # the file COPYING, distributed as part of this software.
18 18 #-------------------------------------------------------------------------------
19 19
20 20 #-------------------------------------------------------------------------------
21 21 # Imports
22 22 #-------------------------------------------------------------------------------
23 23 import os
24 24 import sys
25 25
26 26 try:
27 27 from configparser import ConfigParser
28 28 except:
29 29 from ConfigParser import ConfigParser
30 30 from distutils.command.build_py import build_py
31 31 from glob import glob
32 32
33 33 from setupext import install_data_ext
34 34
35 35 #-------------------------------------------------------------------------------
36 36 # Useful globals and utility functions
37 37 #-------------------------------------------------------------------------------
38 38
39 39 # A few handy globals
40 40 isfile = os.path.isfile
41 41 pjoin = os.path.join
42 42
43 43 def oscmd(s):
44 44 print(">", s)
45 45 os.system(s)
46 46
47 47 # Py3 compatibility hacks, without assuming IPython itself is installed with
48 48 # the full py3compat machinery.
49 49
50 50 try:
51 51 execfile
52 52 except NameError:
53 53 def execfile(fname, globs, locs=None):
54 54 locs = locs or globs
55 55 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
56 56
57 57 # A little utility we'll need below, since glob() does NOT allow you to do
58 58 # exclusion on multiple endings!
59 59 def file_doesnt_endwith(test,endings):
60 60 """Return true if test is a file and its name does NOT end with any
61 61 of the strings listed in endings."""
62 62 if not isfile(test):
63 63 return False
64 64 for e in endings:
65 65 if test.endswith(e):
66 66 return False
67 67 return True
68 68
69 69 #---------------------------------------------------------------------------
70 70 # Basic project information
71 71 #---------------------------------------------------------------------------
72 72
73 73 # release.py contains version, authors, license, url, keywords, etc.
74 74 execfile(pjoin('IPython','core','release.py'), globals())
75 75
76 76 # Create a dict with the basic information
77 77 # This dict is eventually passed to setup after additional keys are added.
78 78 setup_args = dict(
79 79 name = name,
80 80 version = version,
81 81 description = description,
82 82 long_description = long_description,
83 83 author = author,
84 84 author_email = author_email,
85 85 url = url,
86 86 download_url = download_url,
87 87 license = license,
88 88 platforms = platforms,
89 89 keywords = keywords,
90 90 classifiers = classifiers,
91 91 cmdclass = {'install_data': install_data_ext},
92 92 )
93 93
94 94
95 95 #---------------------------------------------------------------------------
96 96 # Find packages
97 97 #---------------------------------------------------------------------------
98 98
99 99 def find_packages():
100 100 """
101 101 Find all of IPython's packages.
102 102 """
103 103 excludes = ['deathrow']
104 104 packages = []
105 105 for dir,subdirs,files in os.walk('IPython'):
106 106 package = dir.replace(os.path.sep, '.')
107 107 if any([ package.startswith('IPython.'+exc) for exc in excludes ]):
108 108 # package is to be excluded (e.g. deathrow)
109 109 continue
110 110 if '__init__.py' not in files:
111 111 # not a package
112 112 continue
113 113 packages.append(package)
114 114 return packages
115 115
116 116 #---------------------------------------------------------------------------
117 117 # Find package data
118 118 #---------------------------------------------------------------------------
119 119
120 120 def find_package_data():
121 121 """
122 122 Find IPython's package_data.
123 123 """
124 124 # This is not enough for these things to appear in an sdist.
125 125 # We need to muck with the MANIFEST to get this to work
126 126
127 127 # exclude static things that we don't ship (e.g. mathjax)
128 128 excludes = ['mathjax']
129 129
130 130 # add 'static/' prefix to exclusions, and tuplify for use in startswith
131 131 excludes = tuple([os.path.join('static', ex) for ex in excludes])
132 132
133 133 # walk notebook resources:
134 134 cwd = os.getcwd()
135 135 os.chdir(os.path.join('IPython', 'frontend', 'html', 'notebook'))
136 136 static_walk = list(os.walk('static'))
137 137 os.chdir(cwd)
138 138 static_data = []
139 139 for parent, dirs, files in static_walk:
140 140 if parent.startswith(excludes):
141 141 continue
142 142 for f in files:
143 143 static_data.append(os.path.join(parent, f))
144 144
145 145 package_data = {
146 146 'IPython.config.profile' : ['README*', '*/*.py'],
147 147 'IPython.testing' : ['*.txt'],
148 148 'IPython.frontend.html.notebook' : ['templates/*'] + static_data,
149 149 'IPython.frontend.qt.console' : ['resources/icon/*.svg'],
150 150 }
151 151 return package_data
152 152
153 153
154 154 #---------------------------------------------------------------------------
155 155 # Find data files
156 156 #---------------------------------------------------------------------------
157 157
158 158 def make_dir_struct(tag,base,out_base):
159 159 """Make the directory structure of all files below a starting dir.
160 160
161 161 This is just a convenience routine to help build a nested directory
162 162 hierarchy because distutils is too stupid to do this by itself.
163 163
164 164 XXX - this needs a proper docstring!
165 165 """
166 166
167 167 # we'll use these a lot below
168 168 lbase = len(base)
169 169 pathsep = os.path.sep
170 170 lpathsep = len(pathsep)
171 171
172 172 out = []
173 173 for (dirpath,dirnames,filenames) in os.walk(base):
174 174 # we need to strip out the dirpath from the base to map it to the
175 175 # output (installation) path. This requires possibly stripping the
176 176 # path separator, because otherwise pjoin will not work correctly
177 177 # (pjoin('foo/','/bar') returns '/bar').
178 178
179 179 dp_eff = dirpath[lbase:]
180 180 if dp_eff.startswith(pathsep):
181 181 dp_eff = dp_eff[lpathsep:]
182 182 # The output path must be anchored at the out_base marker
183 183 out_path = pjoin(out_base,dp_eff)
184 184 # Now we can generate the final filenames. Since os.walk only produces
185 185 # filenames, we must join back with the dirpath to get full valid file
186 186 # paths:
187 187 pfiles = [pjoin(dirpath,f) for f in filenames]
188 188 # Finally, generate the entry we need, which is a pari of (output
189 189 # path, files) for use as a data_files parameter in install_data.
190 190 out.append((out_path, pfiles))
191 191
192 192 return out
193 193
194 194
195 195 def find_data_files():
196 196 """
197 197 Find IPython's data_files.
198 198
199 199 Most of these are docs.
200 200 """
201 201
202 202 docdirbase = pjoin('share', 'doc', 'ipython')
203 203 manpagebase = pjoin('share', 'man', 'man1')
204 204
205 205 # Simple file lists can be made by hand
206 206 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
207 207 if not manpages:
208 208 # When running from a source tree, the manpages aren't gzipped
209 209 manpages = filter(isfile, glob(pjoin('docs','man','*.1')))
210 210 igridhelpfiles = filter(isfile,
211 211 glob(pjoin('IPython','extensions','igrid_help.*')))
212 212
213 213 # For nested structures, use the utility above
214 214 example_files = make_dir_struct(
215 215 'data',
216 216 pjoin('docs','examples'),
217 217 pjoin(docdirbase,'examples')
218 218 )
219 219 manual_files = make_dir_struct(
220 220 'data',
221 221 pjoin('docs','html'),
222 222 pjoin(docdirbase,'manual')
223 223 )
224 224
225 225 # And assemble the entire output list
226 226 data_files = [ (manpagebase, manpages),
227 227 (pjoin(docdirbase, 'extensions'), igridhelpfiles),
228 228 ] + manual_files + example_files
229 229
230 230 return data_files
231 231
232 232
233 233 def make_man_update_target(manpage):
234 234 """Return a target_update-compliant tuple for the given manpage.
235 235
236 236 Parameters
237 237 ----------
238 238 manpage : string
239 239 Name of the manpage, must include the section number (trailing number).
240 240
241 241 Example
242 242 -------
243 243
244 244 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
245 245 ('docs/man/ipython.1.gz',
246 246 ['docs/man/ipython.1'],
247 247 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
248 248 """
249 249 man_dir = pjoin('docs', 'man')
250 250 manpage_gz = manpage + '.gz'
251 251 manpath = pjoin(man_dir, manpage)
252 252 manpath_gz = pjoin(man_dir, manpage_gz)
253 253 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
254 254 locals() )
255 255 return (manpath_gz, [manpath], gz_cmd)
256 256
257 257 #---------------------------------------------------------------------------
258 258 # Find scripts
259 259 #---------------------------------------------------------------------------
260 260
261 261 def find_scripts(entry_points=False, suffix=''):
262 262 """Find IPython's scripts.
263 263
264 264 if entry_points is True:
265 265 return setuptools entry_point-style definitions
266 266 else:
267 267 return file paths of plain scripts [default]
268 268
269 269 suffix is appended to script names if entry_points is True, so that the
270 270 Python 3 scripts get named "ipython3" etc.
271 271 """
272 272 if entry_points:
273 273 console_scripts = [s % suffix for s in [
274 274 'ipython%s = IPython.frontend.terminal.ipapp:launch_new_instance',
275 275 'pycolor%s = IPython.utils.PyColorize:main',
276 276 'ipcontroller%s = IPython.parallel.apps.ipcontrollerapp:launch_new_instance',
277 277 'ipengine%s = IPython.parallel.apps.ipengineapp:launch_new_instance',
278 278 'iplogger%s = IPython.parallel.apps.iploggerapp:launch_new_instance',
279 279 'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance',
280 280 'iptest%s = IPython.testing.iptest:main',
281 281 'irunner%s = IPython.lib.irunner:main'
282 282 ]]
283 283 gui_scripts = [s % suffix for s in [
284 284 'ipython%s-qtconsole = IPython.frontend.qt.console.qtconsoleapp:main',
285 285 ]]
286 286 scripts = dict(console_scripts=console_scripts, gui_scripts=gui_scripts)
287 287 else:
288 288 parallel_scripts = pjoin('IPython','parallel','scripts')
289 289 main_scripts = pjoin('IPython','scripts')
290 290 scripts = [
291 291 pjoin(parallel_scripts, 'ipengine'),
292 292 pjoin(parallel_scripts, 'ipcontroller'),
293 293 pjoin(parallel_scripts, 'ipcluster'),
294 294 pjoin(parallel_scripts, 'iplogger'),
295 295 pjoin(main_scripts, 'ipython'),
296 296 pjoin(main_scripts, 'pycolor'),
297 297 pjoin(main_scripts, 'irunner'),
298 298 pjoin(main_scripts, 'iptest')
299 299 ]
300 300 return scripts
301 301
302 302 #---------------------------------------------------------------------------
303 303 # Verify all dependencies
304 304 #---------------------------------------------------------------------------
305 305
306 306 def check_for_dependencies():
307 307 """Check for IPython's dependencies.
308 308
309 309 This function should NOT be called if running under setuptools!
310 310 """
311 311 from setupext.setupext import (
312 312 print_line, print_raw, print_status,
313 313 check_for_sphinx, check_for_pygments,
314 314 check_for_nose, check_for_pexpect,
315 315 check_for_pyzmq, check_for_readline
316 316 )
317 317 print_line()
318 318 print_raw("BUILDING IPYTHON")
319 319 print_status('python', sys.version)
320 320 print_status('platform', sys.platform)
321 321 if sys.platform == 'win32':
322 322 print_status('Windows version', sys.getwindowsversion())
323 323
324 324 print_raw("")
325 325 print_raw("OPTIONAL DEPENDENCIES")
326 326
327 327 check_for_sphinx()
328 328 check_for_pygments()
329 329 check_for_nose()
330 330 check_for_pexpect()
331 331 check_for_pyzmq()
332 332 check_for_readline()
333 333
334 334 def record_commit_info(pkg_dir, build_cmd=build_py):
335 335 """ Return extended build command class for recording commit
336 336
337 337 records git commit in IPython.utils._sysinfo.commit
338 338
339 339 for use in IPython.utils.sysinfo.sys_info() calls after installation.
340 340 """
341 341
342 342 class MyBuildPy(build_cmd):
343 343 ''' Subclass to write commit data into installation tree '''
344 344 def run(self):
345 345 build_cmd.run(self)
346 346 import subprocess
347 347 proc = subprocess.Popen('git rev-parse --short HEAD',
348 348 stdout=subprocess.PIPE,
349 349 stderr=subprocess.PIPE,
350 350 shell=True)
351 351 repo_commit, _ = proc.communicate()
352 352 repo_commit = repo_commit.strip()
353 353 # We write the installation commit even if it's empty
354 354 out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py')
355 355 with open(out_pth, 'w') as out_file:
356 356 out_file.writelines([
357 357 '# GENERATED BY setup.py\n',
358 358 'commit = "%s"\n' % repo_commit.decode('ascii'),
359 359 ])
360 360 return MyBuildPy
361
362 #-----------------------------------------------------------------------------
363 # Misc. utilities common to setup2/3
364 #-----------------------------------------------------------------------------
365
366 def bdist_wininst_options():
367 """Options to setup specific to the creation of Windows binary installer.
368 """
369
370 setup_args = {}
371
372 if 'bdist_wininst' not in sys.argv:
373 return setup_args
374
375 # If we're building a binary Windows installer, a few extra flags are
376 # needed. Script to be run by the installer after the default setup
377 # routine, to add shortcuts and similar windows-only things. Windows
378 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
379 # doesn't find them.
380 if len(sys.argv) > 2 and \
381 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
382 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
383 sys.exit(1)
384 setup_args['scripts'] = [os.path.join('scripts',
385 'ipython_win_post_install.py')]
386 setup_args['options'] = {"bdist_wininst":
387 {"install_script":
388 "ipython_win_post_install.py"}}
389 return setup_args
General Comments 0
You need to be logged in to leave comments. Login now