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