##// END OF EJS Templates
Clean up pip version check
Thomas Kluyver -
Show More
@@ -1,309 +1,307 b''
1 1 #!/usr/bin/env python
2 2 # -*- coding: utf-8 -*-
3 3 """Setup script for IPython.
4 4
5 5 Under Posix environments it works like a typical setup.py script.
6 6 Under Windows, the command sdist is not supported, since IPython
7 7 requires utilities which are not available under Windows."""
8 8
9 9 #-----------------------------------------------------------------------------
10 10 # Copyright (c) 2008-2011, IPython Development Team.
11 11 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
12 12 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
13 13 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
14 14 #
15 15 # Distributed under the terms of the Modified BSD License.
16 16 #
17 17 # The full license is in the file COPYING.rst, distributed with this software.
18 18 #-----------------------------------------------------------------------------
19 19
20 #-----------------------------------------------------------------------------
21 # Minimal Python version sanity check
22 #-----------------------------------------------------------------------------
23 20 from __future__ import print_function
24 21
25 22 import sys
26 23
24 # **Python version check**
25 #
27 26 # This check is also made in IPython/__init__, don't forget to update both when
28 27 # changing Python version requirements.
29 28 if sys.version_info < (3,3):
29 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
30 30 try:
31 pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1. '
32 31 import pip
33 32 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
34 print(pip_version)
35 33 if pip_version < (9, 0, 1) :
36 pip_message = 'You pip version is out of date, please install pip >= 9.0.1.'\
34 pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
37 35 'pip {} detected.'.format(pip.__version__)
38 36 except Exception:
39 37 pass
40 38
41 39
42 40 error = """
43 41 IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
44 42 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
45 43 Beginning with IPython 6.0, Python 3.3 and above is required.
46 44
47 45 See IPython `README.rst` file for more information:
48 46
49 47 https://github.com/ipython/ipython/blob/master/README.rst
50 48
51 49 Python {py} detected.
52 50 {pip}
53 51 """.format(py=sys.version_info, pip=pip_message )
54 52
55 53 print(error, file=sys.stderr)
56 54 sys.exit(1)
57 55
58 56 # At least we're on the python version we need, move on.
59 57
60 58 #-------------------------------------------------------------------------------
61 59 # Imports
62 60 #-------------------------------------------------------------------------------
63 61
64 62 # Stdlib imports
65 63 import os
66 64
67 65 from glob import glob
68 66
69 67 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
70 68 # update it when the contents of directories change.
71 69 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
72 70
73 71 from distutils.core import setup
74 72
75 73 # Our own imports
76 74 from setupbase import target_update
77 75
78 76 from setupbase import (
79 77 setup_args,
80 78 find_packages,
81 79 find_package_data,
82 80 check_package_data_first,
83 81 find_entry_points,
84 82 build_scripts_entrypt,
85 83 find_data_files,
86 84 git_prebuild,
87 85 install_symlinked,
88 86 install_lib_symlink,
89 87 install_scripts_for_symlink,
90 88 unsymlink,
91 89 )
92 90
93 91 isfile = os.path.isfile
94 92 pjoin = os.path.join
95 93
96 94 #-------------------------------------------------------------------------------
97 95 # Handle OS specific things
98 96 #-------------------------------------------------------------------------------
99 97
100 98 if os.name in ('nt','dos'):
101 99 os_name = 'windows'
102 100 else:
103 101 os_name = os.name
104 102
105 103 # Under Windows, 'sdist' has not been supported. Now that the docs build with
106 104 # Sphinx it might work, but let's not turn it on until someone confirms that it
107 105 # actually works.
108 106 if os_name == 'windows' and 'sdist' in sys.argv:
109 107 print('The sdist command is not available under Windows. Exiting.')
110 108 sys.exit(1)
111 109
112 110
113 111 #-------------------------------------------------------------------------------
114 112 # Things related to the IPython documentation
115 113 #-------------------------------------------------------------------------------
116 114
117 115 # update the manuals when building a source dist
118 116 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
119 117
120 118 # List of things to be updated. Each entry is a triplet of args for
121 119 # target_update()
122 120 to_update = [
123 121 ('docs/man/ipython.1.gz',
124 122 ['docs/man/ipython.1'],
125 123 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
126 124 ]
127 125
128 126
129 127 [ target_update(*t) for t in to_update ]
130 128
131 129 #---------------------------------------------------------------------------
132 130 # Find all the packages, package data, and data_files
133 131 #---------------------------------------------------------------------------
134 132
135 133 packages = find_packages()
136 134 package_data = find_package_data()
137 135
138 136 data_files = find_data_files()
139 137
140 138 setup_args['packages'] = packages
141 139 setup_args['package_data'] = package_data
142 140 setup_args['data_files'] = data_files
143 141
144 142 #---------------------------------------------------------------------------
145 143 # custom distutils commands
146 144 #---------------------------------------------------------------------------
147 145 # imports here, so they are after setuptools import if there was one
148 146 from distutils.command.sdist import sdist
149 147 from distutils.command.upload import upload
150 148
151 149 class UploadWindowsInstallers(upload):
152 150
153 151 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
154 152 user_options = upload.user_options + [
155 153 ('files=', 'f', 'exe file (or glob) to upload')
156 154 ]
157 155 def initialize_options(self):
158 156 upload.initialize_options(self)
159 157 meta = self.distribution.metadata
160 158 base = '{name}-{version}'.format(
161 159 name=meta.get_name(),
162 160 version=meta.get_version()
163 161 )
164 162 self.files = os.path.join('dist', '%s.*.exe' % base)
165 163
166 164 def run(self):
167 165 for dist_file in glob(self.files):
168 166 self.upload_file('bdist_wininst', 'any', dist_file)
169 167
170 168 setup_args['cmdclass'] = {
171 169 'build_py': \
172 170 check_package_data_first(git_prebuild('IPython')),
173 171 'sdist' : git_prebuild('IPython', sdist),
174 172 'upload_wininst' : UploadWindowsInstallers,
175 173 'symlink': install_symlinked,
176 174 'install_lib_symlink': install_lib_symlink,
177 175 'install_scripts_sym': install_scripts_for_symlink,
178 176 'unsymlink': unsymlink,
179 177 }
180 178
181 179
182 180 #---------------------------------------------------------------------------
183 181 # Handle scripts, dependencies, and setuptools specific things
184 182 #---------------------------------------------------------------------------
185 183
186 184 # For some commands, use setuptools. Note that we do NOT list install here!
187 185 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
188 186 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
189 187 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
190 188 'egg_info', 'easy_install', 'upload', 'install_egg_info',
191 189 ))
192 190
193 191 if len(needs_setuptools.intersection(sys.argv)) > 0:
194 192 import setuptools
195 193
196 194 # This dict is used for passing extra arguments that are setuptools
197 195 # specific to setup
198 196 setuptools_extra_args = {}
199 197
200 198 # setuptools requirements
201 199
202 200 extras_require = dict(
203 201 parallel = ['ipyparallel'],
204 202 qtconsole = ['qtconsole'],
205 203 doc = ['Sphinx>=1.3'],
206 204 test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel'],
207 205 terminal = [],
208 206 kernel = ['ipykernel'],
209 207 nbformat = ['nbformat'],
210 208 notebook = ['notebook', 'ipywidgets'],
211 209 nbconvert = ['nbconvert'],
212 210 )
213 211
214 212 install_requires = [
215 213 'setuptools>=18.5',
216 214 'jedi>=0.10',
217 215 'decorator',
218 216 'pickleshare',
219 217 'simplegeneric>0.8',
220 218 'traitlets>=4.2',
221 219 'prompt_toolkit>=1.0.4,<2.0.0',
222 220 'pygments',
223 221 ]
224 222
225 223 # Platform-specific dependencies:
226 224 # This is the correct way to specify these,
227 225 # but requires pip >= 6. pip < 6 ignores these.
228 226
229 227 extras_require.update({
230 228 'test:python_version >= "3.4"': ['numpy'],
231 229 ':python_version == "3.3"': ['pathlib2'],
232 230 ':python_version <= "3.4"': ['typing'],
233 231 ':sys_platform != "win32"': ['pexpect'],
234 232 ':sys_platform == "darwin"': ['appnope'],
235 233 ':sys_platform == "win32"': ['colorama'],
236 234 ':sys_platform == "win32" and python_version < "3.6"': ['win_unicode_console>=0.5'],
237 235 })
238 236 # FIXME: re-specify above platform dependencies for pip < 6
239 237 # These would result in non-portable bdists.
240 238 if not any(arg.startswith('bdist') for arg in sys.argv):
241 239 if sys.platform == 'darwin':
242 240 install_requires.extend(['appnope'])
243 241
244 242 if not sys.platform.startswith('win'):
245 243 install_requires.append('pexpect')
246 244
247 245 # workaround pypa/setuptools#147, where setuptools misspells
248 246 # platform_python_implementation as python_implementation
249 247 if 'setuptools' in sys.modules:
250 248 for key in list(extras_require):
251 249 if 'platform_python_implementation' in key:
252 250 new_key = key.replace('platform_python_implementation', 'python_implementation')
253 251 extras_require[new_key] = extras_require.pop(key)
254 252
255 253 everything = set()
256 254 for key, deps in extras_require.items():
257 255 if ':' not in key:
258 256 everything.update(deps)
259 257 extras_require['all'] = everything
260 258
261 259 if 'setuptools' in sys.modules:
262 260 setuptools_extra_args['python_requires'] = '>=3.3'
263 261 setuptools_extra_args['zip_safe'] = False
264 262 setuptools_extra_args['entry_points'] = {
265 263 'console_scripts': find_entry_points(),
266 264 'pygments.lexers': [
267 265 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer',
268 266 'ipython = IPython.lib.lexers:IPythonLexer',
269 267 'ipython3 = IPython.lib.lexers:IPython3Lexer',
270 268 ],
271 269 }
272 270 setup_args['extras_require'] = extras_require
273 271 requires = setup_args['install_requires'] = install_requires
274 272
275 273 # Script to be run by the windows binary installer after the default setup
276 274 # routine, to add shortcuts and similar windows-only things. Windows
277 275 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
278 276 # doesn't find them.
279 277 if 'bdist_wininst' in sys.argv:
280 278 if len(sys.argv) > 2 and \
281 279 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
282 280 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
283 281 sys.exit(1)
284 282 setup_args['data_files'].append(
285 283 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
286 284 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
287 285 setup_args['options'] = {"bdist_wininst":
288 286 {"install_script":
289 287 "ipython_win_post_install.py"}}
290 288
291 289 else:
292 290 # scripts has to be a non-empty list, or install_scripts isn't called
293 291 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
294 292
295 293 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
296 294
297 295 #---------------------------------------------------------------------------
298 296 # Do the actual setup now
299 297 #---------------------------------------------------------------------------
300 298
301 299 setup_args.update(setuptools_extra_args)
302 300
303 301
304 302
305 303 def main():
306 304 setup(**setup_args)
307 305
308 306 if __name__ == '__main__':
309 307 main()
General Comments 0
You need to be logged in to leave comments. Login now