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