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