##// END OF EJS Templates
More changes to indicate Python 3 requirement
Thomas Kluyver -
Show More
@@ -1,146 +1,146 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 IPython: tools for interactive and parallel computing in Python.
3 IPython: tools for interactive and parallel computing in Python.
4
4
5 http://ipython.org
5 http://ipython.org
6 """
6 """
7 #-----------------------------------------------------------------------------
7 #-----------------------------------------------------------------------------
8 # Copyright (c) 2008-2011, IPython Development Team.
8 # Copyright (c) 2008-2011, IPython Development Team.
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
12 #
12 #
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14 #
14 #
15 # The full license is in the file COPYING.txt, distributed with this software.
15 # The full license is in the file COPYING.txt, distributed with this software.
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19 # Imports
19 # Imports
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 from __future__ import absolute_import
21 from __future__ import absolute_import
22
22
23 import os
23 import os
24 import sys
24 import sys
25 import warnings
25 import warnings
26
26
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28 # Setup everything
28 # Setup everything
29 #-----------------------------------------------------------------------------
29 #-----------------------------------------------------------------------------
30
30
31 # Don't forget to also update setup.py when this changes!
31 # Don't forget to also update setup.py when this changes!
32 v = sys.version_info
32 v = sys.version_info
33 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
33 if v[:2] < (3,3):
34 raise ImportError('IPython requires Python version 2.7 or 3.3 or above.')
34 raise ImportError('IPython requires Python version 3.3 or above.')
35 del v
35 del v
36
36
37 # Make it easy to import extensions - they are always directly on pythonpath.
37 # Make it easy to import extensions - they are always directly on pythonpath.
38 # Therefore, non-IPython modules can be added to extensions directory.
38 # Therefore, non-IPython modules can be added to extensions directory.
39 # This should probably be in ipapp.py.
39 # This should probably be in ipapp.py.
40 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
40 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
41
41
42 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
43 # Setup the top level names
43 # Setup the top level names
44 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
45
45
46 from .core.getipython import get_ipython
46 from .core.getipython import get_ipython
47 from .core import release
47 from .core import release
48 from .core.application import Application
48 from .core.application import Application
49 from .terminal.embed import embed
49 from .terminal.embed import embed
50
50
51 from .core.interactiveshell import InteractiveShell
51 from .core.interactiveshell import InteractiveShell
52 from .testing import test
52 from .testing import test
53 from .utils.sysinfo import sys_info
53 from .utils.sysinfo import sys_info
54 from .utils.frame import extract_module_locals
54 from .utils.frame import extract_module_locals
55
55
56 # Release data
56 # Release data
57 __author__ = '%s <%s>' % (release.author, release.author_email)
57 __author__ = '%s <%s>' % (release.author, release.author_email)
58 __license__ = release.license
58 __license__ = release.license
59 __version__ = release.version
59 __version__ = release.version
60 version_info = release.version_info
60 version_info = release.version_info
61
61
62 def embed_kernel(module=None, local_ns=None, **kwargs):
62 def embed_kernel(module=None, local_ns=None, **kwargs):
63 """Embed and start an IPython kernel in a given scope.
63 """Embed and start an IPython kernel in a given scope.
64
64
65 If you don't want the kernel to initialize the namespace
65 If you don't want the kernel to initialize the namespace
66 from the scope of the surrounding function,
66 from the scope of the surrounding function,
67 and/or you want to load full IPython configuration,
67 and/or you want to load full IPython configuration,
68 you probably want `IPython.start_kernel()` instead.
68 you probably want `IPython.start_kernel()` instead.
69
69
70 Parameters
70 Parameters
71 ----------
71 ----------
72 module : ModuleType, optional
72 module : ModuleType, optional
73 The module to load into IPython globals (default: caller)
73 The module to load into IPython globals (default: caller)
74 local_ns : dict, optional
74 local_ns : dict, optional
75 The namespace to load into IPython user namespace (default: caller)
75 The namespace to load into IPython user namespace (default: caller)
76
76
77 kwargs : various, optional
77 kwargs : various, optional
78 Further keyword args are relayed to the IPKernelApp constructor,
78 Further keyword args are relayed to the IPKernelApp constructor,
79 allowing configuration of the Kernel. Will only have an effect
79 allowing configuration of the Kernel. Will only have an effect
80 on the first embed_kernel call for a given process.
80 on the first embed_kernel call for a given process.
81 """
81 """
82
82
83 (caller_module, caller_locals) = extract_module_locals(1)
83 (caller_module, caller_locals) = extract_module_locals(1)
84 if module is None:
84 if module is None:
85 module = caller_module
85 module = caller_module
86 if local_ns is None:
86 if local_ns is None:
87 local_ns = caller_locals
87 local_ns = caller_locals
88
88
89 # Only import .zmq when we really need it
89 # Only import .zmq when we really need it
90 from ipykernel.embed import embed_kernel as real_embed_kernel
90 from ipykernel.embed import embed_kernel as real_embed_kernel
91 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
91 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
92
92
93 def start_ipython(argv=None, **kwargs):
93 def start_ipython(argv=None, **kwargs):
94 """Launch a normal IPython instance (as opposed to embedded)
94 """Launch a normal IPython instance (as opposed to embedded)
95
95
96 `IPython.embed()` puts a shell in a particular calling scope,
96 `IPython.embed()` puts a shell in a particular calling scope,
97 such as a function or method for debugging purposes,
97 such as a function or method for debugging purposes,
98 which is often not desirable.
98 which is often not desirable.
99
99
100 `start_ipython()` does full, regular IPython initialization,
100 `start_ipython()` does full, regular IPython initialization,
101 including loading startup files, configuration, etc.
101 including loading startup files, configuration, etc.
102 much of which is skipped by `embed()`.
102 much of which is skipped by `embed()`.
103
103
104 This is a public API method, and will survive implementation changes.
104 This is a public API method, and will survive implementation changes.
105
105
106 Parameters
106 Parameters
107 ----------
107 ----------
108
108
109 argv : list or None, optional
109 argv : list or None, optional
110 If unspecified or None, IPython will parse command-line options from sys.argv.
110 If unspecified or None, IPython will parse command-line options from sys.argv.
111 To prevent any command-line parsing, pass an empty list: `argv=[]`.
111 To prevent any command-line parsing, pass an empty list: `argv=[]`.
112 user_ns : dict, optional
112 user_ns : dict, optional
113 specify this dictionary to initialize the IPython user namespace with particular values.
113 specify this dictionary to initialize the IPython user namespace with particular values.
114 kwargs : various, optional
114 kwargs : various, optional
115 Any other kwargs will be passed to the Application constructor,
115 Any other kwargs will be passed to the Application constructor,
116 such as `config`.
116 such as `config`.
117 """
117 """
118 from IPython.terminal.ipapp import launch_new_instance
118 from IPython.terminal.ipapp import launch_new_instance
119 return launch_new_instance(argv=argv, **kwargs)
119 return launch_new_instance(argv=argv, **kwargs)
120
120
121 def start_kernel(argv=None, **kwargs):
121 def start_kernel(argv=None, **kwargs):
122 """Launch a normal IPython kernel instance (as opposed to embedded)
122 """Launch a normal IPython kernel instance (as opposed to embedded)
123
123
124 `IPython.embed_kernel()` puts a shell in a particular calling scope,
124 `IPython.embed_kernel()` puts a shell in a particular calling scope,
125 such as a function or method for debugging purposes,
125 such as a function or method for debugging purposes,
126 which is often not desirable.
126 which is often not desirable.
127
127
128 `start_kernel()` does full, regular IPython initialization,
128 `start_kernel()` does full, regular IPython initialization,
129 including loading startup files, configuration, etc.
129 including loading startup files, configuration, etc.
130 much of which is skipped by `embed()`.
130 much of which is skipped by `embed()`.
131
131
132 Parameters
132 Parameters
133 ----------
133 ----------
134
134
135 argv : list or None, optional
135 argv : list or None, optional
136 If unspecified or None, IPython will parse command-line options from sys.argv.
136 If unspecified or None, IPython will parse command-line options from sys.argv.
137 To prevent any command-line parsing, pass an empty list: `argv=[]`.
137 To prevent any command-line parsing, pass an empty list: `argv=[]`.
138 user_ns : dict, optional
138 user_ns : dict, optional
139 specify this dictionary to initialize the IPython user namespace with particular values.
139 specify this dictionary to initialize the IPython user namespace with particular values.
140 kwargs : various, optional
140 kwargs : various, optional
141 Any other kwargs will be passed to the Application constructor,
141 Any other kwargs will be passed to the Application constructor,
142 such as `config`.
142 such as `config`.
143 """
143 """
144 from IPython.kernel.zmq.kernelapp import launch_new_instance
144 from IPython.kernel.zmq.kernelapp import launch_new_instance
145 return launch_new_instance(argv=argv, **kwargs)
145 return launch_new_instance(argv=argv, **kwargs)
146
146
@@ -1,51 +1,51 b''
1 .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=master
1 .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=master
2 :target: https://codecov.io/github/ipython/ipython?branch=master
2 :target: https://codecov.io/github/ipython/ipython?branch=master
3
3
4 .. image:: https://img.shields.io/pypi/dm/IPython.svg
4 .. image:: https://img.shields.io/pypi/dm/IPython.svg
5 :target: https://pypi.python.org/pypi/ipython
5 :target: https://pypi.python.org/pypi/ipython
6
6
7 .. image:: https://img.shields.io/pypi/v/IPython.svg
7 .. image:: https://img.shields.io/pypi/v/IPython.svg
8 :target: https://pypi.python.org/pypi/ipython
8 :target: https://pypi.python.org/pypi/ipython
9
9
10 .. image:: https://img.shields.io/travis/ipython/ipython.svg
10 .. image:: https://img.shields.io/travis/ipython/ipython.svg
11 :target: https://travis-ci.org/ipython/ipython
11 :target: https://travis-ci.org/ipython/ipython
12
12
13
13
14 ===========================================
14 ===========================================
15 IPython: Productive Interactive Computing
15 IPython: Productive Interactive Computing
16 ===========================================
16 ===========================================
17
17
18 Overview
18 Overview
19 ========
19 ========
20
20
21 Welcome to IPython. Our full documentation is available on `ipython.readthedocs.io
21 Welcome to IPython. Our full documentation is available on `ipython.readthedocs.io
22 <https://ipython.readthedocs.io/en/stable/>`_ and contain information on how to install, use
22 <https://ipython.readthedocs.io/en/stable/>`_ and contain information on how to install, use
23 contribute to the project.
23 contribute to the project.
24
24
25 Officially, IPython requires Python version 2.7, or 3.3 and above.
25 Officially, IPython requires Python version 3.3 and above.
26 IPython 1.x is the last IPython version to support Python 2.6 and 3.2.
26 IPython 5.x is the last IPython version to support Python 2.7.
27
27
28 The Notebook, Qt console and a number of other pieces are now parts of *Jupyter*.
28 The Notebook, Qt console and a number of other pieces are now parts of *Jupyter*.
29 See the `Jupyter installation docs <http://jupyter.readthedocs.io/en/latest/install.html>`__
29 See the `Jupyter installation docs <http://jupyter.readthedocs.io/en/latest/install.html>`__
30 if you want to use these.
30 if you want to use these.
31
31
32
32
33
33
34
34
35 Developement and Instant runnimg
35 Developement and Instant runnimg
36 ================================
36 ================================
37
37
38 You can find the latest version of the development documentation on `readthedocs
38 You can find the latest version of the development documentation on `readthedocs
39 <http://ipython.readthedocs.io/en/latest/>`_.
39 <http://ipython.readthedocs.io/en/latest/>`_.
40
40
41 You can run IPython from this directory without even installing it system-wide
41 You can run IPython from this directory without even installing it system-wide
42 by typing at the terminal::
42 by typing at the terminal::
43
43
44 $ python -m IPython
44 $ python -m IPython
45
45
46 Or see the `developement installation docs
46 Or see the `developement installation docs
47 <http://ipython.readthedocs.io/en/latest/install/install.html#installing-the-development-version>`_
47 <http://ipython.readthedocs.io/en/latest/install/install.html#installing-the-development-version>`_
48 for the latest revision on read the docs.
48 for the latest revision on read the docs.
49
49
50 Documentation and installation instructions for older version of IPython can be
50 Documentation and installation instructions for older version of IPython can be
51 found on the `IPython website <http://ipython.org/documentation.html>`_
51 found on the `IPython website <http://ipython.org/documentation.html>`_
@@ -1,144 +1,144 b''
1 .. _install:
1 .. _install:
2
2
3 Installing IPython
3 Installing IPython
4 ==================
4 ==================
5
5
6
6
7 IPython requires Python 2.7 or β‰₯ 3.3.
7 IPython 6 requires Python β‰₯ 3.3. IPython 5.x can be installed on Python 2.
8
8
9
9
10 Quick Install
10 Quick Install
11 -------------
11 -------------
12
12
13 With ``pip`` already installed :
13 With ``pip`` already installed :
14
14
15 .. code-block:: bash
15 .. code-block:: bash
16
16
17 $ pip install ipython
17 $ pip install ipython
18
18
19 This installs IPython as well as its dependencies.
19 This installs IPython as well as its dependencies.
20
20
21 If you want to use IPython with notebooks or the Qt console, you should also
21 If you want to use IPython with notebooks or the Qt console, you should also
22 install Jupyter ``pip install jupyter``.
22 install Jupyter ``pip install jupyter``.
23
23
24
24
25
25
26 Overview
26 Overview
27 --------
27 --------
28
28
29 This document describes in detail the steps required to install IPython. For a
29 This document describes in detail the steps required to install IPython. For a
30 few quick ways to get started with package managers or full Python
30 few quick ways to get started with package managers or full Python
31 distributions, see `the install page <http://ipython.org/install.html>`_ of the
31 distributions, see `the install page <http://ipython.org/install.html>`_ of the
32 IPython website.
32 IPython website.
33
33
34 Please let us know if you have problems installing IPython or any of its
34 Please let us know if you have problems installing IPython or any of its
35 dependencies.
35 dependencies.
36
36
37 IPython and most dependencies should be installed via :command:`pip`.
37 IPython and most dependencies should be installed via :command:`pip`.
38 In many scenarios, this is the simplest method of installing Python packages.
38 In many scenarios, this is the simplest method of installing Python packages.
39 More information about :mod:`pip` can be found on
39 More information about :mod:`pip` can be found on
40 `its PyPI page <https://pip.pypa.io>`__.
40 `its PyPI page <https://pip.pypa.io>`__.
41
41
42
42
43 More general information about installing Python packages can be found in
43 More general information about installing Python packages can be found in
44 `Python's documentation <http://docs.python.org>`_.
44 `Python's documentation <http://docs.python.org>`_.
45
45
46 .. _dependencies:
46 .. _dependencies:
47
47
48 Dependencies
48 Dependencies
49 ~~~~~~~~~~~~
49 ~~~~~~~~~~~~
50
50
51 IPython relies on a number of other Python packages. Installing using a package
51 IPython relies on a number of other Python packages. Installing using a package
52 manager like pip or conda will ensure the necessary packages are installed.
52 manager like pip or conda will ensure the necessary packages are installed.
53 Manual installation without dependencies is possible, but not recommended.
53 Manual installation without dependencies is possible, but not recommended.
54 The dependencies can be viewed with package manager commands,
54 The dependencies can be viewed with package manager commands,
55 such as :command:`pip show ipython` or :command:`conda info ipython`.
55 such as :command:`pip show ipython` or :command:`conda info ipython`.
56
56
57
57
58 Installing IPython itself
58 Installing IPython itself
59 ~~~~~~~~~~~~~~~~~~~~~~~~~
59 ~~~~~~~~~~~~~~~~~~~~~~~~~
60
60
61 IPython requires several dependencies to work correctly, it is not recommended
61 IPython requires several dependencies to work correctly, it is not recommended
62 to install IPython and all its dependencies manually as this can be quite long
62 to install IPython and all its dependencies manually as this can be quite long
63 and troublesome. You should use the python package manager ``pip``.
63 and troublesome. You should use the python package manager ``pip``.
64
64
65 Installation using pip
65 Installation using pip
66 ~~~~~~~~~~~~~~~~~~~~~~
66 ~~~~~~~~~~~~~~~~~~~~~~
67
67
68 Make sure you have the latest version of :mod:`pip` (the Python package
68 Make sure you have the latest version of :mod:`pip` (the Python package
69 manager) installed. If you do not, head to `Pip documentation
69 manager) installed. If you do not, head to `Pip documentation
70 <https://pip.pypa.io/en/stable/installing/>`_ and install :mod:`pip` first.
70 <https://pip.pypa.io/en/stable/installing/>`_ and install :mod:`pip` first.
71
71
72 The quickest way to get up and running with IPython is to install it with pip:
72 The quickest way to get up and running with IPython is to install it with pip:
73
73
74 .. code-block:: bash
74 .. code-block:: bash
75
75
76 $ pip install ipython
76 $ pip install ipython
77
77
78 That's it.
78 That's it.
79
79
80
80
81 Installation from source
81 Installation from source
82 ~~~~~~~~~~~~~~~~~~~~~~~~
82 ~~~~~~~~~~~~~~~~~~~~~~~~
83
83
84 If you don't want to use :command:`pip`, or don't have it installed,
84 If you don't want to use :command:`pip`, or don't have it installed,
85 grab the latest stable tarball of IPython `from PyPI
85 grab the latest stable tarball of IPython `from PyPI
86 <https://pypi.python.org/pypi/ipython>`__. Then do the following:
86 <https://pypi.python.org/pypi/ipython>`__. Then do the following:
87
87
88 .. code-block:: bash
88 .. code-block:: bash
89
89
90 $ tar -xzf ipython.tar.gz
90 $ tar -xzf ipython.tar.gz
91 $ cd ipython
91 $ cd ipython
92 $ pip install .
92 $ pip install .
93
93
94 Do not invoke ``setup.py`` directly as this can have undesirable consequences
94 Do not invoke ``setup.py`` directly as this can have undesirable consequences
95 for further upgrades. Try to also avoid any usage of ``easy_install`` that can
95 for further upgrades. Try to also avoid any usage of ``easy_install`` that can
96 have similar undesirable consequences.
96 have similar undesirable consequences.
97
97
98 If you are installing to a location (like ``/usr/local``) that requires higher
98 If you are installing to a location (like ``/usr/local``) that requires higher
99 permissions, you may need to run the last command with :command:`sudo`. You can
99 permissions, you may need to run the last command with :command:`sudo`. You can
100 also install in user specific location by using the ``--user`` flag in
100 also install in user specific location by using the ``--user`` flag in
101 conjunction with pip.
101 conjunction with pip.
102
102
103 To run IPython's test suite, use the :command:`iptest` command from outside of
103 To run IPython's test suite, use the :command:`iptest` command from outside of
104 the IPython source tree:
104 the IPython source tree:
105
105
106 .. code-block:: bash
106 .. code-block:: bash
107
107
108 $ iptest
108 $ iptest
109
109
110 .. _devinstall:
110 .. _devinstall:
111
111
112 Installing the development version
112 Installing the development version
113 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
114
115 It is also possible to install the development version of IPython from our
115 It is also possible to install the development version of IPython from our
116 `Git <http://git-scm.com/>`_ source code repository. To do this you will
116 `Git <http://git-scm.com/>`_ source code repository. To do this you will
117 need to have Git installed on your system.
117 need to have Git installed on your system.
118
118
119
119
120 Then do:
120 Then do:
121
121
122 .. code-block:: bash
122 .. code-block:: bash
123
123
124 $ git clone https://github.com/ipython/ipython.git
124 $ git clone https://github.com/ipython/ipython.git
125 $ cd ipython
125 $ cd ipython
126 $ pip install -e .
126 $ pip install -e .
127
127
128 The :command:`pip install -e .` command allows users and developers to follow
128 The :command:`pip install -e .` command allows users and developers to follow
129 the development branch as it changes by creating links in the right places and
129 the development branch as it changes by creating links in the right places and
130 installing the command line scripts to the appropriate locations.
130 installing the command line scripts to the appropriate locations.
131
131
132 Then, if you want to update your IPython at any time, do:
132 Then, if you want to update your IPython at any time, do:
133
133
134 .. code-block:: bash
134 .. code-block:: bash
135
135
136 $ git pull
136 $ git pull
137
137
138 If the dependencies or entrypoints have changed, you may have to run
138 If the dependencies or entrypoints have changed, you may have to run
139
139
140 .. code-block:: bash
140 .. code-block:: bash
141
141
142 $ pip install -e .
142 $ pip install -e .
143
143
144 again, but this is infrequent.
144 again, but this is infrequent.
@@ -1,288 +1,289 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """Setup script for IPython.
3 """Setup script for IPython.
4
4
5 Under Posix environments it works like a typical setup.py script.
5 Under Posix environments it works like a typical setup.py script.
6 Under Windows, the command sdist is not supported, since IPython
6 Under Windows, the command sdist is not supported, since IPython
7 requires utilities which are not available under Windows."""
7 requires utilities which are not available under Windows."""
8
8
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10 # Copyright (c) 2008-2011, IPython Development Team.
10 # Copyright (c) 2008-2011, IPython Development Team.
11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
14 #
14 #
15 # Distributed under the terms of the Modified BSD License.
15 # Distributed under the terms of the Modified BSD License.
16 #
16 #
17 # The full license is in the file COPYING.rst, distributed with this software.
17 # The full license is in the file COPYING.rst, distributed with this software.
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Minimal Python version sanity check
21 # Minimal Python version sanity check
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 from __future__ import print_function
23 from __future__ import print_function
24
24
25 import sys
25 import sys
26
26
27 # This check is also made in IPython/__init__, don't forget to update both when
27 # This check is also made in IPython/__init__, don't forget to update both when
28 # changing Python version requirements.
28 # changing Python version requirements.
29 v = sys.version_info
29 v = sys.version_info
30 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
30 if v[:2] < (3,3):
31 error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
31 error = "ERROR: IPython requires Python version 3.3 or above."
32 print(error, file=sys.stderr)
32 print(error, file=sys.stderr)
33 sys.exit(1)
33 sys.exit(1)
34
34
35 PY3 = (sys.version_info[0] >= 3)
35 PY3 = (sys.version_info[0] >= 3)
36
36
37 # At least we're on the python version we need, move on.
37 # At least we're on the python version we need, move on.
38
38
39 #-------------------------------------------------------------------------------
39 #-------------------------------------------------------------------------------
40 # Imports
40 # Imports
41 #-------------------------------------------------------------------------------
41 #-------------------------------------------------------------------------------
42
42
43 # Stdlib imports
43 # Stdlib imports
44 import os
44 import os
45
45
46 from glob import glob
46 from glob import glob
47
47
48 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
48 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
49 # update it when the contents of directories change.
49 # update it when the contents of directories change.
50 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
50 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
51
51
52 from distutils.core import setup
52 from distutils.core import setup
53
53
54 # Our own imports
54 # Our own imports
55 from setupbase import target_update
55 from setupbase import target_update
56
56
57 from setupbase import (
57 from setupbase import (
58 setup_args,
58 setup_args,
59 find_packages,
59 find_packages,
60 find_package_data,
60 find_package_data,
61 check_package_data_first,
61 check_package_data_first,
62 find_entry_points,
62 find_entry_points,
63 build_scripts_entrypt,
63 build_scripts_entrypt,
64 find_data_files,
64 find_data_files,
65 git_prebuild,
65 git_prebuild,
66 install_symlinked,
66 install_symlinked,
67 install_lib_symlink,
67 install_lib_symlink,
68 install_scripts_for_symlink,
68 install_scripts_for_symlink,
69 unsymlink,
69 unsymlink,
70 )
70 )
71
71
72 isfile = os.path.isfile
72 isfile = os.path.isfile
73 pjoin = os.path.join
73 pjoin = os.path.join
74
74
75 #-------------------------------------------------------------------------------
75 #-------------------------------------------------------------------------------
76 # Handle OS specific things
76 # Handle OS specific things
77 #-------------------------------------------------------------------------------
77 #-------------------------------------------------------------------------------
78
78
79 if os.name in ('nt','dos'):
79 if os.name in ('nt','dos'):
80 os_name = 'windows'
80 os_name = 'windows'
81 else:
81 else:
82 os_name = os.name
82 os_name = os.name
83
83
84 # Under Windows, 'sdist' has not been supported. Now that the docs build with
84 # Under Windows, 'sdist' has not been supported. Now that the docs build with
85 # Sphinx it might work, but let's not turn it on until someone confirms that it
85 # Sphinx it might work, but let's not turn it on until someone confirms that it
86 # actually works.
86 # actually works.
87 if os_name == 'windows' and 'sdist' in sys.argv:
87 if os_name == 'windows' and 'sdist' in sys.argv:
88 print('The sdist command is not available under Windows. Exiting.')
88 print('The sdist command is not available under Windows. Exiting.')
89 sys.exit(1)
89 sys.exit(1)
90
90
91
91
92 #-------------------------------------------------------------------------------
92 #-------------------------------------------------------------------------------
93 # Things related to the IPython documentation
93 # Things related to the IPython documentation
94 #-------------------------------------------------------------------------------
94 #-------------------------------------------------------------------------------
95
95
96 # update the manuals when building a source dist
96 # update the manuals when building a source dist
97 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
97 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
98
98
99 # List of things to be updated. Each entry is a triplet of args for
99 # List of things to be updated. Each entry is a triplet of args for
100 # target_update()
100 # target_update()
101 to_update = [
101 to_update = [
102 ('docs/man/ipython.1.gz',
102 ('docs/man/ipython.1.gz',
103 ['docs/man/ipython.1'],
103 ['docs/man/ipython.1'],
104 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
104 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
105 ]
105 ]
106
106
107
107
108 [ target_update(*t) for t in to_update ]
108 [ target_update(*t) for t in to_update ]
109
109
110 #---------------------------------------------------------------------------
110 #---------------------------------------------------------------------------
111 # Find all the packages, package data, and data_files
111 # Find all the packages, package data, and data_files
112 #---------------------------------------------------------------------------
112 #---------------------------------------------------------------------------
113
113
114 packages = find_packages()
114 packages = find_packages()
115 package_data = find_package_data()
115 package_data = find_package_data()
116
116
117 data_files = find_data_files()
117 data_files = find_data_files()
118
118
119 setup_args['packages'] = packages
119 setup_args['packages'] = packages
120 setup_args['package_data'] = package_data
120 setup_args['package_data'] = package_data
121 setup_args['data_files'] = data_files
121 setup_args['data_files'] = data_files
122
122
123 #---------------------------------------------------------------------------
123 #---------------------------------------------------------------------------
124 # custom distutils commands
124 # custom distutils commands
125 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
126 # imports here, so they are after setuptools import if there was one
126 # imports here, so they are after setuptools import if there was one
127 from distutils.command.sdist import sdist
127 from distutils.command.sdist import sdist
128 from distutils.command.upload import upload
128 from distutils.command.upload import upload
129
129
130 class UploadWindowsInstallers(upload):
130 class UploadWindowsInstallers(upload):
131
131
132 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
132 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
133 user_options = upload.user_options + [
133 user_options = upload.user_options + [
134 ('files=', 'f', 'exe file (or glob) to upload')
134 ('files=', 'f', 'exe file (or glob) to upload')
135 ]
135 ]
136 def initialize_options(self):
136 def initialize_options(self):
137 upload.initialize_options(self)
137 upload.initialize_options(self)
138 meta = self.distribution.metadata
138 meta = self.distribution.metadata
139 base = '{name}-{version}'.format(
139 base = '{name}-{version}'.format(
140 name=meta.get_name(),
140 name=meta.get_name(),
141 version=meta.get_version()
141 version=meta.get_version()
142 )
142 )
143 self.files = os.path.join('dist', '%s.*.exe' % base)
143 self.files = os.path.join('dist', '%s.*.exe' % base)
144
144
145 def run(self):
145 def run(self):
146 for dist_file in glob(self.files):
146 for dist_file in glob(self.files):
147 self.upload_file('bdist_wininst', 'any', dist_file)
147 self.upload_file('bdist_wininst', 'any', dist_file)
148
148
149 setup_args['cmdclass'] = {
149 setup_args['cmdclass'] = {
150 'build_py': \
150 'build_py': \
151 check_package_data_first(git_prebuild('IPython')),
151 check_package_data_first(git_prebuild('IPython')),
152 'sdist' : git_prebuild('IPython', sdist),
152 'sdist' : git_prebuild('IPython', sdist),
153 'upload_wininst' : UploadWindowsInstallers,
153 'upload_wininst' : UploadWindowsInstallers,
154 'symlink': install_symlinked,
154 'symlink': install_symlinked,
155 'install_lib_symlink': install_lib_symlink,
155 'install_lib_symlink': install_lib_symlink,
156 'install_scripts_sym': install_scripts_for_symlink,
156 'install_scripts_sym': install_scripts_for_symlink,
157 'unsymlink': unsymlink,
157 'unsymlink': unsymlink,
158 }
158 }
159
159
160
160
161 #---------------------------------------------------------------------------
161 #---------------------------------------------------------------------------
162 # Handle scripts, dependencies, and setuptools specific things
162 # Handle scripts, dependencies, and setuptools specific things
163 #---------------------------------------------------------------------------
163 #---------------------------------------------------------------------------
164
164
165 # For some commands, use setuptools. Note that we do NOT list install here!
165 # For some commands, use setuptools. Note that we do NOT list install here!
166 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
166 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
167 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
167 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
168 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
168 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
169 'egg_info', 'easy_install', 'upload', 'install_egg_info',
169 'egg_info', 'easy_install', 'upload', 'install_egg_info',
170 ))
170 ))
171
171
172 if len(needs_setuptools.intersection(sys.argv)) > 0:
172 if len(needs_setuptools.intersection(sys.argv)) > 0:
173 import setuptools
173 import setuptools
174
174
175 # This dict is used for passing extra arguments that are setuptools
175 # This dict is used for passing extra arguments that are setuptools
176 # specific to setup
176 # specific to setup
177 setuptools_extra_args = {}
177 setuptools_extra_args = {}
178
178
179 # setuptools requirements
179 # setuptools requirements
180
180
181 extras_require = dict(
181 extras_require = dict(
182 parallel = ['ipyparallel'],
182 parallel = ['ipyparallel'],
183 qtconsole = ['qtconsole'],
183 qtconsole = ['qtconsole'],
184 doc = ['Sphinx>=1.3'],
184 doc = ['Sphinx>=1.3'],
185 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy'],
185 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy'],
186 terminal = [],
186 terminal = [],
187 kernel = ['ipykernel'],
187 kernel = ['ipykernel'],
188 nbformat = ['nbformat'],
188 nbformat = ['nbformat'],
189 notebook = ['notebook', 'ipywidgets'],
189 notebook = ['notebook', 'ipywidgets'],
190 nbconvert = ['nbconvert'],
190 nbconvert = ['nbconvert'],
191 )
191 )
192
192
193 install_requires = [
193 install_requires = [
194 'setuptools>=18.5',
194 'setuptools>=18.5',
195 'decorator',
195 'decorator',
196 'pickleshare',
196 'pickleshare',
197 'simplegeneric>0.8',
197 'simplegeneric>0.8',
198 'traitlets>=4.2',
198 'traitlets>=4.2',
199 'prompt_toolkit>=1.0.3,<2.0.0',
199 'prompt_toolkit>=1.0.3,<2.0.0',
200 'pygments',
200 'pygments',
201 ]
201 ]
202
202
203 # Platform-specific dependencies:
203 # Platform-specific dependencies:
204 # This is the correct way to specify these,
204 # This is the correct way to specify these,
205 # but requires pip >= 6. pip < 6 ignores these.
205 # but requires pip >= 6. pip < 6 ignores these.
206
206
207 extras_require.update({
207 extras_require.update({
208 ':python_version == "2.7"': ['backports.shutil_get_terminal_size'],
208 ':python_version == "2.7"': ['backports.shutil_get_terminal_size'],
209 ':python_version == "2.7" or python_version == "3.3"': ['pathlib2'],
209 ':python_version == "2.7" or python_version == "3.3"': ['pathlib2'],
210 ':sys_platform != "win32"': ['pexpect'],
210 ':sys_platform != "win32"': ['pexpect'],
211 ':sys_platform == "darwin"': ['appnope'],
211 ':sys_platform == "darwin"': ['appnope'],
212 ':sys_platform == "win32"': ['colorama', 'win_unicode_console>=0.5'],
212 ':sys_platform == "win32"': ['colorama', 'win_unicode_console>=0.5'],
213 'test:python_version == "2.7"': ['mock'],
213 'test:python_version == "2.7"': ['mock'],
214 })
214 })
215 # FIXME: re-specify above platform dependencies for pip < 6
215 # FIXME: re-specify above platform dependencies for pip < 6
216 # These would result in non-portable bdists.
216 # These would result in non-portable bdists.
217 if not any(arg.startswith('bdist') for arg in sys.argv):
217 if not any(arg.startswith('bdist') for arg in sys.argv):
218 if sys.version_info < (3, 3):
218 if sys.version_info < (3, 3):
219 extras_require['test'].append('mock')
219 extras_require['test'].append('mock')
220
220
221 if sys.platform == 'darwin':
221 if sys.platform == 'darwin':
222 install_requires.extend(['appnope'])
222 install_requires.extend(['appnope'])
223
223
224 if not sys.platform.startswith('win'):
224 if not sys.platform.startswith('win'):
225 install_requires.append('pexpect')
225 install_requires.append('pexpect')
226
226
227 # workaround pypa/setuptools#147, where setuptools misspells
227 # workaround pypa/setuptools#147, where setuptools misspells
228 # platform_python_implementation as python_implementation
228 # platform_python_implementation as python_implementation
229 if 'setuptools' in sys.modules:
229 if 'setuptools' in sys.modules:
230 for key in list(extras_require):
230 for key in list(extras_require):
231 if 'platform_python_implementation' in key:
231 if 'platform_python_implementation' in key:
232 new_key = key.replace('platform_python_implementation', 'python_implementation')
232 new_key = key.replace('platform_python_implementation', 'python_implementation')
233 extras_require[new_key] = extras_require.pop(key)
233 extras_require[new_key] = extras_require.pop(key)
234
234
235 everything = set()
235 everything = set()
236 for key, deps in extras_require.items():
236 for key, deps in extras_require.items():
237 if ':' not in key:
237 if ':' not in key:
238 everything.update(deps)
238 everything.update(deps)
239 extras_require['all'] = everything
239 extras_require['all'] = everything
240
240
241 if 'setuptools' in sys.modules:
241 if 'setuptools' in sys.modules:
242 setuptools_extra_args['python_requires'] = '>=3.3'
242 setuptools_extra_args['zip_safe'] = False
243 setuptools_extra_args['zip_safe'] = False
243 setuptools_extra_args['entry_points'] = {
244 setuptools_extra_args['entry_points'] = {
244 'console_scripts': find_entry_points(),
245 'console_scripts': find_entry_points(),
245 'pygments.lexers': [
246 'pygments.lexers': [
246 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
247 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
247 'ipython = IPython.lib.lexers:IPythonLexer',
248 'ipython = IPython.lib.lexers:IPythonLexer',
248 'ipython3 = IPython.lib.lexers:IPython3Lexer',
249 'ipython3 = IPython.lib.lexers:IPython3Lexer',
249 ],
250 ],
250 }
251 }
251 setup_args['extras_require'] = extras_require
252 setup_args['extras_require'] = extras_require
252 requires = setup_args['install_requires'] = install_requires
253 requires = setup_args['install_requires'] = install_requires
253
254
254 # Script to be run by the windows binary installer after the default setup
255 # Script to be run by the windows binary installer after the default setup
255 # routine, to add shortcuts and similar windows-only things. Windows
256 # routine, to add shortcuts and similar windows-only things. Windows
256 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
257 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
257 # doesn't find them.
258 # doesn't find them.
258 if 'bdist_wininst' in sys.argv:
259 if 'bdist_wininst' in sys.argv:
259 if len(sys.argv) > 2 and \
260 if len(sys.argv) > 2 and \
260 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
261 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
261 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
262 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
262 sys.exit(1)
263 sys.exit(1)
263 setup_args['data_files'].append(
264 setup_args['data_files'].append(
264 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
265 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
265 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
266 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
266 setup_args['options'] = {"bdist_wininst":
267 setup_args['options'] = {"bdist_wininst":
267 {"install_script":
268 {"install_script":
268 "ipython_win_post_install.py"}}
269 "ipython_win_post_install.py"}}
269
270
270 else:
271 else:
271 # scripts has to be a non-empty list, or install_scripts isn't called
272 # scripts has to be a non-empty list, or install_scripts isn't called
272 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
273 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
273
274
274 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
275 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
275
276
276 #---------------------------------------------------------------------------
277 #---------------------------------------------------------------------------
277 # Do the actual setup now
278 # Do the actual setup now
278 #---------------------------------------------------------------------------
279 #---------------------------------------------------------------------------
279
280
280 setup_args.update(setuptools_extra_args)
281 setup_args.update(setuptools_extra_args)
281
282
282
283
283
284
284 def main():
285 def main():
285 setup(**setup_args)
286 setup(**setup_args)
286
287
287 if __name__ == '__main__':
288 if __name__ == '__main__':
288 main()
289 main()
@@ -1,57 +1,56 b''
1 """Various utilities common to IPython release and maintenance tools.
1 """Various utilities common to IPython release and maintenance tools.
2 """
2 """
3 from __future__ import print_function
3 from __future__ import print_function
4
4
5 # Library imports
5 # Library imports
6 import os
6 import os
7
7
8 # Useful shorthands
8 # Useful shorthands
9 pjoin = os.path.join
9 pjoin = os.path.join
10 cd = os.chdir
10 cd = os.chdir
11
11
12 # Constants
12 # Constants
13
13
14 # SSH root address of the archive site
14 # SSH root address of the archive site
15 archive_user = 'ipython@archive.ipython.org'
15 archive_user = 'ipython@archive.ipython.org'
16 archive_dir = 'archive.ipython.org'
16 archive_dir = 'archive.ipython.org'
17 archive = '%s:%s' % (archive_user, archive_dir)
17 archive = '%s:%s' % (archive_user, archive_dir)
18
18
19 # Build commands
19 # Build commands
20 # Source dists
20 # Source dists
21 sdists = './setup.py sdist --formats=gztar,zip'
21 sdists = './setup.py sdist --formats=gztar,zip'
22 # Binary dists
22 # Binary dists
23 def buildwheels():
23 def buildwheels():
24 for py in ('2', '3'):
24 sh('python3 setupegg.py bdist_wheel' % py)
25 sh('python%s setupegg.py bdist_wheel' % py)
26
25
27 # Utility functions
26 # Utility functions
28 def sh(cmd):
27 def sh(cmd):
29 """Run system command in shell, raise SystemExit if it returns an error."""
28 """Run system command in shell, raise SystemExit if it returns an error."""
30 print("$", cmd)
29 print("$", cmd)
31 stat = os.system(cmd)
30 stat = os.system(cmd)
32 #stat = 0 # Uncomment this and comment previous to run in debug mode
31 #stat = 0 # Uncomment this and comment previous to run in debug mode
33 if stat:
32 if stat:
34 raise SystemExit("Command %s failed with code: %s" % (cmd, stat))
33 raise SystemExit("Command %s failed with code: %s" % (cmd, stat))
35
34
36 # Backwards compatibility
35 # Backwards compatibility
37 c = sh
36 c = sh
38
37
39 def get_ipdir():
38 def get_ipdir():
40 """Get IPython directory from command line, or assume it's the one above."""
39 """Get IPython directory from command line, or assume it's the one above."""
41
40
42 # Initialize arguments and check location
41 # Initialize arguments and check location
43 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
42 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
44
43
45 ipdir = os.path.abspath(ipdir)
44 ipdir = os.path.abspath(ipdir)
46
45
47 cd(ipdir)
46 cd(ipdir)
48 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
47 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
49 raise SystemExit('Invalid ipython directory: %s' % ipdir)
48 raise SystemExit('Invalid ipython directory: %s' % ipdir)
50 return ipdir
49 return ipdir
51
50
52 try:
51 try:
53 execfile = execfile
52 execfile = execfile
54 except NameError:
53 except NameError:
55 def execfile(fname, globs, locs=None):
54 def execfile(fname, globs, locs=None):
56 locs = locs or globs
55 locs = locs or globs
57 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
56 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
General Comments 0
You need to be logged in to leave comments. Login now