Show More
@@ -1,252 +1,257 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-2010, 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.txt, distributed with this software. |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Minimal Python version sanity check |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | |
|
24 | 24 | import sys |
|
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[0:3] < '2.6': |
|
29 | 29 | error = """\ |
|
30 | 30 | ERROR: 'IPython requires Python Version 2.6 or above.' |
|
31 | 31 | Exiting.""" |
|
32 | 32 | print >> sys.stderr, error |
|
33 | 33 | sys.exit(1) |
|
34 | 34 | |
|
35 | 35 | # At least we're on the python version we need, move on. |
|
36 | 36 | |
|
37 | 37 | #------------------------------------------------------------------------------- |
|
38 | 38 | # Imports |
|
39 | 39 | #------------------------------------------------------------------------------- |
|
40 | 40 | |
|
41 | 41 | # Stdlib imports |
|
42 | 42 | import os |
|
43 | 43 | import shutil |
|
44 | 44 | |
|
45 | 45 | from glob import glob |
|
46 | 46 | |
|
47 | 47 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
48 | 48 | # update it when the contents of directories change. |
|
49 | 49 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
50 | 50 | |
|
51 | 51 | from distutils.core import setup |
|
52 | 52 | |
|
53 | 53 | # Our own imports |
|
54 | 54 | from IPython.utils.path import target_update |
|
55 | 55 | |
|
56 | 56 | from setupbase import ( |
|
57 | 57 | setup_args, |
|
58 | 58 | find_packages, |
|
59 | 59 | find_package_data, |
|
60 | 60 | find_scripts, |
|
61 | 61 | find_data_files, |
|
62 | 62 | check_for_dependencies, |
|
63 | 63 | record_commit_info, |
|
64 | 64 | ) |
|
65 | 65 | |
|
66 | 66 | isfile = os.path.isfile |
|
67 | 67 | pjoin = os.path.join |
|
68 | 68 | |
|
69 | 69 | #----------------------------------------------------------------------------- |
|
70 | 70 | # Function definitions |
|
71 | 71 | #----------------------------------------------------------------------------- |
|
72 | 72 | |
|
73 | 73 | def cleanup(): |
|
74 | 74 | """Clean up the junk left around by the build process""" |
|
75 | 75 | if "develop" not in sys.argv: |
|
76 | 76 | try: |
|
77 | 77 | shutil.rmtree('ipython.egg-info') |
|
78 | 78 | except: |
|
79 | 79 | try: |
|
80 | 80 | os.unlink('ipython.egg-info') |
|
81 | 81 | except: |
|
82 | 82 | pass |
|
83 | 83 | |
|
84 | 84 | #------------------------------------------------------------------------------- |
|
85 | 85 | # Handle OS specific things |
|
86 | 86 | #------------------------------------------------------------------------------- |
|
87 | 87 | |
|
88 | 88 | if os.name == 'posix': |
|
89 | 89 | os_name = 'posix' |
|
90 | 90 | elif os.name in ['nt','dos']: |
|
91 | 91 | os_name = 'windows' |
|
92 | 92 | else: |
|
93 | 93 | print 'Unsupported operating system:',os.name |
|
94 | 94 | sys.exit(1) |
|
95 | 95 | |
|
96 | 96 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
97 | 97 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
98 | 98 | # actually works. |
|
99 | 99 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
100 | 100 | print 'The sdist command is not available under Windows. Exiting.' |
|
101 | 101 | sys.exit(1) |
|
102 | 102 | |
|
103 | 103 | #------------------------------------------------------------------------------- |
|
104 | 104 | # Things related to the IPython documentation |
|
105 | 105 | #------------------------------------------------------------------------------- |
|
106 | 106 | |
|
107 | 107 | # update the manuals when building a source dist |
|
108 | 108 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
109 | 109 | import textwrap |
|
110 | 110 | |
|
111 | 111 | # List of things to be updated. Each entry is a triplet of args for |
|
112 | 112 | # target_update() |
|
113 | 113 | to_update = [ |
|
114 | 114 | # FIXME - Disabled for now: we need to redo an automatic way |
|
115 | 115 | # of generating the magic info inside the rst. |
|
116 | 116 | #('docs/magic.tex', |
|
117 | 117 | #['IPython/Magic.py'], |
|
118 | 118 | #"cd doc && ./update_magic.sh" ), |
|
119 | 119 | |
|
120 | 120 | ('docs/man/ipcluster.1.gz', |
|
121 | 121 | ['docs/man/ipcluster.1'], |
|
122 | 122 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
123 | 123 | |
|
124 | 124 | ('docs/man/ipcontroller.1.gz', |
|
125 | 125 | ['docs/man/ipcontroller.1'], |
|
126 | 126 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
127 | 127 | |
|
128 | 128 | ('docs/man/ipengine.1.gz', |
|
129 | 129 | ['docs/man/ipengine.1'], |
|
130 | 130 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
131 | 131 | |
|
132 | 132 | ('docs/man/ipython.1.gz', |
|
133 | 133 | ['docs/man/ipython.1'], |
|
134 | 134 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
135 | 135 | |
|
136 | 136 | ('docs/man/ipython-wx.1.gz', |
|
137 | 137 | ['docs/man/ipython-wx.1'], |
|
138 | 138 | 'cd docs/man && gzip -9c ipython-wx.1 > ipython-wx.1.gz'), |
|
139 | 139 | |
|
140 | 140 | ('docs/man/ipythonx.1.gz', |
|
141 | 141 | ['docs/man/ipythonx.1'], |
|
142 | 142 | 'cd docs/man && gzip -9c ipythonx.1 > ipythonx.1.gz'), |
|
143 | 143 | |
|
144 | 144 | ('docs/man/irunner.1.gz', |
|
145 | 145 | ['docs/man/irunner.1'], |
|
146 | 146 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
147 | 147 | |
|
148 | 148 | ('docs/man/pycolor.1.gz', |
|
149 | 149 | ['docs/man/pycolor.1'], |
|
150 | 150 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
151 | 151 | ] |
|
152 | 152 | |
|
153 | 153 | # Only build the docs if sphinx is present |
|
154 | 154 | try: |
|
155 | 155 | import sphinx |
|
156 | 156 | except ImportError: |
|
157 | 157 | pass |
|
158 | 158 | else: |
|
159 | 159 | # The Makefile calls the do_sphinx scripts to build html and pdf, so |
|
160 | 160 | # just one target is enough to cover all manual generation |
|
161 | 161 | |
|
162 | 162 | # First, compute all the dependencies that can force us to rebuild the |
|
163 | 163 | # docs. Start with the main release file that contains metadata |
|
164 | 164 | docdeps = ['IPython/core/release.py'] |
|
165 | 165 | # Inculde all the reST sources |
|
166 | 166 | pjoin = os.path.join |
|
167 | 167 | for dirpath,dirnames,filenames in os.walk('docs/source'): |
|
168 | 168 | if dirpath in ['_static','_templates']: |
|
169 | 169 | continue |
|
170 | 170 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
171 | 171 | if f.endswith('.txt') ] |
|
172 | 172 | # and the examples |
|
173 | 173 | for dirpath,dirnames,filenames in os.walk('docs/example'): |
|
174 | 174 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
175 | 175 | if not f.endswith('~') ] |
|
176 | 176 | # then, make them all dependencies for the main PDF (the html will get |
|
177 | 177 | # auto-generated as well). |
|
178 | 178 | to_update.append( |
|
179 | 179 | ('docs/dist/ipython.pdf', |
|
180 | 180 | docdeps, |
|
181 | 181 | "cd docs && make dist") |
|
182 | 182 | ) |
|
183 | 183 | |
|
184 | 184 | [ target_update(*t) for t in to_update ] |
|
185 | 185 | |
|
186 | 186 | #--------------------------------------------------------------------------- |
|
187 | 187 | # Find all the packages, package data, and data_files |
|
188 | 188 | #--------------------------------------------------------------------------- |
|
189 | 189 | |
|
190 | 190 | packages = find_packages() |
|
191 | 191 | package_data = find_package_data() |
|
192 | 192 | data_files = find_data_files() |
|
193 | 193 | |
|
194 | 194 | #--------------------------------------------------------------------------- |
|
195 | 195 | # Handle scripts, dependencies, and setuptools specific things |
|
196 | 196 | #--------------------------------------------------------------------------- |
|
197 | 197 | |
|
198 | 198 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
199 | 199 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
200 | 200 | if len(set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', |
|
201 | 201 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
202 | 202 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', |
|
203 | 203 | )).intersection(sys.argv)) > 0: |
|
204 | 204 | import setuptools |
|
205 | 205 | |
|
206 | 206 | # This dict is used for passing extra arguments that are setuptools |
|
207 | 207 | # specific to setup |
|
208 | 208 | setuptools_extra_args = {} |
|
209 | 209 | |
|
210 | 210 | if 'setuptools' in sys.modules: |
|
211 | 211 | setuptools_extra_args['zip_safe'] = False |
|
212 | 212 | setuptools_extra_args['entry_points'] = { |
|
213 | 213 | 'console_scripts': find_scripts(True) |
|
214 | 214 | } |
|
215 | 215 | setup_args['extras_require'] = dict( |
|
216 | 216 | parallel = 'pyzmq>=2.1.4', |
|
217 | 217 | zmq = 'pyzmq>=2.0.10.1', |
|
218 | 218 | doc='Sphinx>=0.3', |
|
219 | 219 | test='nose>=0.10.1', |
|
220 | 220 | ) |
|
221 | requires = setup_args.setdefault('install_requires', []) | |
|
222 | if sys.platform == 'darwin': | |
|
223 | requires.append('readline') | |
|
224 | elif sys.platform.startswith('win'): | |
|
225 | requires.append('pyreadline') | |
|
221 | 226 | |
|
222 | 227 | # Script to be run by the windows binary installer after the default setup |
|
223 | 228 | # routine, to add shortcuts and similar windows-only things. Windows |
|
224 | 229 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
225 | 230 | # doesn't find them. |
|
226 | 231 | if 'bdist_wininst' in sys.argv: |
|
227 | 232 | if len(sys.argv) > 2 and \ |
|
228 | 233 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
229 | 234 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
230 | 235 | sys.exit(1) |
|
231 | 236 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
232 | 237 | else: |
|
233 | 238 | # If we are running without setuptools, call this function which will |
|
234 | 239 | # check for dependencies an inform the user what is needed. This is |
|
235 | 240 | # just to make life easy for users. |
|
236 | 241 | check_for_dependencies() |
|
237 | 242 | setup_args['scripts'] = find_scripts(False) |
|
238 | 243 | |
|
239 | 244 | #--------------------------------------------------------------------------- |
|
240 | 245 | # Do the actual setup now |
|
241 | 246 | #--------------------------------------------------------------------------- |
|
242 | 247 | |
|
243 | 248 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')} |
|
244 | 249 | setup_args['packages'] = packages |
|
245 | 250 | setup_args['package_data'] = package_data |
|
246 | 251 | setup_args['data_files'] = data_files |
|
247 | 252 | setup_args.update(setuptools_extra_args) |
|
248 | 253 | |
|
249 | 254 | |
|
250 | 255 | if __name__ == '__main__': |
|
251 | 256 | setup(**setup_args) |
|
252 | 257 | cleanup() |
@@ -1,387 +1,387 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | This module defines the things that are used in setup.py for building IPython |
|
4 | 4 | |
|
5 | 5 | This includes: |
|
6 | 6 | |
|
7 | 7 | * The basic arguments to setup |
|
8 | 8 | * Functions for finding things like packages, package data, etc. |
|
9 | 9 | * A function for checking dependencies. |
|
10 | 10 | """ |
|
11 | 11 | from __future__ import print_function |
|
12 | 12 | |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | # Copyright (C) 2008 The IPython Development Team |
|
15 | 15 | # |
|
16 | 16 | # Distributed under the terms of the BSD License. The full license is in |
|
17 | 17 | # the file COPYING, distributed as part of this software. |
|
18 | 18 | #------------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #------------------------------------------------------------------------------- |
|
21 | 21 | # Imports |
|
22 | 22 | #------------------------------------------------------------------------------- |
|
23 | 23 | import os |
|
24 | 24 | import sys |
|
25 | 25 | |
|
26 | 26 | from ConfigParser import ConfigParser |
|
27 | 27 | from distutils.command.build_py import build_py |
|
28 | 28 | from glob import glob |
|
29 | 29 | |
|
30 | 30 | from setupext import install_data_ext |
|
31 | 31 | |
|
32 | 32 | #------------------------------------------------------------------------------- |
|
33 | 33 | # Useful globals and utility functions |
|
34 | 34 | #------------------------------------------------------------------------------- |
|
35 | 35 | |
|
36 | 36 | # A few handy globals |
|
37 | 37 | isfile = os.path.isfile |
|
38 | 38 | pjoin = os.path.join |
|
39 | 39 | |
|
40 | 40 | def oscmd(s): |
|
41 | 41 | print(">", s) |
|
42 | 42 | os.system(s) |
|
43 | 43 | |
|
44 | 44 | # A little utility we'll need below, since glob() does NOT allow you to do |
|
45 | 45 | # exclusion on multiple endings! |
|
46 | 46 | def file_doesnt_endwith(test,endings): |
|
47 | 47 | """Return true if test is a file and its name does NOT end with any |
|
48 | 48 | of the strings listed in endings.""" |
|
49 | 49 | if not isfile(test): |
|
50 | 50 | return False |
|
51 | 51 | for e in endings: |
|
52 | 52 | if test.endswith(e): |
|
53 | 53 | return False |
|
54 | 54 | return True |
|
55 | 55 | |
|
56 | 56 | #--------------------------------------------------------------------------- |
|
57 | 57 | # Basic project information |
|
58 | 58 | #--------------------------------------------------------------------------- |
|
59 | 59 | |
|
60 | 60 | # release.py contains version, authors, license, url, keywords, etc. |
|
61 | 61 | execfile(pjoin('IPython','core','release.py')) |
|
62 | 62 | |
|
63 | 63 | # Create a dict with the basic information |
|
64 | 64 | # This dict is eventually passed to setup after additional keys are added. |
|
65 | 65 | setup_args = dict( |
|
66 | 66 | name = name, |
|
67 | 67 | version = version, |
|
68 | 68 | description = description, |
|
69 | 69 | long_description = long_description, |
|
70 | 70 | author = author, |
|
71 | 71 | author_email = author_email, |
|
72 | 72 | url = url, |
|
73 | 73 | download_url = download_url, |
|
74 | 74 | license = license, |
|
75 | 75 | platforms = platforms, |
|
76 | 76 | keywords = keywords, |
|
77 | 77 | cmdclass = {'install_data': install_data_ext}, |
|
78 | 78 | ) |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | #--------------------------------------------------------------------------- |
|
82 | 82 | # Find packages |
|
83 | 83 | #--------------------------------------------------------------------------- |
|
84 | 84 | |
|
85 | 85 | def add_package(packages,pname,config=False,tests=False,scripts=False, |
|
86 | 86 | others=None): |
|
87 | 87 | """ |
|
88 | 88 | Add a package to the list of packages, including certain subpackages. |
|
89 | 89 | """ |
|
90 | 90 | packages.append('.'.join(['IPython',pname])) |
|
91 | 91 | if config: |
|
92 | 92 | packages.append('.'.join(['IPython',pname,'config'])) |
|
93 | 93 | if tests: |
|
94 | 94 | packages.append('.'.join(['IPython',pname,'tests'])) |
|
95 | 95 | if scripts: |
|
96 | 96 | packages.append('.'.join(['IPython',pname,'scripts'])) |
|
97 | 97 | if others is not None: |
|
98 | 98 | for o in others: |
|
99 | 99 | packages.append('.'.join(['IPython',pname,o])) |
|
100 | 100 | |
|
101 | 101 | def find_packages(): |
|
102 | 102 | """ |
|
103 | 103 | Find all of IPython's packages. |
|
104 | 104 | """ |
|
105 | 105 | packages = ['IPython'] |
|
106 | 106 | add_package(packages, 'config', tests=True, others=['default','profile']) |
|
107 | 107 | add_package(packages, 'core', tests=True) |
|
108 | 108 | add_package(packages, 'deathrow', tests=True) |
|
109 | 109 | add_package(packages, 'extensions') |
|
110 | 110 | add_package(packages, 'external') |
|
111 | 111 | add_package(packages, 'external.argparse') |
|
112 | 112 | add_package(packages, 'external.configobj') |
|
113 | 113 | add_package(packages, 'external.decorator') |
|
114 | 114 | add_package(packages, 'external.decorators') |
|
115 | 115 | add_package(packages, 'external.guid') |
|
116 | 116 | add_package(packages, 'external.Itpl') |
|
117 | 117 | add_package(packages, 'external.mglob') |
|
118 | 118 | add_package(packages, 'external.path') |
|
119 | 119 | add_package(packages, 'external.pexpect') |
|
120 | 120 | add_package(packages, 'external.pyparsing') |
|
121 | 121 | add_package(packages, 'external.simplegeneric') |
|
122 | 122 | add_package(packages, 'external.ssh') |
|
123 | 123 | add_package(packages, 'external.validate') |
|
124 | 124 | add_package(packages, 'kernel') |
|
125 | 125 | add_package(packages, 'frontend') |
|
126 | 126 | add_package(packages, 'frontend.qt') |
|
127 | 127 | add_package(packages, 'frontend.qt.console', tests=True) |
|
128 | 128 | add_package(packages, 'frontend.terminal', tests=True) |
|
129 | 129 | add_package(packages, 'lib', tests=True) |
|
130 | 130 | add_package(packages, 'parallel', tests=True, scripts=True, |
|
131 | 131 | others=['apps','engine','client','controller']) |
|
132 | 132 | add_package(packages, 'quarantine', tests=True) |
|
133 | 133 | add_package(packages, 'scripts') |
|
134 | 134 | add_package(packages, 'testing', tests=True) |
|
135 | 135 | add_package(packages, 'testing.plugin', tests=False) |
|
136 | 136 | add_package(packages, 'utils', tests=True) |
|
137 | 137 | add_package(packages, 'zmq') |
|
138 | 138 | add_package(packages, 'zmq.pylab') |
|
139 | 139 | return packages |
|
140 | 140 | |
|
141 | 141 | #--------------------------------------------------------------------------- |
|
142 | 142 | # Find package data |
|
143 | 143 | #--------------------------------------------------------------------------- |
|
144 | 144 | |
|
145 | 145 | def find_package_data(): |
|
146 | 146 | """ |
|
147 | 147 | Find IPython's package_data. |
|
148 | 148 | """ |
|
149 | 149 | # This is not enough for these things to appear in an sdist. |
|
150 | 150 | # We need to muck with the MANIFEST to get this to work |
|
151 | 151 | package_data = { |
|
152 | 152 | 'IPython.config.userconfig' : ['*'], |
|
153 | 153 | 'IPython.testing' : ['*.txt'] |
|
154 | 154 | } |
|
155 | 155 | return package_data |
|
156 | 156 | |
|
157 | 157 | |
|
158 | 158 | #--------------------------------------------------------------------------- |
|
159 | 159 | # Find data files |
|
160 | 160 | #--------------------------------------------------------------------------- |
|
161 | 161 | |
|
162 | 162 | def make_dir_struct(tag,base,out_base): |
|
163 | 163 | """Make the directory structure of all files below a starting dir. |
|
164 | 164 | |
|
165 | 165 | This is just a convenience routine to help build a nested directory |
|
166 | 166 | hierarchy because distutils is too stupid to do this by itself. |
|
167 | 167 | |
|
168 | 168 | XXX - this needs a proper docstring! |
|
169 | 169 | """ |
|
170 | 170 | |
|
171 | 171 | # we'll use these a lot below |
|
172 | 172 | lbase = len(base) |
|
173 | 173 | pathsep = os.path.sep |
|
174 | 174 | lpathsep = len(pathsep) |
|
175 | 175 | |
|
176 | 176 | out = [] |
|
177 | 177 | for (dirpath,dirnames,filenames) in os.walk(base): |
|
178 | 178 | # we need to strip out the dirpath from the base to map it to the |
|
179 | 179 | # output (installation) path. This requires possibly stripping the |
|
180 | 180 | # path separator, because otherwise pjoin will not work correctly |
|
181 | 181 | # (pjoin('foo/','/bar') returns '/bar'). |
|
182 | 182 | |
|
183 | 183 | dp_eff = dirpath[lbase:] |
|
184 | 184 | if dp_eff.startswith(pathsep): |
|
185 | 185 | dp_eff = dp_eff[lpathsep:] |
|
186 | 186 | # The output path must be anchored at the out_base marker |
|
187 | 187 | out_path = pjoin(out_base,dp_eff) |
|
188 | 188 | # Now we can generate the final filenames. Since os.walk only produces |
|
189 | 189 | # filenames, we must join back with the dirpath to get full valid file |
|
190 | 190 | # paths: |
|
191 | 191 | pfiles = [pjoin(dirpath,f) for f in filenames] |
|
192 | 192 | # Finally, generate the entry we need, which is a pari of (output |
|
193 | 193 | # path, files) for use as a data_files parameter in install_data. |
|
194 | 194 | out.append((out_path, pfiles)) |
|
195 | 195 | |
|
196 | 196 | return out |
|
197 | 197 | |
|
198 | 198 | |
|
199 | 199 | def find_data_files(): |
|
200 | 200 | """ |
|
201 | 201 | Find IPython's data_files. |
|
202 | 202 | |
|
203 | 203 | Most of these are docs. |
|
204 | 204 | """ |
|
205 | 205 | |
|
206 | 206 | docdirbase = pjoin('share', 'doc', 'ipython') |
|
207 | 207 | manpagebase = pjoin('share', 'man', 'man1') |
|
208 | 208 | |
|
209 | 209 | # Simple file lists can be made by hand |
|
210 | 210 | manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz'))) |
|
211 | 211 | igridhelpfiles = filter(isfile, |
|
212 | 212 | glob(pjoin('IPython','extensions','igrid_help.*'))) |
|
213 | 213 | |
|
214 | 214 | # For nested structures, use the utility above |
|
215 | 215 | example_files = make_dir_struct( |
|
216 | 216 | 'data', |
|
217 | 217 | pjoin('docs','examples'), |
|
218 | 218 | pjoin(docdirbase,'examples') |
|
219 | 219 | ) |
|
220 | 220 | manual_files = make_dir_struct( |
|
221 | 221 | 'data', |
|
222 | 222 | pjoin('docs','dist'), |
|
223 | 223 | pjoin(docdirbase,'manual') |
|
224 | 224 | ) |
|
225 | 225 | |
|
226 | 226 | # And assemble the entire output list |
|
227 | 227 | data_files = [ (manpagebase, manpages), |
|
228 | 228 | (pjoin(docdirbase, 'extensions'), igridhelpfiles), |
|
229 | 229 | ] + manual_files + example_files |
|
230 | 230 | |
|
231 | 231 | return data_files |
|
232 | 232 | |
|
233 | 233 | |
|
234 | 234 | def make_man_update_target(manpage): |
|
235 | 235 | """Return a target_update-compliant tuple for the given manpage. |
|
236 | 236 | |
|
237 | 237 | Parameters |
|
238 | 238 | ---------- |
|
239 | 239 | manpage : string |
|
240 | 240 | Name of the manpage, must include the section number (trailing number). |
|
241 | 241 | |
|
242 | 242 | Example |
|
243 | 243 | ------- |
|
244 | 244 | |
|
245 | 245 | >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE |
|
246 | 246 | ('docs/man/ipython.1.gz', |
|
247 | 247 | ['docs/man/ipython.1'], |
|
248 | 248 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz') |
|
249 | 249 | """ |
|
250 | 250 | man_dir = pjoin('docs', 'man') |
|
251 | 251 | manpage_gz = manpage + '.gz' |
|
252 | 252 | manpath = pjoin(man_dir, manpage) |
|
253 | 253 | manpath_gz = pjoin(man_dir, manpage_gz) |
|
254 | 254 | gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" % |
|
255 | 255 | locals() ) |
|
256 | 256 | return (manpath_gz, [manpath], gz_cmd) |
|
257 | 257 | |
|
258 | 258 | #--------------------------------------------------------------------------- |
|
259 | 259 | # Find scripts |
|
260 | 260 | #--------------------------------------------------------------------------- |
|
261 | 261 | |
|
262 | 262 | def find_scripts(entry_points=False): |
|
263 | 263 | """Find IPython's scripts. |
|
264 | 264 | |
|
265 | 265 | if entry_points is True: |
|
266 | 266 | return setuptools entry_point-style definitions |
|
267 | 267 | else: |
|
268 | 268 | return file paths of plain scripts [default] |
|
269 | 269 | |
|
270 | 270 | """ |
|
271 | 271 | if entry_points: |
|
272 | 272 | scripts = [ |
|
273 | 273 | 'ipython = IPython.frontend.terminal.ipapp:launch_new_instance', |
|
274 | 274 | 'ipython-qtconsole = IPython.frontend.qt.console.ipythonqt:main', |
|
275 | 275 | 'pycolor = IPython.utils.PyColorize:main', |
|
276 | 276 | 'ipcontroller = IPython.parallel.apps.ipcontrollerapp:launch_new_instance', |
|
277 | 277 | 'ipengine = IPython.parallel.apps.ipengineapp:launch_new_instance', |
|
278 | 278 | 'iplogger = IPython.parallel.apps.iploggerapp:launch_new_instance', |
|
279 | 279 | 'ipcluster = IPython.parallel.apps.ipclusterapp:launch_new_instance', |
|
280 | 280 | 'iptest = IPython.testing.iptest:main', |
|
281 | 281 | 'irunner = IPython.lib.irunner:main' |
|
282 | 282 | ] |
|
283 | 283 | else: |
|
284 | 284 | parallel_scripts = pjoin('IPython','parallel','scripts') |
|
285 | 285 | main_scripts = pjoin('IPython','scripts') |
|
286 | 286 | scripts = [ |
|
287 | 287 | pjoin(parallel_scripts, 'ipengine'), |
|
288 | 288 | pjoin(parallel_scripts, 'ipcontroller'), |
|
289 | 289 | pjoin(parallel_scripts, 'ipcluster'), |
|
290 | 290 | pjoin(parallel_scripts, 'iplogger'), |
|
291 | 291 | pjoin(main_scripts, 'ipython'), |
|
292 | 292 | pjoin(main_scripts, 'ipython-qtconsole'), |
|
293 | 293 | pjoin(main_scripts, 'pycolor'), |
|
294 | 294 | pjoin(main_scripts, 'irunner'), |
|
295 | 295 | pjoin(main_scripts, 'iptest') |
|
296 | 296 | ] |
|
297 | 297 | |
|
298 | 298 | return scripts |
|
299 | 299 | |
|
300 | 300 | #--------------------------------------------------------------------------- |
|
301 | 301 | # Verify all dependencies |
|
302 | 302 | #--------------------------------------------------------------------------- |
|
303 | 303 | |
|
304 | 304 | def check_for_dependencies(): |
|
305 | 305 | """Check for IPython's dependencies. |
|
306 | 306 | |
|
307 | 307 | This function should NOT be called if running under setuptools! |
|
308 | 308 | """ |
|
309 | 309 | from setupext.setupext import ( |
|
310 | 310 | print_line, print_raw, print_status, |
|
311 | 311 | check_for_sphinx, check_for_pygments, |
|
312 | 312 | check_for_nose, check_for_pexpect, |
|
313 | check_for_pyzmq | |
|
313 | check_for_pyzmq, check_for_readline | |
|
314 | 314 | ) |
|
315 | 315 | print_line() |
|
316 | 316 | print_raw("BUILDING IPYTHON") |
|
317 | 317 | print_status('python', sys.version) |
|
318 | 318 | print_status('platform', sys.platform) |
|
319 | 319 | if sys.platform == 'win32': |
|
320 | 320 | print_status('Windows version', sys.getwindowsversion()) |
|
321 | 321 | |
|
322 | 322 | print_raw("") |
|
323 | 323 | print_raw("OPTIONAL DEPENDENCIES") |
|
324 | 324 | |
|
325 | 325 | check_for_sphinx() |
|
326 | 326 | check_for_pygments() |
|
327 | 327 | check_for_nose() |
|
328 | 328 | check_for_pexpect() |
|
329 | 329 | check_for_pyzmq() |
|
330 | ||
|
330 | check_for_readline() | |
|
331 | 331 | |
|
332 | 332 | def record_commit_info(pkg_dir, build_cmd=build_py): |
|
333 | 333 | """ Return extended build command class for recording commit |
|
334 | 334 | |
|
335 | 335 | The extended command tries to run git to find the current commit, getting |
|
336 | 336 | the empty string if it fails. It then writes the commit hash into a file |
|
337 | 337 | in the `pkg_dir` path, named ``.git_commit_info.ini``. |
|
338 | 338 | |
|
339 | 339 | In due course this information can be used by the package after it is |
|
340 | 340 | installed, to tell you what commit it was installed from if known. |
|
341 | 341 | |
|
342 | 342 | To make use of this system, you need a package with a .git_commit_info.ini |
|
343 | 343 | file - e.g. ``myproject/.git_commit_info.ini`` - that might well look like |
|
344 | 344 | this:: |
|
345 | 345 | |
|
346 | 346 | # This is an ini file that may contain information about the code state |
|
347 | 347 | [commit hash] |
|
348 | 348 | # The line below may contain a valid hash if it has been substituted |
|
349 | 349 | # during 'git archive' |
|
350 | 350 | archive_subst_hash=$Format:%h$ |
|
351 | 351 | # This line may be modified by the install process |
|
352 | 352 | install_hash= |
|
353 | 353 | |
|
354 | 354 | The .git_commit_info file above is also designed to be used with git |
|
355 | 355 | substitution - so you probably also want a ``.gitattributes`` file in the |
|
356 | 356 | root directory of your working tree that contains something like this:: |
|
357 | 357 | |
|
358 | 358 | myproject/.git_commit_info.ini export-subst |
|
359 | 359 | |
|
360 | 360 | That will cause the ``.git_commit_info.ini`` file to get filled in by ``git |
|
361 | 361 | archive`` - useful in case someone makes such an archive - for example with |
|
362 | 362 | via the github 'download source' button. |
|
363 | 363 | |
|
364 | 364 | Although all the above will work as is, you might consider having something |
|
365 | 365 | like a ``get_info()`` function in your package to display the commit |
|
366 | 366 | information at the terminal. See the ``pkg_info.py`` module in the nipy |
|
367 | 367 | package for an example. |
|
368 | 368 | """ |
|
369 | 369 | class MyBuildPy(build_cmd): |
|
370 | 370 | ''' Subclass to write commit data into installation tree ''' |
|
371 | 371 | def run(self): |
|
372 | 372 | build_py.run(self) |
|
373 | 373 | import subprocess |
|
374 | 374 | proc = subprocess.Popen('git rev-parse --short HEAD', |
|
375 | 375 | stdout=subprocess.PIPE, |
|
376 | 376 | stderr=subprocess.PIPE, |
|
377 | 377 | shell=True) |
|
378 | 378 | repo_commit, _ = proc.communicate() |
|
379 | 379 | # We write the installation commit even if it's empty |
|
380 | 380 | cfg_parser = ConfigParser() |
|
381 | 381 | cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini')) |
|
382 | 382 | cfg_parser.set('commit hash', 'install_hash', repo_commit) |
|
383 | 383 | out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini') |
|
384 | 384 | out_file = open(out_pth, 'wt') |
|
385 | 385 | cfg_parser.write(out_file) |
|
386 | 386 | out_file.close() |
|
387 | 387 | return MyBuildPy |
@@ -1,142 +1,157 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | __docformat__ = "restructuredtext en" |
|
4 | 4 | |
|
5 | 5 | #------------------------------------------------------------------------------- |
|
6 | 6 | # Copyright (C) 2008 The IPython Development Team |
|
7 | 7 | # |
|
8 | 8 | # Distributed under the terms of the BSD License. The full license is in |
|
9 | 9 | # the file COPYING, distributed as part of this software. |
|
10 | 10 | #------------------------------------------------------------------------------- |
|
11 | 11 | |
|
12 | 12 | #------------------------------------------------------------------------------- |
|
13 | 13 | # Imports |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | import sys, os |
|
17 | 17 | from textwrap import fill |
|
18 | 18 | |
|
19 | 19 | display_status=True |
|
20 | 20 | |
|
21 | 21 | if display_status: |
|
22 | 22 | def print_line(char='='): |
|
23 | 23 | print char * 76 |
|
24 | 24 | |
|
25 | 25 | def print_status(package, status): |
|
26 | 26 | initial_indent = "%22s: " % package |
|
27 | 27 | indent = ' ' * 24 |
|
28 | 28 | print fill(str(status), width=76, |
|
29 | 29 | initial_indent=initial_indent, |
|
30 | 30 | subsequent_indent=indent) |
|
31 | 31 | |
|
32 | 32 | def print_message(message): |
|
33 | 33 | indent = ' ' * 24 + "* " |
|
34 | 34 | print fill(str(message), width=76, |
|
35 | 35 | initial_indent=indent, |
|
36 | 36 | subsequent_indent=indent) |
|
37 | 37 | |
|
38 | 38 | def print_raw(section): |
|
39 | 39 | print section |
|
40 | 40 | else: |
|
41 | 41 | def print_line(*args, **kwargs): |
|
42 | 42 | pass |
|
43 | 43 | print_status = print_message = print_raw = print_line |
|
44 | 44 | |
|
45 | 45 | #------------------------------------------------------------------------------- |
|
46 | 46 | # Tests for specific packages |
|
47 | 47 | #------------------------------------------------------------------------------- |
|
48 | 48 | |
|
49 | 49 | def check_for_ipython(): |
|
50 | 50 | try: |
|
51 | 51 | import IPython |
|
52 | 52 | except ImportError: |
|
53 | 53 | print_status("IPython", "Not found") |
|
54 | 54 | return False |
|
55 | 55 | else: |
|
56 | 56 | print_status("IPython", IPython.__version__) |
|
57 | 57 | return True |
|
58 | 58 | |
|
59 | 59 | def check_for_sphinx(): |
|
60 | 60 | try: |
|
61 | 61 | import sphinx |
|
62 | 62 | except ImportError: |
|
63 | 63 | print_status('sphinx', "Not found (required for building documentation)") |
|
64 | 64 | return False |
|
65 | 65 | else: |
|
66 | 66 | print_status('sphinx', sphinx.__version__) |
|
67 | 67 | return True |
|
68 | 68 | |
|
69 | 69 | def check_for_pygments(): |
|
70 | 70 | try: |
|
71 | 71 | import pygments |
|
72 | 72 | except ImportError: |
|
73 | 73 | print_status('pygments', "Not found (required for syntax highlighting documentation)") |
|
74 | 74 | return False |
|
75 | 75 | else: |
|
76 | 76 | print_status('pygments', pygments.__version__) |
|
77 | 77 | return True |
|
78 | 78 | |
|
79 | 79 | def check_for_nose(): |
|
80 | 80 | try: |
|
81 | 81 | import nose |
|
82 | 82 | except ImportError: |
|
83 | 83 | print_status('nose', "Not found (required for running the test suite)") |
|
84 | 84 | return False |
|
85 | 85 | else: |
|
86 | 86 | print_status('nose', nose.__version__) |
|
87 | 87 | return True |
|
88 | 88 | |
|
89 | 89 | def check_for_pexpect(): |
|
90 | 90 | try: |
|
91 | 91 | import pexpect |
|
92 | 92 | except ImportError: |
|
93 | 93 | print_status("pexpect", "no (required for running standalone doctests)") |
|
94 | 94 | return False |
|
95 | 95 | else: |
|
96 | 96 | print_status("pexpect", pexpect.__version__) |
|
97 | 97 | return True |
|
98 | 98 | |
|
99 | 99 | def check_for_httplib2(): |
|
100 | 100 | try: |
|
101 | 101 | import httplib2 |
|
102 | 102 | except ImportError: |
|
103 | 103 | print_status("httplib2", "no (required for blocking http clients)") |
|
104 | 104 | return False |
|
105 | 105 | else: |
|
106 | 106 | print_status("httplib2","yes") |
|
107 | 107 | return True |
|
108 | 108 | |
|
109 | 109 | def check_for_sqlalchemy(): |
|
110 | 110 | try: |
|
111 | 111 | import sqlalchemy |
|
112 | 112 | except ImportError: |
|
113 | 113 | print_status("sqlalchemy", "no (required for the ipython1 notebook)") |
|
114 | 114 | return False |
|
115 | 115 | else: |
|
116 | 116 | print_status("sqlalchemy","yes") |
|
117 | 117 | return True |
|
118 | 118 | |
|
119 | 119 | def check_for_simplejson(): |
|
120 | 120 | try: |
|
121 | 121 | import simplejson |
|
122 | 122 | except ImportError: |
|
123 | 123 | print_status("simplejson", "no (required for the ipython1 notebook)") |
|
124 | 124 | return False |
|
125 | 125 | else: |
|
126 | 126 | print_status("simplejson","yes") |
|
127 | 127 | return True |
|
128 | 128 | |
|
129 | 129 | def check_for_pyzmq(): |
|
130 | 130 | try: |
|
131 | 131 | import zmq |
|
132 | 132 | except ImportError: |
|
133 | 133 | print_status('pyzmq', "no (required for qtconsole and parallel computing capabilities)") |
|
134 | 134 | return False |
|
135 | 135 | else: |
|
136 | 136 | if zmq.__version__ < '2.0.10': |
|
137 | 137 | print_status('pyzmq', "no (require >= 2.0.10 for qtconsole and parallel computing capabilities)") |
|
138 | 138 | |
|
139 | 139 | else: |
|
140 | 140 | print_status("pyzmq", zmq.__version__) |
|
141 | 141 | return True |
|
142 | 142 | |
|
143 | def check_for_readline(): | |
|
144 | try: | |
|
145 | import readline | |
|
146 | except ImportError: | |
|
147 | try: | |
|
148 | import pyreadline | |
|
149 | except ImportError: | |
|
150 | print_status('readline', "no (required for good interactive behavior)") | |
|
151 | return False | |
|
152 | else: | |
|
153 | print_status('readline', "yes pyreadline-"+pyreadline.release.version) | |
|
154 | return True | |
|
155 | else: | |
|
156 | print_status('readline', "yes") | |
|
157 | return True |
General Comments 0
You need to be logged in to leave comments.
Login now