##// END OF EJS Templates
remove __future__ import of print function
Terry Davis -
Show More
@@ -1,263 +1,261 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
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 from __future__ import print_function
21
22 import os
20 import os
23 import sys
21 import sys
24
22
25 # **Python version check**
23 # **Python version check**
26 #
24 #
27 # This check is also made in IPython/__init__, don't forget to update both when
25 # This check is also made in IPython/__init__, don't forget to update both when
28 # changing Python version requirements.
26 # changing Python version requirements.
29 if sys.version_info < (3, 6):
27 if sys.version_info < (3, 6):
30 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
28 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
31 try:
29 try:
32 import pip
30 import pip
33 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
31 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
34 if pip_version < (9, 0, 1) :
32 if pip_version < (9, 0, 1) :
35 pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
33 pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
36 'pip {} detected.'.format(pip.__version__)
34 'pip {} detected.'.format(pip.__version__)
37 else:
35 else:
38 # pip is new enough - it must be something else
36 # pip is new enough - it must be something else
39 pip_message = ''
37 pip_message = ''
40 except Exception:
38 except Exception:
41 pass
39 pass
42
40
43
41
44 error = """
42 error = """
45 IPython 7.10+ supports Python 3.6 and above, following NEP 29.
43 IPython 7.10+ supports Python 3.6 and above, following NEP 29.
46 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
44 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
47 Python 3.3 and 3.4 were supported up to IPython 6.x.
45 Python 3.3 and 3.4 were supported up to IPython 6.x.
48 Python 3.5 was supported with IPython 7.0 to 7.9.
46 Python 3.5 was supported with IPython 7.0 to 7.9.
49
47
50 See IPython `README.rst` file for more information:
48 See IPython `README.rst` file for more information:
51
49
52 https://github.com/ipython/ipython/blob/master/README.rst
50 https://github.com/ipython/ipython/blob/master/README.rst
53
51
54 Python {py} detected.
52 Python {py} detected.
55 {pip}
53 {pip}
56 """.format(py=sys.version_info, pip=pip_message )
54 """.format(py=sys.version_info, pip=pip_message )
57
55
58 print(error, file=sys.stderr)
56 print(error, file=sys.stderr)
59 sys.exit(1)
57 sys.exit(1)
60
58
61 # At least we're on the python version we need, move on.
59 # At least we're on the python version we need, move on.
62
60
63 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
61 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
64 # update it when the contents of directories change.
62 # update it when the contents of directories change.
65 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
63 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
66
64
67 from distutils.core import setup
65 from distutils.core import setup
68
66
69 # Our own imports
67 # Our own imports
70 from setupbase import target_update
68 from setupbase import target_update
71
69
72 from setupbase import (
70 from setupbase import (
73 setup_args,
71 setup_args,
74 find_packages,
72 find_packages,
75 find_package_data,
73 find_package_data,
76 check_package_data_first,
74 check_package_data_first,
77 find_entry_points,
75 find_entry_points,
78 build_scripts_entrypt,
76 build_scripts_entrypt,
79 find_data_files,
77 find_data_files,
80 git_prebuild,
78 git_prebuild,
81 install_symlinked,
79 install_symlinked,
82 install_lib_symlink,
80 install_lib_symlink,
83 install_scripts_for_symlink,
81 install_scripts_for_symlink,
84 unsymlink,
82 unsymlink,
85 )
83 )
86
84
87 isfile = os.path.isfile
85 isfile = os.path.isfile
88 pjoin = os.path.join
86 pjoin = os.path.join
89
87
90 #-------------------------------------------------------------------------------
88 #-------------------------------------------------------------------------------
91 # Handle OS specific things
89 # Handle OS specific things
92 #-------------------------------------------------------------------------------
90 #-------------------------------------------------------------------------------
93
91
94 if os.name in ('nt','dos'):
92 if os.name in ('nt','dos'):
95 os_name = 'windows'
93 os_name = 'windows'
96 else:
94 else:
97 os_name = os.name
95 os_name = os.name
98
96
99 # Under Windows, 'sdist' has not been supported. Now that the docs build with
97 # Under Windows, 'sdist' has not been supported. Now that the docs build with
100 # Sphinx it might work, but let's not turn it on until someone confirms that it
98 # Sphinx it might work, but let's not turn it on until someone confirms that it
101 # actually works.
99 # actually works.
102 if os_name == 'windows' and 'sdist' in sys.argv:
100 if os_name == 'windows' and 'sdist' in sys.argv:
103 print('The sdist command is not available under Windows. Exiting.')
101 print('The sdist command is not available under Windows. Exiting.')
104 sys.exit(1)
102 sys.exit(1)
105
103
106
104
107 #-------------------------------------------------------------------------------
105 #-------------------------------------------------------------------------------
108 # Things related to the IPython documentation
106 # Things related to the IPython documentation
109 #-------------------------------------------------------------------------------
107 #-------------------------------------------------------------------------------
110
108
111 # update the manuals when building a source dist
109 # update the manuals when building a source dist
112 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
110 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
113
111
114 # List of things to be updated. Each entry is a triplet of args for
112 # List of things to be updated. Each entry is a triplet of args for
115 # target_update()
113 # target_update()
116 to_update = [
114 to_update = [
117 ('docs/man/ipython.1.gz',
115 ('docs/man/ipython.1.gz',
118 ['docs/man/ipython.1'],
116 ['docs/man/ipython.1'],
119 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
117 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
120 ]
118 ]
121
119
122
120
123 [ target_update(*t) for t in to_update ]
121 [ target_update(*t) for t in to_update ]
124
122
125 #---------------------------------------------------------------------------
123 #---------------------------------------------------------------------------
126 # Find all the packages, package data, and data_files
124 # Find all the packages, package data, and data_files
127 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
128
126
129 packages = find_packages()
127 packages = find_packages()
130 package_data = find_package_data()
128 package_data = find_package_data()
131
129
132 data_files = find_data_files()
130 data_files = find_data_files()
133
131
134 setup_args['packages'] = packages
132 setup_args['packages'] = packages
135 setup_args['package_data'] = package_data
133 setup_args['package_data'] = package_data
136 setup_args['data_files'] = data_files
134 setup_args['data_files'] = data_files
137
135
138 #---------------------------------------------------------------------------
136 #---------------------------------------------------------------------------
139 # custom distutils commands
137 # custom distutils commands
140 #---------------------------------------------------------------------------
138 #---------------------------------------------------------------------------
141 # imports here, so they are after setuptools import if there was one
139 # imports here, so they are after setuptools import if there was one
142 from distutils.command.sdist import sdist
140 from distutils.command.sdist import sdist
143
141
144 setup_args['cmdclass'] = {
142 setup_args['cmdclass'] = {
145 'build_py': \
143 'build_py': \
146 check_package_data_first(git_prebuild('IPython')),
144 check_package_data_first(git_prebuild('IPython')),
147 'sdist' : git_prebuild('IPython', sdist),
145 'sdist' : git_prebuild('IPython', sdist),
148 'symlink': install_symlinked,
146 'symlink': install_symlinked,
149 'install_lib_symlink': install_lib_symlink,
147 'install_lib_symlink': install_lib_symlink,
150 'install_scripts_sym': install_scripts_for_symlink,
148 'install_scripts_sym': install_scripts_for_symlink,
151 'unsymlink': unsymlink,
149 'unsymlink': unsymlink,
152 }
150 }
153
151
154
152
155 #---------------------------------------------------------------------------
153 #---------------------------------------------------------------------------
156 # Handle scripts, dependencies, and setuptools specific things
154 # Handle scripts, dependencies, and setuptools specific things
157 #---------------------------------------------------------------------------
155 #---------------------------------------------------------------------------
158
156
159 # For some commands, use setuptools. Note that we do NOT list install here!
157 # For some commands, use setuptools. Note that we do NOT list install here!
160 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
158 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
161 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
159 needs_setuptools = {'develop', 'release', 'bdist_egg', 'bdist_rpm',
162 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
160 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
163 'egg_info', 'easy_install', 'upload', 'install_egg_info',
161 'egg_info', 'easy_install', 'upload', 'install_egg_info',
164 }
162 }
165
163
166 if len(needs_setuptools.intersection(sys.argv)) > 0:
164 if len(needs_setuptools.intersection(sys.argv)) > 0:
167 import setuptools
165 import setuptools
168
166
169 # This dict is used for passing extra arguments that are setuptools
167 # This dict is used for passing extra arguments that are setuptools
170 # specific to setup
168 # specific to setup
171 setuptools_extra_args = {}
169 setuptools_extra_args = {}
172
170
173 # setuptools requirements
171 # setuptools requirements
174
172
175 extras_require = dict(
173 extras_require = dict(
176 parallel = ['ipyparallel'],
174 parallel = ['ipyparallel'],
177 qtconsole = ['qtconsole'],
175 qtconsole = ['qtconsole'],
178 doc = ['Sphinx>=1.3'],
176 doc = ['Sphinx>=1.3'],
179 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy>=1.14'],
177 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy>=1.14'],
180 terminal = [],
178 terminal = [],
181 kernel = ['ipykernel'],
179 kernel = ['ipykernel'],
182 nbformat = ['nbformat'],
180 nbformat = ['nbformat'],
183 notebook = ['notebook', 'ipywidgets'],
181 notebook = ['notebook', 'ipywidgets'],
184 nbconvert = ['nbconvert'],
182 nbconvert = ['nbconvert'],
185 )
183 )
186
184
187 install_requires = [
185 install_requires = [
188 'setuptools>=18.5',
186 'setuptools>=18.5',
189 'jedi>=0.10',
187 'jedi>=0.10',
190 'decorator',
188 'decorator',
191 'pickleshare',
189 'pickleshare',
192 'traitlets>=4.2',
190 'traitlets>=4.2',
193 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
191 'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
194 'pygments',
192 'pygments',
195 'backcall',
193 'backcall',
196 'stack_data',
194 'stack_data',
197 ]
195 ]
198
196
199 # Platform-specific dependencies:
197 # Platform-specific dependencies:
200 # This is the correct way to specify these,
198 # This is the correct way to specify these,
201 # but requires pip >= 6. pip < 6 ignores these.
199 # but requires pip >= 6. pip < 6 ignores these.
202
200
203 extras_require.update({
201 extras_require.update({
204 ':sys_platform != "win32"': ['pexpect'],
202 ':sys_platform != "win32"': ['pexpect'],
205 ':sys_platform == "darwin"': ['appnope'],
203 ':sys_platform == "darwin"': ['appnope'],
206 ':sys_platform == "win32"': ['colorama'],
204 ':sys_platform == "win32"': ['colorama'],
207 })
205 })
208 # FIXME: re-specify above platform dependencies for pip < 6
206 # FIXME: re-specify above platform dependencies for pip < 6
209 # These would result in non-portable bdists.
207 # These would result in non-portable bdists.
210 if not any(arg.startswith('bdist') for arg in sys.argv):
208 if not any(arg.startswith('bdist') for arg in sys.argv):
211 if sys.platform == 'darwin':
209 if sys.platform == 'darwin':
212 install_requires.extend(['appnope'])
210 install_requires.extend(['appnope'])
213
211
214 if not sys.platform.startswith('win'):
212 if not sys.platform.startswith('win'):
215 install_requires.append('pexpect')
213 install_requires.append('pexpect')
216
214
217 # workaround pypa/setuptools#147, where setuptools misspells
215 # workaround pypa/setuptools#147, where setuptools misspells
218 # platform_python_implementation as python_implementation
216 # platform_python_implementation as python_implementation
219 if 'setuptools' in sys.modules:
217 if 'setuptools' in sys.modules:
220 for key in list(extras_require):
218 for key in list(extras_require):
221 if 'platform_python_implementation' in key:
219 if 'platform_python_implementation' in key:
222 new_key = key.replace('platform_python_implementation', 'python_implementation')
220 new_key = key.replace('platform_python_implementation', 'python_implementation')
223 extras_require[new_key] = extras_require.pop(key)
221 extras_require[new_key] = extras_require.pop(key)
224
222
225 everything = set()
223 everything = set()
226 for key, deps in extras_require.items():
224 for key, deps in extras_require.items():
227 if ':' not in key:
225 if ':' not in key:
228 everything.update(deps)
226 everything.update(deps)
229 extras_require['all'] = everything
227 extras_require['all'] = everything
230
228
231 if 'setuptools' in sys.modules:
229 if 'setuptools' in sys.modules:
232 setuptools_extra_args['python_requires'] = '>=3.6'
230 setuptools_extra_args['python_requires'] = '>=3.6'
233 setuptools_extra_args['zip_safe'] = False
231 setuptools_extra_args['zip_safe'] = False
234 setuptools_extra_args['entry_points'] = {
232 setuptools_extra_args['entry_points'] = {
235 'console_scripts': find_entry_points(),
233 'console_scripts': find_entry_points(),
236 'pygments.lexers': [
234 'pygments.lexers': [
237 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
235 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
238 'ipython = IPython.lib.lexers:IPythonLexer',
236 'ipython = IPython.lib.lexers:IPythonLexer',
239 'ipython3 = IPython.lib.lexers:IPython3Lexer',
237 'ipython3 = IPython.lib.lexers:IPython3Lexer',
240 ],
238 ],
241 }
239 }
242 setup_args['extras_require'] = extras_require
240 setup_args['extras_require'] = extras_require
243 setup_args['install_requires'] = install_requires
241 setup_args['install_requires'] = install_requires
244
242
245 else:
243 else:
246 # scripts has to be a non-empty list, or install_scripts isn't called
244 # scripts has to be a non-empty list, or install_scripts isn't called
247 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
245 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
248
246
249 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
247 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
250
248
251 #---------------------------------------------------------------------------
249 #---------------------------------------------------------------------------
252 # Do the actual setup now
250 # Do the actual setup now
253 #---------------------------------------------------------------------------
251 #---------------------------------------------------------------------------
254
252
255 setup_args.update(setuptools_extra_args)
253 setup_args.update(setuptools_extra_args)
256
254
257
255
258
256
259 def main():
257 def main():
260 setup(**setup_args)
258 setup(**setup_args)
261
259
262 if __name__ == '__main__':
260 if __name__ == '__main__':
263 main()
261 main()
General Comments 0
You need to be logged in to leave comments. Login now