##// END OF EJS Templates
add terminado as [notebook] dep on non-Windows
Min RK -
Show More
@@ -1,338 +1,341 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.rst, distributed with this software.
18 18 #-----------------------------------------------------------------------------
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Minimal Python version sanity check
22 22 #-----------------------------------------------------------------------------
23 23 from __future__ import print_function
24 24
25 25 import sys
26 26
27 27 # This check is also made in IPython/__init__, don't forget to update both when
28 28 # changing Python version requirements.
29 29 v = sys.version_info
30 30 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
31 31 error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
32 32 print(error, file=sys.stderr)
33 33 sys.exit(1)
34 34
35 35 PY3 = (sys.version_info[0] >= 3)
36 36
37 37 # At least we're on the python version we need, move on.
38 38
39 39 #-------------------------------------------------------------------------------
40 40 # Imports
41 41 #-------------------------------------------------------------------------------
42 42
43 43 # Stdlib imports
44 44 import os
45 45 import shutil
46 46
47 47 from glob import glob
48 48
49 49 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
50 50 # update it when the contents of directories change.
51 51 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
52 52
53 53 from distutils.core import setup
54 54
55 55 # Our own imports
56 56 from setupbase import target_update
57 57
58 58 from setupbase import (
59 59 setup_args,
60 60 find_packages,
61 61 find_package_data,
62 62 check_package_data_first,
63 63 find_entry_points,
64 64 build_scripts_entrypt,
65 65 find_data_files,
66 66 check_for_dependencies,
67 67 git_prebuild,
68 68 check_submodule_status,
69 69 update_submodules,
70 70 require_submodules,
71 71 UpdateSubmodules,
72 72 get_bdist_wheel,
73 73 CompileCSS,
74 74 JavascriptVersion,
75 75 css_js_prerelease,
76 76 install_symlinked,
77 77 install_lib_symlink,
78 78 install_scripts_for_symlink,
79 79 unsymlink,
80 80 )
81 81 from setupext import setupext
82 82
83 83 isfile = os.path.isfile
84 84 pjoin = os.path.join
85 85
86 86 #-------------------------------------------------------------------------------
87 87 # Handle OS specific things
88 88 #-------------------------------------------------------------------------------
89 89
90 90 if os.name in ('nt','dos'):
91 91 os_name = 'windows'
92 92 else:
93 93 os_name = os.name
94 94
95 95 # Under Windows, 'sdist' has not been supported. Now that the docs build with
96 96 # Sphinx it might work, but let's not turn it on until someone confirms that it
97 97 # actually works.
98 98 if os_name == 'windows' and 'sdist' in sys.argv:
99 99 print('The sdist command is not available under Windows. Exiting.')
100 100 sys.exit(1)
101 101
102 102 #-------------------------------------------------------------------------------
103 103 # Make sure we aren't trying to run without submodules
104 104 #-------------------------------------------------------------------------------
105 105 here = os.path.abspath(os.path.dirname(__file__))
106 106
107 107 def require_clean_submodules():
108 108 """Check on git submodules before distutils can do anything
109 109
110 110 Since distutils cannot be trusted to update the tree
111 111 after everything has been set in motion,
112 112 this is not a distutils command.
113 113 """
114 114 # PACKAGERS: Add a return here to skip checks for git submodules
115 115
116 116 # don't do anything if nothing is actually supposed to happen
117 117 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
118 118 if do_nothing in sys.argv:
119 119 return
120 120
121 121 status = check_submodule_status(here)
122 122
123 123 if status == "missing":
124 124 print("checking out submodules for the first time")
125 125 update_submodules(here)
126 126 elif status == "unclean":
127 127 print('\n'.join([
128 128 "Cannot build / install IPython with unclean submodules",
129 129 "Please update submodules with",
130 130 " python setup.py submodule",
131 131 "or",
132 132 " git submodule update",
133 133 "or commit any submodule changes you have made."
134 134 ]))
135 135 sys.exit(1)
136 136
137 137 require_clean_submodules()
138 138
139 139 #-------------------------------------------------------------------------------
140 140 # Things related to the IPython documentation
141 141 #-------------------------------------------------------------------------------
142 142
143 143 # update the manuals when building a source dist
144 144 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
145 145
146 146 # List of things to be updated. Each entry is a triplet of args for
147 147 # target_update()
148 148 to_update = [
149 149 # FIXME - Disabled for now: we need to redo an automatic way
150 150 # of generating the magic info inside the rst.
151 151 #('docs/magic.tex',
152 152 #['IPython/Magic.py'],
153 153 #"cd doc && ./update_magic.sh" ),
154 154
155 155 ('docs/man/ipcluster.1.gz',
156 156 ['docs/man/ipcluster.1'],
157 157 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
158 158
159 159 ('docs/man/ipcontroller.1.gz',
160 160 ['docs/man/ipcontroller.1'],
161 161 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
162 162
163 163 ('docs/man/ipengine.1.gz',
164 164 ['docs/man/ipengine.1'],
165 165 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
166 166
167 167 ('docs/man/ipython.1.gz',
168 168 ['docs/man/ipython.1'],
169 169 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
170 170
171 171 ]
172 172
173 173
174 174 [ target_update(*t) for t in to_update ]
175 175
176 176 #---------------------------------------------------------------------------
177 177 # Find all the packages, package data, and data_files
178 178 #---------------------------------------------------------------------------
179 179
180 180 packages = find_packages()
181 181 package_data = find_package_data()
182 182
183 183 data_files = find_data_files()
184 184
185 185 setup_args['packages'] = packages
186 186 setup_args['package_data'] = package_data
187 187 setup_args['data_files'] = data_files
188 188
189 189 #---------------------------------------------------------------------------
190 190 # custom distutils commands
191 191 #---------------------------------------------------------------------------
192 192 # imports here, so they are after setuptools import if there was one
193 193 from distutils.command.sdist import sdist
194 194 from distutils.command.upload import upload
195 195
196 196 class UploadWindowsInstallers(upload):
197 197
198 198 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
199 199 user_options = upload.user_options + [
200 200 ('files=', 'f', 'exe file (or glob) to upload')
201 201 ]
202 202 def initialize_options(self):
203 203 upload.initialize_options(self)
204 204 meta = self.distribution.metadata
205 205 base = '{name}-{version}'.format(
206 206 name=meta.get_name(),
207 207 version=meta.get_version()
208 208 )
209 209 self.files = os.path.join('dist', '%s.*.exe' % base)
210 210
211 211 def run(self):
212 212 for dist_file in glob(self.files):
213 213 self.upload_file('bdist_wininst', 'any', dist_file)
214 214
215 215 setup_args['cmdclass'] = {
216 216 'build_py': css_js_prerelease(
217 217 check_package_data_first(git_prebuild('IPython'))),
218 218 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)),
219 219 'upload_wininst' : UploadWindowsInstallers,
220 220 'submodule' : UpdateSubmodules,
221 221 'css' : CompileCSS,
222 222 'symlink': install_symlinked,
223 223 'install_lib_symlink': install_lib_symlink,
224 224 'install_scripts_sym': install_scripts_for_symlink,
225 225 'unsymlink': unsymlink,
226 226 'jsversion' : JavascriptVersion,
227 227 }
228 228
229 229 #---------------------------------------------------------------------------
230 230 # Handle scripts, dependencies, and setuptools specific things
231 231 #---------------------------------------------------------------------------
232 232
233 233 # For some commands, use setuptools. Note that we do NOT list install here!
234 234 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
235 235 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
236 236 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
237 237 'egg_info', 'easy_install', 'upload', 'install_egg_info',
238 238 ))
239 239
240 240 if len(needs_setuptools.intersection(sys.argv)) > 0:
241 241 import setuptools
242 242
243 243 # This dict is used for passing extra arguments that are setuptools
244 244 # specific to setup
245 245 setuptools_extra_args = {}
246 246
247 247 # setuptools requirements
248 248
249 249 extras_require = dict(
250 250 parallel = ['pyzmq>=2.1.11'],
251 251 qtconsole = ['pyzmq>=2.1.11', 'pygments'],
252 252 zmq = ['pyzmq>=2.1.11'],
253 253 doc = ['Sphinx>=1.1', 'numpydoc'],
254 254 test = ['nose>=0.10.1', 'requests'],
255 255 terminal = [],
256 256 nbformat = ['jsonschema>=2.0'],
257 257 notebook = ['tornado>=4.0', 'pyzmq>=2.1.11', 'jinja2', 'pygments', 'mistune>=0.5'],
258 258 nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1']
259 259 )
260 260
261 if not sys.platform.startswith('win'):
262 extras_require['notebook'].append('terminado>=0.3.3')
263
261 264 if sys.version_info < (3, 3):
262 265 extras_require['test'].append('mock')
263 266
264 267 extras_require['notebook'].extend(extras_require['nbformat'])
265 268 extras_require['nbconvert'].extend(extras_require['nbformat'])
266 269
267 270 install_requires = []
268 271
269 272 # add readline
270 273 if sys.platform == 'darwin':
271 274 if 'bdist_wheel' in sys.argv[1:] or not setupext.check_for_readline():
272 275 install_requires.append('gnureadline')
273 276 elif sys.platform.startswith('win'):
274 277 extras_require['terminal'].append('pyreadline>=2.0')
275 278
276 279 everything = set()
277 280 for deps in extras_require.values():
278 281 everything.update(deps)
279 282 extras_require['all'] = everything
280 283
281 284 if 'setuptools' in sys.modules:
282 285 # setup.py develop should check for submodules
283 286 from setuptools.command.develop import develop
284 287 setup_args['cmdclass']['develop'] = require_submodules(develop)
285 288 setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
286 289
287 290 setuptools_extra_args['zip_safe'] = False
288 291 setuptools_extra_args['entry_points'] = {
289 292 'console_scripts': find_entry_points(),
290 293 'pygments.lexers': [
291 294 'ipythonconsole = IPython.nbconvert.utils.lexers:IPythonConsoleLexer',
292 295 'ipython = IPython.nbconvert.utils.lexers:IPythonLexer',
293 296 'ipython3 = IPython.nbconvert.utils.lexers:IPython3Lexer',
294 297 ],
295 298 }
296 299 setup_args['extras_require'] = extras_require
297 300 requires = setup_args['install_requires'] = install_requires
298 301
299 302 # Script to be run by the windows binary installer after the default setup
300 303 # routine, to add shortcuts and similar windows-only things. Windows
301 304 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
302 305 # doesn't find them.
303 306 if 'bdist_wininst' in sys.argv:
304 307 if len(sys.argv) > 2 and \
305 308 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
306 309 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
307 310 sys.exit(1)
308 311 setup_args['data_files'].append(
309 312 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
310 313 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
311 314 setup_args['options'] = {"bdist_wininst":
312 315 {"install_script":
313 316 "ipython_win_post_install.py"}}
314 317
315 318 else:
316 319 # If we are installing without setuptools, call this function which will
317 320 # check for dependencies an inform the user what is needed. This is
318 321 # just to make life easy for users.
319 322 for install_cmd in ('install', 'symlink'):
320 323 if install_cmd in sys.argv:
321 324 check_for_dependencies()
322 325 break
323 326 # scripts has to be a non-empty list, or install_scripts isn't called
324 327 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
325 328
326 329 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
327 330
328 331 #---------------------------------------------------------------------------
329 332 # Do the actual setup now
330 333 #---------------------------------------------------------------------------
331 334
332 335 setup_args.update(setuptools_extra_args)
333 336
334 337 def main():
335 338 setup(**setup_args)
336 339
337 340 if __name__ == '__main__':
338 341 main()
General Comments 0
You need to be logged in to leave comments. Login now