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