##// END OF EJS Templates
remove strict requirement for less,invoke in wheel/sdist...
Min RK -
Show More
@@ -1,333 +1,333 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 #-----------------------------------------------------------------------------
21 21 # Minimal Python version sanity check
22 22 #-----------------------------------------------------------------------------
23 23 from __future__ import print_function
24 24
25 25 import sys
26 26
27 27 # This check is also made in IPython/__init__, don't forget to update both when
28 28 # changing Python version requirements.
29 29 v = sys.version_info
30 30 if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
31 31 error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
32 32 print(error, file=sys.stderr)
33 33 sys.exit(1)
34 34
35 35 PY3 = (sys.version_info[0] >= 3)
36 36
37 37 # At least we're on the python version we need, move on.
38 38
39 39 #-------------------------------------------------------------------------------
40 40 # Imports
41 41 #-------------------------------------------------------------------------------
42 42
43 43 # Stdlib imports
44 44 import os
45 45 import shutil
46 46
47 47 from glob import glob
48 48
49 49 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
50 50 # update it when the contents of directories change.
51 51 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
52 52
53 53 from distutils.core import setup
54 54
55 55 # Our own imports
56 56 from setupbase import target_update
57 57
58 58 from setupbase import (
59 59 setup_args,
60 60 find_packages,
61 61 find_package_data,
62 62 check_package_data_first,
63 63 find_entry_points,
64 64 build_scripts_entrypt,
65 65 find_data_files,
66 66 check_for_dependencies,
67 67 git_prebuild,
68 68 check_submodule_status,
69 69 update_submodules,
70 70 require_submodules,
71 71 UpdateSubmodules,
72 72 get_bdist_wheel,
73 73 CompileCSS,
74 74 JavascriptVersion,
75 75 css_js_prerelease,
76 76 install_symlinked,
77 77 install_lib_symlink,
78 78 install_scripts_for_symlink,
79 79 unsymlink,
80 80 )
81 81 from setupext import setupext
82 82
83 83 isfile = os.path.isfile
84 84 pjoin = os.path.join
85 85
86 86 #-------------------------------------------------------------------------------
87 87 # Handle OS specific things
88 88 #-------------------------------------------------------------------------------
89 89
90 90 if os.name in ('nt','dos'):
91 91 os_name = 'windows'
92 92 else:
93 93 os_name = os.name
94 94
95 95 # Under Windows, 'sdist' has not been supported. Now that the docs build with
96 96 # Sphinx it might work, but let's not turn it on until someone confirms that it
97 97 # actually works.
98 98 if os_name == 'windows' and 'sdist' in sys.argv:
99 99 print('The sdist command is not available under Windows. Exiting.')
100 100 sys.exit(1)
101 101
102 102 #-------------------------------------------------------------------------------
103 103 # Make sure we aren't trying to run without submodules
104 104 #-------------------------------------------------------------------------------
105 105 here = os.path.abspath(os.path.dirname(__file__))
106 106
107 107 def require_clean_submodules():
108 108 """Check on git submodules before distutils can do anything
109 109
110 110 Since distutils cannot be trusted to update the tree
111 111 after everything has been set in motion,
112 112 this is not a distutils command.
113 113 """
114 114 # PACKAGERS: Add a return here to skip checks for git submodules
115 115
116 116 # don't do anything if nothing is actually supposed to happen
117 117 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
118 118 if do_nothing in sys.argv:
119 119 return
120 120
121 121 status = check_submodule_status(here)
122 122
123 123 if status == "missing":
124 124 print("checking out submodules for the first time")
125 125 update_submodules(here)
126 126 elif status == "unclean":
127 127 print('\n'.join([
128 128 "Cannot build / install IPython with unclean submodules",
129 129 "Please update submodules with",
130 130 " python setup.py submodule",
131 131 "or",
132 132 " git submodule update",
133 133 "or commit any submodule changes you have made."
134 134 ]))
135 135 sys.exit(1)
136 136
137 137 require_clean_submodules()
138 138
139 139 #-------------------------------------------------------------------------------
140 140 # Things related to the IPython documentation
141 141 #-------------------------------------------------------------------------------
142 142
143 143 # update the manuals when building a source dist
144 144 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
145 145
146 146 # List of things to be updated. Each entry is a triplet of args for
147 147 # target_update()
148 148 to_update = [
149 149 # FIXME - Disabled for now: we need to redo an automatic way
150 150 # of generating the magic info inside the rst.
151 151 #('docs/magic.tex',
152 152 #['IPython/Magic.py'],
153 153 #"cd doc && ./update_magic.sh" ),
154 154
155 155 ('docs/man/ipcluster.1.gz',
156 156 ['docs/man/ipcluster.1'],
157 157 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'),
158 158
159 159 ('docs/man/ipcontroller.1.gz',
160 160 ['docs/man/ipcontroller.1'],
161 161 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'),
162 162
163 163 ('docs/man/ipengine.1.gz',
164 164 ['docs/man/ipengine.1'],
165 165 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'),
166 166
167 167 ('docs/man/ipython.1.gz',
168 168 ['docs/man/ipython.1'],
169 169 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'),
170 170
171 171 ]
172 172
173 173
174 174 [ target_update(*t) for t in to_update ]
175 175
176 176 #---------------------------------------------------------------------------
177 177 # Find all the packages, package data, and data_files
178 178 #---------------------------------------------------------------------------
179 179
180 180 packages = find_packages()
181 181 package_data = find_package_data()
182 182
183 183 data_files = find_data_files()
184 184
185 185 setup_args['packages'] = packages
186 186 setup_args['package_data'] = package_data
187 187 setup_args['data_files'] = data_files
188 188
189 189 #---------------------------------------------------------------------------
190 190 # custom distutils commands
191 191 #---------------------------------------------------------------------------
192 192 # imports here, so they are after setuptools import if there was one
193 193 from distutils.command.sdist import sdist
194 194 from distutils.command.upload import upload
195 195
196 196 class UploadWindowsInstallers(upload):
197 197
198 198 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
199 199 user_options = upload.user_options + [
200 200 ('files=', 'f', 'exe file (or glob) to upload')
201 201 ]
202 202 def initialize_options(self):
203 203 upload.initialize_options(self)
204 204 meta = self.distribution.metadata
205 205 base = '{name}-{version}'.format(
206 206 name=meta.get_name(),
207 207 version=meta.get_version()
208 208 )
209 209 self.files = os.path.join('dist', '%s.*.exe' % base)
210 210
211 211 def run(self):
212 212 for dist_file in glob(self.files):
213 213 self.upload_file('bdist_wininst', 'any', dist_file)
214 214
215 215 setup_args['cmdclass'] = {
216 216 'build_py': css_js_prerelease(
217 217 check_package_data_first(git_prebuild('IPython')),
218 218 strict=False),
219 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist)),
219 'sdist' : css_js_prerelease(git_prebuild('IPython', sdist), strict=False),
220 220 'upload_wininst' : UploadWindowsInstallers,
221 221 'submodule' : UpdateSubmodules,
222 222 'css' : CompileCSS,
223 223 'symlink': install_symlinked,
224 224 'install_lib_symlink': install_lib_symlink,
225 225 'install_scripts_sym': install_scripts_for_symlink,
226 226 'unsymlink': unsymlink,
227 227 'jsversion' : JavascriptVersion,
228 228 }
229 229
230 230 #---------------------------------------------------------------------------
231 231 # Handle scripts, dependencies, and setuptools specific things
232 232 #---------------------------------------------------------------------------
233 233
234 234 # For some commands, use setuptools. Note that we do NOT list install here!
235 235 # If you want a setuptools-enhanced install, just run 'setupegg.py install'
236 236 needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm',
237 237 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel',
238 238 'egg_info', 'easy_install', 'upload', 'install_egg_info',
239 239 ))
240 240
241 241 if len(needs_setuptools.intersection(sys.argv)) > 0:
242 242 import setuptools
243 243
244 244 # This dict is used for passing extra arguments that are setuptools
245 245 # specific to setup
246 246 setuptools_extra_args = {}
247 247
248 248 # setuptools requirements
249 249
250 250 extras_require = dict(
251 251 parallel = ['pyzmq>=2.1.11'],
252 252 qtconsole = ['pyzmq>=2.1.11', 'pygments'],
253 253 zmq = ['pyzmq>=2.1.11'],
254 254 doc = ['Sphinx>=1.1', 'numpydoc'],
255 255 test = ['nose>=0.10.1', 'requests'],
256 256 terminal = [],
257 257 nbformat = ['jsonschema>=2.0'],
258 258 notebook = ['tornado>=4.0', 'pyzmq>=2.1.11', 'jinja2', 'pygments', 'mistune>=0.5'],
259 259 nbconvert = ['pygments', 'jinja2', 'mistune>=0.3.1']
260 260 )
261 261
262 262 if sys.version_info < (3, 3):
263 263 extras_require['test'].append('mock')
264 264
265 265 extras_require['notebook'].extend(extras_require['nbformat'])
266 266 extras_require['nbconvert'].extend(extras_require['nbformat'])
267 267
268 268 everything = set()
269 269 for deps in extras_require.values():
270 270 everything.update(deps)
271 271 extras_require['all'] = everything
272 272
273 273 install_requires = []
274 274
275 275 # add readline
276 276 if sys.platform == 'darwin':
277 277 if 'bdist_wheel' in sys.argv[1:] or not setupext.check_for_readline():
278 278 install_requires.append('gnureadline')
279 279 elif sys.platform.startswith('win'):
280 280 extras_require['terminal'].append('pyreadline>=2.0')
281 281
282 282
283 283 if 'setuptools' in sys.modules:
284 284 # setup.py develop should check for submodules
285 285 from setuptools.command.develop import develop
286 286 setup_args['cmdclass']['develop'] = require_submodules(develop)
287 setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
287 setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel(), strict=False)
288 288
289 289 setuptools_extra_args['zip_safe'] = False
290 290 setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()}
291 291 setup_args['extras_require'] = extras_require
292 292 requires = setup_args['install_requires'] = install_requires
293 293
294 294 # Script to be run by the windows binary installer after the default setup
295 295 # routine, to add shortcuts and similar windows-only things. Windows
296 296 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
297 297 # doesn't find them.
298 298 if 'bdist_wininst' in sys.argv:
299 299 if len(sys.argv) > 2 and \
300 300 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
301 301 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
302 302 sys.exit(1)
303 303 setup_args['data_files'].append(
304 304 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
305 305 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
306 306 setup_args['options'] = {"bdist_wininst":
307 307 {"install_script":
308 308 "ipython_win_post_install.py"}}
309 309
310 310 else:
311 311 # If we are installing without setuptools, call this function which will
312 312 # check for dependencies an inform the user what is needed. This is
313 313 # just to make life easy for users.
314 314 for install_cmd in ('install', 'symlink'):
315 315 if install_cmd in sys.argv:
316 316 check_for_dependencies()
317 317 break
318 318 # scripts has to be a non-empty list, or install_scripts isn't called
319 319 setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()]
320 320
321 321 setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt
322 322
323 323 #---------------------------------------------------------------------------
324 324 # Do the actual setup now
325 325 #---------------------------------------------------------------------------
326 326
327 327 setup_args.update(setuptools_extra_args)
328 328
329 329 def main():
330 330 setup(**setup_args)
331 331
332 332 if __name__ == '__main__':
333 333 main()
@@ -1,79 +1,81 b''
1 1 #!/usr/bin/env python
2 2 """IPython release script.
3 3
4 4 This should ONLY be run at real release time.
5 5 """
6 6 from __future__ import print_function
7 7
8 8 from toollib import *
9 9 from gh_api import post_download
10 10
11 11 # Get main ipython dir, this will raise if it doesn't pass some checks
12 12 ipdir = get_ipdir()
13 13 tooldir = pjoin(ipdir, 'tools')
14 14 distdir = pjoin(ipdir, 'dist')
15 15
16 16 # Where I keep static backups of each release
17 17 ipbackupdir = os.path.expanduser('~/ipython/backup')
18 18 if not os.path.exists(ipbackupdir):
19 19 os.makedirs(ipbackupdir)
20 20
21 21 # Start in main IPython dir
22 22 cd(ipdir)
23 23
24 24 # Load release info
25 execfile(pjoin('IPython','core','release.py'))
25 execfile(pjoin('IPython','core','release.py'), globals())
26 26 # ensure js version is in sync
27 27 sh('./setup.py jsversion')
28 # build minified css and sourcemaps
29 sh('./setup.py css -x -f')
28 30
29 31 # Build site addresses for file uploads
30 32 release_site = '%s/release/%s' % (archive, version)
31 33 backup_site = '%s/backup/' % archive
32 34
33 35 # Start actual release process
34 36 print()
35 37 print('Releasing IPython')
36 38 print('=================')
37 39 print()
38 40 print('Version:', version)
39 41 print()
40 42 print('Source IPython directory:', ipdir)
41 43 print()
42 44
43 45 # Perform local backup, go to tools dir to run it.
44 46 cd(tooldir)
45 47 sh('./make_tarball.py')
46 48 sh('mv ipython-*.tgz %s' % ipbackupdir)
47 49
48 50 # Build release files
49 51 sh('./build_release %s' % ipdir)
50 52
51 53 # Register with the Python Package Index (PyPI)
52 54 print( 'Registering with PyPI...')
53 55 cd(ipdir)
54 56 sh('./setup.py register')
55 57
56 58 # Upload all files
57 59 sh(sdists + ' upload')
58 60 for py in ('2.7', '3.4'):
59 61 sh('python%s setupegg.py bdist_wheel upload' % py)
60 62
61 63 cd(distdir)
62 64 print( 'Uploading distribution files...')
63 65
64 66 for fname in os.listdir('.'):
65 67 # TODO: update to GitHub releases API
66 68 continue
67 69 print('uploading %s to GitHub' % fname)
68 70 desc = "IPython %s source distribution" % version
69 71 post_download("ipython/ipython", fname, description=desc)
70 72
71 73 # Make target dir if it doesn't exist
72 74 sh('ssh %s "mkdir -p %s/release/%s" ' % (archive_user, archive_dir, version))
73 75 sh('scp * %s' % release_site)
74 76
75 77 print( 'Uploading backup files...')
76 78 cd(ipbackupdir)
77 79 sh('scp `ls -1tr *tgz | tail -1` %s' % backup_site)
78 80
79 81 print('Done!')
@@ -1,61 +1,68 b''
1 1 """Various utilities common to IPython release and maintenance tools.
2 2 """
3 3 from __future__ import print_function
4 4
5 5 # Library imports
6 6 import os
7 7 import sys
8 8
9 9 # Useful shorthands
10 10 pjoin = os.path.join
11 11 cd = os.chdir
12 12
13 13 # Constants
14 14
15 15 # SSH root address of the archive site
16 16 archive_user = 'ipython@archive.ipython.org'
17 17 archive_dir = 'archive.ipython.org'
18 18 archive = '%s:%s' % (archive_user, archive_dir)
19 19
20 20 # Build commands
21 21 # Source dists
22 22 sdists = './setup.py sdist --formats=gztar,zip'
23 23 # Binary dists
24 24 wheels = './setupegg.py bdist_wheel'
25 25
26 26 # Utility functions
27 27 def sh(cmd):
28 28 """Run system command in shell, raise SystemExit if it returns an error."""
29 29 print("$", cmd)
30 30 stat = os.system(cmd)
31 31 #stat = 0 # Uncomment this and comment previous to run in debug mode
32 32 if stat:
33 33 raise SystemExit("Command %s failed with code: %s" % (cmd, stat))
34 34
35 35 # Backwards compatibility
36 36 c = sh
37 37
38 38 def get_ipdir():
39 39 """Get IPython directory from command line, or assume it's the one above."""
40 40
41 41 # Initialize arguments and check location
42 42 try:
43 43 ipdir = sys.argv[1]
44 44 except IndexError:
45 45 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
46 46
47 47 ipdir = os.path.abspath(ipdir)
48 48
49 49 cd(ipdir)
50 50 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
51 51 raise SystemExit('Invalid ipython directory: %s' % ipdir)
52 52 return ipdir
53 53
54 54
55 55 def compile_tree():
56 56 """Compile all Python files below current directory."""
57 57 stat = os.system('python -m compileall .')
58 58 if stat:
59 59 msg = '*** ERROR: Some Python files in tree do NOT compile! ***\n'
60 60 msg += 'See messages above for the actual file that produced it.\n'
61 61 raise SystemExit(msg)
62
63 try:
64 execfile
65 except NameError:
66 def execfile(fname, globs, locs=None):
67 locs = locs or globs
68 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
General Comments 0
You need to be logged in to leave comments. Login now