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