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