##// END OF EJS Templates
Merge pull request #4846 from takluyver/irunner-vestiges...
Paul Ivanov -
r14710:0622e829 merge
parent child Browse files
Show More
@@ -1,449 +1,433 b''
1 1 IPython requires Python 2.7 or ≥ 3.3.
2 2
3 3 .. note::
4 4
5 5 If you need to use Python 2.6 or 3.2, you can find IPython 1.0
6 6 `here <http://archive.ipython.org/release/>`__.
7 7
8 8 Quickstart
9 9 ==========
10 10
11 11 If you have :mod:`setuptools`,
12 12 the quickest way to get up and running with IPython is:
13 13
14 14 .. code-block:: bash
15 15
16 16 $ easy_install ipython[all]
17 17
18 18 This will download and install IPython and its main optional dependencies:
19 19
20 20 - jinja2, needed for the notebook
21 21 - sphinx, needed for nbconvert
22 22 - pyzmq, needed for IPython's parallel computing features, qt console and
23 23 notebook
24 24 - pygments, used by nbconvert and the Qt console for syntax highlighting
25 25 - tornado, needed by the web-based notebook
26 26 - nose, used by the test suite
27 27 - readline (on OS X) or pyreadline (on Windows), needed for the terminal
28 28
29 29 To run IPython's test suite, use the :command:`iptest` command:
30 30
31 31 .. code-block:: bash
32 32
33 33 $ iptest
34 34
35 35 .. note::
36 36
37 37 .. code-block:: bash
38 38
39 39 $ pip install ipython[all]
40 40
41 41 will also work in many cases, but it will ignore the binary eggs
42 42 of packages such as pyzmq and readline,
43 43 which may be required for some users on Windows or OS X.
44 44
45 45
46 46 Overview
47 47 ========
48 48
49 49 This document describes in detail the steps required to install IPython,
50 50 and its various optional dependencies.
51 51 For a few quick ways to get started with package managers or full Python distributions,
52 52 see `the install page <http://ipython.org/install.html>`_ of the IPython website.
53 53
54 54 IPython is organized into a number of subpackages, each of which has its own dependencies.
55 55 All of the subpackages come with IPython, so you don't need to download and
56 56 install them separately. However, to use a given subpackage, you will need to
57 57 install all of its dependencies.
58 58
59 59 Please let us know if you have problems installing IPython or any of its dependencies.
60 60
61 61 IPython and most dependencies can be installed via :command:`easy_install`,
62 62 provided by the :mod:`setuptools` package, or :command:`pip`.
63 63 In many scenarios, this is the most simplest method of installing Python packages.
64 64 More information about :mod:`setuptools` can be found on
65 65 `its PyPI page <http://pypi.python.org/pypi/setuptools>`__.
66 66
67 67 .. note::
68 68
69 69 On Windows, IPython *requires* :mod:`setuptools`. We hope to
70 70 change this in the future, but for now on Windows, you *must* install
71 71 :mod:`setuptools` to use IPython.
72 72
73 73 More general information about installing Python packages can be found in
74 74 `Python's documentation <http://docs.python.org>`_.
75 75
76 76
77 77 Installing IPython itself
78 78 =========================
79 79
80 80 Given a properly built Python, the basic interactive IPython shell will work
81 81 with no external dependencies. However, some Python distributions
82 82 (particularly on Windows and OS X), don't come with a working :mod:`readline`
83 83 module. The IPython shell will work without :mod:`readline`, but will lack
84 84 many features that users depend on, such as tab completion and command line
85 85 editing. If you install IPython with :mod:`setuptools`, (e.g. with
86 86 `easy_install`), then the appropriate :mod:`readline` for your platform will be
87 87 installed. See below for details of how to make sure you have a working
88 88 :mod:`readline`.
89 89
90 90 Installation using easy_install or pip
91 91 --------------------------------------
92 92
93 93 If you have :mod:`setuptools` or :mod:`pip`, the easiest way of getting IPython is
94 94 to simply use :command:`easy_install` or :command:`pip`:
95 95
96 96 .. code-block:: bash
97 97
98 98 $ pip install ipython
99 99
100 100 That's it.
101 101
102 102 .. note::
103 103
104 104 Many prefer :command:`pip` to :command:`easy_install`, but it ignores eggs (binary Python packages).
105 105 This mainly affects pyzmq and readline, which are compiled packages and provide
106 106 binary eggs. If you use :command:`pip` to install these packages,
107 107 it will always compile from source, which may not succeed.
108 108
109 109 Installation from source
110 110 ------------------------
111 111
112 112 If you don't want to use :command:`easy_install`, or don't have it installed,
113 113 just grab the latest stable build of IPython from `here
114 114 <http://ipython.org/download.html>`_. Then do the following:
115 115
116 116 .. code-block:: bash
117 117
118 118 $ tar -xzf ipython.tar.gz
119 119 $ cd ipython
120 120 $ python setup.py install
121 121
122 122 If you are installing to a location (like ``/usr/local``) that requires higher
123 123 permissions, you may need to run the last command with :command:`sudo`.
124 124
125 125 Windows
126 126 -------
127 127
128 128 As mentioned above, on Windows, IPython requires :mod:`setuptools`, and it also
129 129 requires the PyReadline library to properly support coloring and keyboard
130 130 management (features that the default windows console doesn't have). So on
131 131 Windows, the installation procedure is:
132 132
133 133 1. Install `setuptools <http://pypi.python.org/pypi/setuptools>`_.
134 134
135 135 2. Install `pyreadline <http://pypi.python.org/pypi/pyreadline>`_. You can use
136 136 the command ``easy_install pyreadline`` from a terminal, or the binary
137 137 installer appropriate for your platform from the PyPI page.
138 138
139 139 3. Install IPython itself, which you can download from `PyPI
140 140 <http://pypi.python.org/pypi/ipython>`_ or from `our site
141 141 <http://ipython.org/download.html>`_. Note that on Windows 7, you *must*
142 142 right-click and 'Run as administrator' for the Start menu shortcuts to be
143 143 created.
144 144
145 145 IPython by default runs in a terminal window, but the normal terminal
146 146 application supplied by Microsoft Windows is very primitive. You may want to
147 147 download the excellent and free Console_ application instead, which is a far
148 148 superior tool. You can even configure Console to give you by default an
149 149 IPython tab, which is very convenient to create new IPython sessions directly
150 150 from the working terminal.
151 151
152 152 .. _Console: http://sourceforge.net/projects/console
153 153
154 154
155 155 Installing the development version
156 156 ----------------------------------
157 157
158 158 It is also possible to install the development version of IPython from our
159 159 `Git <http://git-scm.com/>`_ source code repository. To do this you will
160 160 need to have Git installed on your system. Then just do:
161 161
162 162 .. code-block:: bash
163 163
164 164 $ git clone --recursive https://github.com/ipython/ipython.git
165 165 $ cd ipython
166 166 $ python setup.py install
167 167
168 168 Some users want to be able to follow the development branch as it changes. If
169 169 you have :mod:`setuptools` installed, this is easy. Simply replace the last
170 170 step by:
171 171
172 172 .. code-block:: bash
173 173
174 174 $ python setupegg.py develop
175 175
176 176 This creates links in the right places and installs the command line script to
177 177 the appropriate places. Then, if you want to update your IPython at any time,
178 178 just do:
179 179
180 180 .. code-block:: bash
181 181
182 182 $ git pull
183 183
184 184
185 185 Basic optional dependencies
186 186 ===========================
187 187
188 188 There are a number of basic optional dependencies that most users will want to
189 189 get. These are:
190 190
191 191 * readline (for command line editing, tab completion, etc.)
192 192 * nose (to run the IPython test suite)
193 * pexpect (to use things like irunner)
194 193
195 194 If you are comfortable installing these things yourself, have at it, otherwise
196 195 read on for more details.
197 196
197 IPython uses several other modules, such as pexpect_ and path.py, if they are
198 installed on your system, but it can also use bundled versions from
199 :mod:`IPython.external`, so there's no need to install them separately.
200
198 201 readline
199 202 --------
200 203
201 204 As indicated above, on Windows, to get full functionality in the console
202 205 version of IPython, PyReadline is needed.
203 206 PyReadline is a separate, Windows only implementation of readline that uses
204 207 native Windows calls through :mod:`ctypes`. The easiest way of installing
205 208 PyReadline is you use the binary installer available `here
206 209 <http://pypi.python.org/pypi/pyreadline>`__.
207 210
208 211 On OSX, if you are using the built-in Python shipped by Apple, you will be
209 212 missing a full readline implementation as Apple ships instead a library called
210 213 ``libedit`` that provides only some of readline's functionality. While you may
211 214 find libedit sufficient, we have occasional reports of bugs with it and several
212 215 developers who use OS X as their main environment consider libedit unacceptable
213 216 for productive, regular use with IPython.
214 217
215 218 Therefore, we *strongly* recommend that on OS X you get the full
216 219 :mod:`readline` module. We will *not* consider completion/history problems to
217 220 be bugs for IPython if you are using libedit.
218 221
219 222 To get a working :mod:`readline` module, just do (with :mod:`setuptools`
220 223 installed):
221 224
222 225 .. code-block:: bash
223 226
224 227 $ easy_install readline
225 228
226 229 .. note::
227 230
228 231 Other Python distributions on OS X (such as fink, MacPorts and the official
229 232 python.org binaries) already have readline installed so you likely don't
230 233 have to do this step.
231 234
232 235 When IPython is installed with :mod:`setuptools`, (e.g. using the
233 236 ``easy_install`` command), readline is added as a dependency on OS X, and
234 237 PyReadline on Windows, and will be installed on your system. However, if you
235 238 do not use setuptools, you may have to install one of these packages yourself.
236 239
237 240
238 241 nose
239 242 ----
240 243
241 244 To run the IPython test suite you will need the :mod:`nose` package. Nose
242 245 provides a great way of sniffing out and running all of the IPython tests. The
243 246 simplest way of getting nose is to use :command:`easy_install` or :command:`pip`:
244 247
245 248 .. code-block:: bash
246 249
247 250 $ pip install nose
248 251
249 252 Another way of getting this is to do:
250 253
251 254 .. code-block:: bash
252 255
253 256 $ pip install ipython[test]
254 257
255 258 For more installation options, see the `nose website
256 259 <http://somethingaboutorange.com/mrl/projects/nose/>`_.
257 260
258 261 Once you have nose installed, you can run IPython's test suite using the
259 262 iptest command:
260 263
261 264 .. code-block:: bash
262 265
263 266 $ iptest
264 267
265 pexpect
266 -------
267
268 The pexpect_ package is used in IPython's :command:`irunner` script, as well as
269 for managing subprocesses. IPython now includes a version of pexpect in
270 :mod:`IPython.external`, but if you have installed pexpect, IPython will use
271 that instead. On Unix platforms (including OS X), just do:
272
273 .. code-block:: bash
274
275 $ pip install pexpect
276
277 .. note::
278
279 On Python 3, you should actually install :mod:`pexpect-u`,
280 a unicode-safe fork of pexpect.
281
282 Windows users are out of luck as pexpect does not run there.
283
284 268 Dependencies for IPython.parallel (parallel computing)
285 269 ======================================================
286 270
287 271 IPython.parallel provides a nice architecture for parallel computing, with a
288 272 focus on fluid interactive workflows. These features require just one package:
289 273 PyZMQ. See the next section for PyZMQ details.
290 274
291 275 On a Unix style platform (including OS X), if you want to use
292 276 :mod:`setuptools`, you can just do:
293 277
294 278 .. code-block:: bash
295 279
296 280 $ easy_install ipython[zmq] # will include pyzmq
297 281
298 282 Security in IPython.parallel is provided by SSH tunnels. By default, Linux
299 283 and OSX clients will use the shell ssh command, but on Windows, we also
300 284 support tunneling with paramiko_.
301 285
302 286 Dependencies for IPython.kernel.zmq
303 287 ===================================
304 288
305 289 pyzmq
306 290 -----
307 291
308 292 IPython 0.11 introduced some new functionality, including a two-process
309 293 execution model using ZeroMQ_ for communication. The Python bindings to ZeroMQ
310 294 are found in the PyZMQ_ project, which is easy_install-able once you have
311 295 ZeroMQ installed. If you are on Python 2.6 or 2.7 on OSX, or 2.7 on Windows,
312 296 pyzmq has eggs that include ZeroMQ itself.
313 297
314 298 IPython.kernel.zmq depends on pyzmq >= 2.1.4.
315 299
316 300 Dependencies for the IPython QT console
317 301 =======================================
318 302
319 303 pyzmq
320 304 -----
321 305
322 306 Like the :mod:`IPython.parallel` package, the QT Console requires ZeroMQ and
323 307 PyZMQ.
324 308
325 309 Qt
326 310 --
327 311
328 312 Also with 0.11, a new GUI was added using the work in :mod:`IPython.kernel.zmq`, which
329 313 can be launched with ``ipython qtconsole``. The GUI is built on Qt, and works
330 314 with either PyQt, which can be installed from the `PyQt website
331 315 <http://www.riverbankcomputing.co.uk/>`_, or `PySide
332 316 <http://www.pyside.org/>`_, from Nokia.
333 317
334 318 pygments
335 319 --------
336 320
337 321 The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_
338 322 project, which is easy_install-able.
339 323
340 324 .. _installnotebook:
341 325
342 326 Dependencies for the IPython HTML notebook
343 327 ==========================================
344 328
345 329 The IPython notebook is a notebook-style web interface to IPython and can be
346 330 started with the command ``ipython notebook``.
347 331
348 332 pyzmq
349 333 -----
350 334
351 335 Like the :mod:`IPython.parallel` and :mod:`IPython.frontend.qt.console`
352 336 packages, the HTML notebook requires ZeroMQ and PyZMQ.
353 337
354 338 Tornado
355 339 -------
356 340
357 341 The IPython notebook uses the Tornado_ project for its HTTP server. Tornado 2.1
358 342 is required, in order to support current versions of browsers, due to an update
359 343 to the websocket protocol.
360 344
361 345 Jinja
362 346 -----
363 347
364 348 The IPython notebook uses the Jinja_ templating tool to render HTML pages.
365 349
366 350
367 351 MathJax
368 352 -------
369 353
370 354 The IPython notebook uses the MathJax_ Javascript library for rendering LaTeX
371 355 in web browsers. Because MathJax is large, we don't include it with
372 356 IPython. Normally IPython will load MathJax from a CDN, but if you have a slow
373 357 network connection, or want to use LaTeX without an internet connection at all,
374 358 you can install MathJax locally.
375 359
376 360 A quick and easy method is to install it from a python session::
377 361
378 362 from IPython.external.mathjax import install_mathjax
379 363 install_mathjax()
380 364
381 365 If you need tighter configuration control, you can download your own copy
382 366 of MathJax from http://www.mathjax.org/download/ - use the MathJax-2.0 link.
383 367 When you have the file stored locally, install it with::
384 368
385 369 python -m IPython.external.mathjax /path/to/source/mathjax-MathJax-v2.0-20-g07669ac.zip
386 370
387 371 For unusual needs, IPython can tell you what directory it wants to find MathJax in::
388 372
389 373 python -m IPython.external.mathjax -d /some/other/mathjax
390 374
391 375 By default Mathjax will be installed in your ipython profile directory, but you
392 376 can make system wide install, please refer to the documentation and helper function
393 377 of :mod:`IPython.external.mathjax`
394 378
395 379 Browser Compatibility
396 380 ---------------------
397 381
398 382 The IPython notebook is officially supported on the following browers:
399 383
400 384 * Chrome ≥ 13
401 385 * Safari ≥ 5
402 386 * Firefox ≥ 6
403 387
404 388 The is mainly due to the notebook's usage of WebSockets and the flexible box model.
405 389
406 390 The following browsers are unsupported:
407 391
408 392 * Safari < 5
409 393 * Firefox < 6
410 394 * Chrome < 13
411 395 * Opera (any): CSS issues, but execution might work
412 396 * Internet Explorer < 10
413 397
414 398 The following specific combinations are known **NOT** to work:
415 399
416 400 * Safari, IPython 0.12, tornado ≥ 2.2.0
417 401 * Safari with HTTPS connection to notebook and an untrusted certificate (websockets will fail)
418 402 * The [diigo Chrome extension](http://help.diigo.com/tools/chrome-extension) seems to interfere with scrolling
419 403
420 404 There are some early reports that the Notebook works on Internet Explorer 10, but we
421 405 expect there will be some CSS issues related to the flexible box model.
422 406
423 407
424 408 Dependencies for nbconvert (converting notebooks to various formats)
425 409 ====================================================================
426 410
427 411 pandoc
428 412 ------
429 413
430 414 The most important dependency of nbconvert is Pandoc_ 1.10 or later, a document format translation program.
431 415 This is not a Python package, so it cannot be expressed as a regular IPython dependency with setuptools.
432 416
433 417 To install pandoc on Linux, you can generally use your package manager::
434 418
435 419 sudo apt-get install pandoc
436 420
437 421 On other platforms, you can get pandoc from `their website <http://johnmacfarlane.net/pandoc/installing.html>`_.
438 422
439 423
440 424 .. _ZeroMQ: http://www.zeromq.org
441 425 .. _PyZMQ: https://github.com/zeromq/pyzmq
442 426 .. _paramiko: https://github.com/robey/paramiko
443 427 .. _pygments: http://pygments.org
444 .. _pexpect: http://www.noah.org/wiki/Pexpect
428 .. _pexpect: http://pexpect.readthedocs.org/en/latest/
445 429 .. _Jinja: http://jinja.pocoo.org
446 430 .. _Sphinx: http://sphinx-doc.org
447 431 .. _pandoc: http://johnmacfarlane.net/pandoc
448 432 .. _Tornado: http://www.tornadoweb.org
449 433 .. _MathJax: http://www.mathjax.org
@@ -1,148 +1,147 b''
1 1 #!python
2 2 """Distutils post installation script for Windows.
3 3
4 4 http://docs.python.org/2/distutils/builtdist.html#the-postinstallation-script
5 5
6 6 """
7 7
8 8 from __future__ import print_function
9 9
10 10 import os
11 11 import sys
12 12 import shutil
13 13
14 14 try:
15 15 import setuptools
16 16 have_setuptools = True
17 17 except ImportError:
18 18 have_setuptools = False
19 19
20 20
21 21 pjoin = os.path.join
22 22
23 23 # suffix for start menu folder names
24 24 pyver = "(Py%i.%i %i bit)" % (sys.version_info[0], sys.version_info[1],
25 25 (32, 64)[sys.maxsize > 2**32])
26 26
27 27
28 28 def mkshortcut(target, description, linkdir, arguments="", iconpath='',
29 29 workdir="%HOMEDRIVE%%HOMEPATH%", iconindex=0):
30 30 """Make a shortcut if it doesn't exist and register its creation."""
31 31 filename = pjoin(linkdir, description + '.lnk')
32 32 description = "%s %s" % (description, pyver)
33 33 create_shortcut(target, description, filename, arguments, workdir,
34 34 iconpath, iconindex)
35 35 file_created(filename)
36 36
37 37
38 38 def arguments(scriptsdir, script, scriptargs=''):
39 39 """Return command line arguments to be passed to the python executable."""
40 40 cmdbase = suffix(pjoin(scriptsdir, script))
41 41 if have_setuptools:
42 42 cmdbase += '-script.py'
43 43 return '"%s" %s' % (cmdbase, scriptargs)
44 44
45 45
46 46 def suffix(s):
47 47 """Add '3' suffix to programs for Python 3."""
48 48 if sys.version_info[0] == 3:
49 49 s = s + '3'
50 50 return s
51 51
52 52
53 53 def install():
54 54 """Routine to be run by the win32 installer with the -install switch."""
55 55 # Get some system constants
56 56 python = pjoin(sys.prefix, 'python.exe')
57 57 pythonw = pjoin(sys.prefix, 'pythonw.exe')
58 58
59 59 if not have_setuptools:
60 60 # This currently doesn't work without setuptools,
61 61 # so don't bother making broken links
62 62 print("Setuptools is required to"
63 63 " create Start Menu items.", file=sys.stderr)
64 64 print("Re-run this installer after installing"
65 65 " Setuptools to get Start Menu items.", file=sys.stderr)
66 66 return
67 67
68 68 # Lookup path to common startmenu ...
69 69 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
70 70 'IPython %s' % pyver)
71 71
72 72 # Create IPython entry ...
73 73 if not os.path.isdir(ip_start_menu):
74 74 os.mkdir(ip_start_menu)
75 75 directory_created(ip_start_menu)
76 76
77 77 # Create .py and .bat files to make things available from
78 78 # the Windows command line. Thanks to the Twisted project
79 79 # for this logic!
80 80 programs = [
81 81 'ipython',
82 82 'iptest',
83 83 'ipcontroller',
84 84 'ipengine',
85 85 'ipcluster',
86 'irunner',
87 86 ]
88 87 programs = [suffix(p) for p in programs]
89 88 scripts = pjoin(sys.prefix, 'scripts')
90 89 if not have_setuptools:
91 90 # only create .bat files if we don't have setuptools
92 91 for program in programs:
93 92 raw = pjoin(scripts, program)
94 93 bat = raw + '.bat'
95 94 py = raw + '.py'
96 95 # Create .py versions of the scripts
97 96 shutil.copy(raw, py)
98 97 # Create .bat files for each of the scripts
99 98 bat_file = file(bat, 'w')
100 99 bat_file.write("@%s %s %%*" % (python, py))
101 100 bat_file.close()
102 101
103 102 # Create Start Menu shortcuts
104 103 iconpath = pjoin(scripts, 'ipython.ico')
105 104 mkshortcut(python, 'IPython', ip_start_menu,
106 105 arguments(scripts, 'ipython'), iconpath)
107 106 mkshortcut(python, 'IPython (pylab mode)', ip_start_menu,
108 107 arguments(scripts, 'ipython', '--pylab'), iconpath)
109 108 mkshortcut(python, 'IPython Controller', ip_start_menu,
110 109 arguments(scripts, 'ipcontroller'), iconpath)
111 110 mkshortcut(python, 'IPython Engine', ip_start_menu,
112 111 arguments(scripts, 'ipengine'), iconpath)
113 112 mkshortcut(pythonw, 'IPython Qt Console', ip_start_menu,
114 113 arguments(scripts, 'ipython', 'qtconsole'), iconpath)
115 114
116 115 iconpath = pjoin(scripts, 'ipython_nb.ico')
117 116 mkshortcut(python, 'IPython Notebook', ip_start_menu,
118 117 arguments(scripts, 'ipython', 'notebook'), iconpath)
119 118
120 119 mkshortcut(pythonw, 'IPython Documentation', ip_start_menu,
121 120 '-m webbrowser -t "http://ipython.org/documentation.html',
122 121 iconpath='url.dll')
123 122
124 123 # Disable pysh Start item until the profile restores functionality
125 124 # Most of this code is in IPython/deathrow, and needs to be updated
126 125 # to 0.11 APIs
127 126 #mkshortcut(python, 'IPython%s (command prompt mode)', ip_start_menu,
128 127 # arguments(scripts, 'ipython', 'profile=pysh --init'))
129 128
130 129
131 130 def remove():
132 131 """Routine to be run by the win32 installer with the -remove switch."""
133 132 pass
134 133
135 134
136 135 # main()
137 136 if len(sys.argv) > 1:
138 137 if sys.argv[1] == '-install':
139 138 try:
140 139 install()
141 140 except OSError:
142 141 print("Failed to create Start Menu items, try running the"
143 142 " installer as administrator.", file=sys.stderr)
144 143 elif sys.argv[1] == '-remove':
145 144 remove()
146 145 else:
147 146 print("Script was called with option %s" % sys.argv[1],
148 147 file=sys.stderr)
@@ -1,344 +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.txt, 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 if sys.version_info[:2] < (2,7):
30 30 error = "ERROR: IPython requires Python Version 2.7 or above."
31 31 print(error, file=sys.stderr)
32 32 sys.exit(1)
33 33
34 34 PY3 = (sys.version_info[0] >= 3)
35 35
36 36 # At least we're on the python version we need, move on.
37 37
38 38 #-------------------------------------------------------------------------------
39 39 # Imports
40 40 #-------------------------------------------------------------------------------
41 41
42 42 # Stdlib imports
43 43 import os
44 44 import shutil
45 45
46 46 from glob import glob
47 47
48 48 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
49 49 # update it when the contents of directories change.
50 50 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
51 51
52 52 from distutils.core import setup
53 53
54 54 # Our own imports
55 55 from setupbase import target_update
56 56
57 57 from setupbase import (
58 58 setup_args,
59 59 find_packages,
60 60 find_package_data,
61 61 find_entry_points,
62 62 build_scripts_entrypt,
63 63 find_data_files,
64 64 check_for_dependencies,
65 65 git_prebuild,
66 66 check_submodule_status,
67 67 update_submodules,
68 68 require_submodules,
69 69 UpdateSubmodules,
70 70 CompileCSS,
71 71 JavascriptVersion,
72 72 install_symlinked,
73 73 install_lib_symlink,
74 74 install_scripts_for_symlink,
75 75 unsymlink,
76 76 )
77 77 from setupext import setupext
78 78
79 79 isfile = os.path.isfile
80 80 pjoin = os.path.join
81 81
82 82 #-----------------------------------------------------------------------------
83 83 # Function definitions
84 84 #-----------------------------------------------------------------------------
85 85
86 86 def cleanup():
87 87 """Clean up the junk left around by the build process"""
88 88 if "develop" not in sys.argv and "egg_info" not in sys.argv:
89 89 try:
90 90 shutil.rmtree('ipython.egg-info')
91 91 except:
92 92 try:
93 93 os.unlink('ipython.egg-info')
94 94 except:
95 95 pass
96 96
97 97 #-------------------------------------------------------------------------------
98 98 # Handle OS specific things
99 99 #-------------------------------------------------------------------------------
100 100
101 101 if os.name in ('nt','dos'):
102 102 os_name = 'windows'
103 103 else:
104 104 os_name = os.name
105 105
106 106 # Under Windows, 'sdist' has not been supported. Now that the docs build with
107 107 # Sphinx it might work, but let's not turn it on until someone confirms that it
108 108 # actually works.
109 109 if os_name == 'windows' and 'sdist' in sys.argv:
110 110 print('The sdist command is not available under Windows. Exiting.')
111 111 sys.exit(1)
112 112
113 113 #-------------------------------------------------------------------------------
114 114 # Make sure we aren't trying to run without submodules
115 115 #-------------------------------------------------------------------------------
116 116 here = os.path.abspath(os.path.dirname(__file__))
117 117
118 118 def require_clean_submodules():
119 119 """Check on git submodules before distutils can do anything
120 120
121 121 Since distutils cannot be trusted to update the tree
122 122 after everything has been set in motion,
123 123 this is not a distutils command.
124 124 """
125 125 # PACKAGERS: Add a return here to skip checks for git submodules
126 126
127 127 # don't do anything if nothing is actually supposed to happen
128 128 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
129 129 if do_nothing in sys.argv:
130 130 return
131 131
132 132 status = check_submodule_status(here)
133 133
134 134 if status == "missing":
135 135 print("checking out submodules for the first time")
136 136 update_submodules(here)
137 137 elif status == "unclean":
138 138 print('\n'.join([
139 139 "Cannot build / install IPython with unclean submodules",
140 140 "Please update submodules with",
141 141 " python setup.py submodule",
142 142 "or",
143 143 " git submodule update",
144 144 "or commit any submodule changes you have made."
145 145 ]))
146 146 sys.exit(1)
147 147
148 148 require_clean_submodules()
149 149
150 150 #-------------------------------------------------------------------------------
151 151 # Things related to the IPython documentation
152 152 #-------------------------------------------------------------------------------
153 153
154 154 # update the manuals when building a source dist
155 155 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
156 156
157 157 # List of things to be updated. Each entry is a triplet of args for
158 158 # target_update()
159 159 to_update = [
160 160 # FIXME - Disabled for now: we need to redo an automatic way
161 161 # of generating the magic info inside the rst.
162 162 #('docs/magic.tex',
163 163 #['IPython/Magic.py'],
164 164 #"cd doc && ./update_magic.sh" ),
165 165
166 166 ('docs/man/ipcluster.1.gz',
167 167 ['docs/man/ipcluster.1'],
168 168 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
169 169
170 170 ('docs/man/ipcontroller.1.gz',
171 171 ['docs/man/ipcontroller.1'],
172 172 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
173 173
174 174 ('docs/man/ipengine.1.gz',
175 175 ['docs/man/ipengine.1'],
176 176 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
177 177
178 178 ('docs/man/iplogger.1.gz',
179 179 ['docs/man/iplogger.1'],
180 180 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'),
181 181
182 182 ('docs/man/ipython.1.gz',
183 183 ['docs/man/ipython.1'],
184 184 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
185 185
186 ('docs/man/irunner.1.gz',
187 ['docs/man/irunner.1'],
188 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'),
189 186 ]
190 187
191 188
192 189 [ target_update(*t) for t in to_update ]
193 190
194 191 #---------------------------------------------------------------------------
195 192 # Find all the packages, package data, and data_files
196 193 #---------------------------------------------------------------------------
197 194
198 195 packages = find_packages()
199 196 package_data = find_package_data()
200 197 data_files = find_data_files()
201 198
202 199 setup_args['packages'] = packages
203 200 setup_args['package_data'] = package_data
204 201 setup_args['data_files'] = data_files
205 202
206 203 #---------------------------------------------------------------------------
207 204 # custom distutils commands
208 205 #---------------------------------------------------------------------------
209 206 # imports here, so they are after setuptools import if there was one
210 207 from distutils.command.sdist import sdist
211 208 from distutils.command.upload import upload
212 209
213 210 class UploadWindowsInstallers(upload):
214 211
215 212 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
216 213 user_options = upload.user_options + [
217 214 ('files=', 'f', 'exe file (or glob) to upload')
218 215 ]
219 216 def initialize_options(self):
220 217 upload.initialize_options(self)
221 218 meta = self.distribution.metadata
222 219 base = '{name}-{version}'.format(
223 220 name=meta.get_name(),
224 221 version=meta.get_version()
225 222 )
226 223 self.files = os.path.join('dist', '%s.*.exe' % base)
227 224
228 225 def run(self):
229 226 for dist_file in glob(self.files):
230 227 self.upload_file('bdist_wininst', 'any', dist_file)
231 228
232 229 setup_args['cmdclass'] = {
233 230 'build_py': git_prebuild('IPython'),
234 231 'sdist' : git_prebuild('IPython', sdist),
235 232 'upload_wininst' : UploadWindowsInstallers,
236 233 'submodule' : UpdateSubmodules,
237 234 'css' : CompileCSS,
238 235 'symlink': install_symlinked,
239 236 'install_lib_symlink': install_lib_symlink,
240 237 'install_scripts_sym': install_scripts_for_symlink,
241 238 'unsymlink': unsymlink,
242 239 'jsversion' : JavascriptVersion,
243 240 }
244 241
245 242 #---------------------------------------------------------------------------
246 243 # Handle scripts, dependencies, and setuptools specific things
247 244 #---------------------------------------------------------------------------
248 245
249 246 # For some commands, use setuptools. Note that we do NOT list install here!
250 247 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
251 248 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
252 249 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info',
253 250 'egg_info', 'easy_install', 'upload',
254 251 ))
255 252 if sys.platform == 'win32':
256 253 # Depend on setuptools for install on *Windows only*
257 254 # If we get script-installation working without setuptools,
258 255 # then we can back off, but until then use it.
259 256 # See Issue #369 on GitHub for more
260 257 needs_setuptools.add('install')
261 258
262 259 if len(needs_setuptools.intersection(sys.argv)) > 0:
263 260 import setuptools
264 261
265 262 # This dict is used for passing extra arguments that are setuptools
266 263 # specific to setup
267 264 setuptools_extra_args = {}
268 265
269 266 if 'setuptools' in sys.modules:
270 267 # setup.py develop should check for submodules
271 268 from setuptools.command.develop import develop
272 269 setup_args['cmdclass']['develop'] = require_submodules(develop)
273 270
274 271 setuptools_extra_args['zip_safe'] = False
275 272 setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()}
276 273 setup_args['extras_require'] = dict(
277 274 parallel = 'pyzmq>=2.1.11',
278 275 qtconsole = ['pyzmq>=2.1.11', 'pygments'],
279 276 zmq = 'pyzmq>=2.1.11',
280 277 doc = ['Sphinx>=1.1', 'numpydoc'],
281 278 test = 'nose>=0.10.1',
282 279 notebook = ['tornado>=3.1', 'pyzmq>=2.1.11', 'jinja2'],
283 280 nbconvert = ['pygments', 'jinja2', 'Sphinx>=0.3']
284 281 )
285 282 everything = set()
286 283 for deps in setup_args['extras_require'].values():
287 284 if not isinstance(deps, list):
288 285 deps = [deps]
289 286 for dep in deps:
290 287 everything.add(dep)
291 288 setup_args['extras_require']['all'] = everything
292 289
293 290 requires = setup_args.setdefault('install_requires', [])
294 291 setupext.display_status = False
295 292 if not setupext.check_for_readline():
296 293 if sys.platform == 'darwin':
297 294 requires.append('readline')
298 295 elif sys.platform.startswith('win'):
299 296 # Pyreadline 64 bit windows issue solved in versions >=1.7.1
300 297 # Also solves issues with some older versions of pyreadline that
301 298 # satisfy the unconstrained depdendency.
302 299 requires.append('pyreadline>=1.7.1')
303 300 else:
304 301 pass
305 302 # do we want to install readline here?
306 303
307 304 # Script to be run by the windows binary installer after the default setup
308 305 # routine, to add shortcuts and similar windows-only things. Windows
309 306 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
310 307 # doesn't find them.
311 308 if 'bdist_wininst' in sys.argv:
312 309 if len(sys.argv) > 2 and \
313 310 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
314 311 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
315 312 sys.exit(1)
316 313 setup_args['data_files'].append(
317 314 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
318 315 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
319 316 setup_args['options'] = {"bdist_wininst":
320 317 {"install_script":
321 318 "ipython_win_post_install.py"}}
322 319
323 320 else:
324 321 # If we are running without setuptools, call this function which will
325 322 # check for dependencies an inform the user what is needed. This is
326 323 # just to make life easy for users.
327 324 check_for_dependencies()
328 325 # scripts has to be a non-empty list, or install_scripts isn't called
329 326 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
330 327
331 328 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
332 329
333 330 #---------------------------------------------------------------------------
334 331 # Do the actual setup now
335 332 #---------------------------------------------------------------------------
336 333
337 334 setup_args.update(setuptools_extra_args)
338 335
339 336 def main():
340 337 setup(**setup_args)
341 338 cleanup()
342 339
343 340 if __name__ == '__main__':
344 341 main()
General Comments 0
You need to be logged in to leave comments. Login now