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