~ellisonbg/ipython/bugfixes0411409

0.1.31 by Ville M. Vainio
more crlf
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
"""Setup script for IPython.
4
5
Under Posix environments it works like a typical setup.py script. 
6
Under Windows, the command sdist is not supported, since IPython 
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
7
requires utilities which are not available under Windows."""
0.1.31 by Ville M. Vainio
more crlf
8
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
9
#-------------------------------------------------------------------------------
10
#  Copyright (C) 2008  The IPython Development Team
0.1.31 by Ville M. Vainio
more crlf
11
#
12
#  Distributed under the terms of the BSD License.  The full license is in
13
#  the file COPYING, distributed as part of this software.
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
14
#-------------------------------------------------------------------------------
15
16
#-------------------------------------------------------------------------------
17
# Imports
18
#-------------------------------------------------------------------------------
0.1.31 by Ville M. Vainio
more crlf
19
20
# Stdlib imports
21
import os
22
import sys
23
24
from glob import glob
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
25
26
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
27
# update it when the contents of directories change.
28
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
29
30
from distutils.core import setup
0.1.31 by Ville M. Vainio
more crlf
31
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
32
# Local imports
33
from IPython.genutils import target_update
34
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
35
from setupbase import (
36
    setup_args, 
37
    find_packages, 
38
    find_package_data, 
39
    find_scripts,
40
    find_data_files,
41
    check_for_dependencies
42
)
43
0.1.31 by Ville M. Vainio
more crlf
44
isfile = os.path.isfile
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
45
46
#-------------------------------------------------------------------------------
47
# Handle OS specific things
48
#-------------------------------------------------------------------------------
0.1.31 by Ville M. Vainio
more crlf
49
50
if os.name == 'posix':
51
    os_name = 'posix'
52
elif os.name in ['nt','dos']:
53
    os_name = 'windows'
54
else:
55
    print 'Unsupported operating system:',os.name
56
    sys.exit(1)
57
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
58
# Under Windows, 'sdist' has not been supported.  Now that the docs build with
59
# Sphinx it might work, but let's not turn it on until someone confirms that it
60
# actually works.
0.1.31 by Ville M. Vainio
more crlf
61
if os_name == 'windows' and 'sdist' in sys.argv:
62
    print 'The sdist command is not available under Windows.  Exiting.'
63
    sys.exit(1)
64
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
65
#-------------------------------------------------------------------------------
66
# Things related to the IPython documentation
67
#-------------------------------------------------------------------------------
68
0.1.31 by Ville M. Vainio
more crlf
69
# update the manuals when building a source dist
70
if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
0.1.107 by Ville M. Vainio
Updated setup.py and do_sphinx.py for new manual distribution
71
    import textwrap
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
72
73
    # List of things to be updated. Each entry is a triplet of args for
0.1.31 by Ville M. Vainio
more crlf
74
    # target_update()
1001.1.8 by Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems
75
    to_update = [
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
76
                  # FIXME - Disabled for now: we need to redo an automatic way
77
                  # of generating the magic info inside the rst.                
1095 by Fernando Perez
Fixes to build system.
78
                  #('docs/magic.tex',
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
79
                  #['IPython/Magic.py'],
80
                  #"cd doc && ./update_magic.sh" ),
81
                 
1095 by Fernando Perez
Fixes to build system.
82
                 ('docs/man/ipython.1.gz',
83
                  ['docs/man/ipython.1'],
84
                  "cd docs/man && gzip -9c ipython.1 > ipython.1.gz"),
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
85
1095 by Fernando Perez
Fixes to build system.
86
                 ('docs/man/pycolor.1.gz',
87
                  ['docs/man/pycolor.1'],
88
                  "cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz"),
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
89
                 ]
90
1102.1.23 by Fernando Perez
Final updates for releasing the 0.9.rc1.
91
    # Only build the docs if sphinx is present
1001.1.8 by Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems
92
    try:
93
        import sphinx
94
    except ImportError:
95
        pass
96
    else:
1102.1.23 by Fernando Perez
Final updates for releasing the 0.9.rc1.
97
        # The Makefile calls the do_sphinx scripts to build html and pdf, so
98
        # just one target is enough to cover all manual generation
99
100
        # First, compute all the dependencies that can force us to rebuild the
101
        # docs.  Start with the main release file that contains metadata
102
        docdeps = ['IPython/Release.py']
103
        # Inculde all the reST sources
104
        pjoin = os.path.join
105
        for dirpath,dirnames,filenames in os.walk('docs/source'):
106
            if dirpath in ['_static','_templates']:
107
                continue
108
            docdeps += [ pjoin(dirpath,f) for f in filenames
109
                         if f.endswith('.txt') ]
110
        # and the examples
111
        for dirpath,dirnames,filenames in os.walk('docs/example'):
112
            docdeps += [ pjoin(dirpath,f) for f in filenames
113
                         if not f.endswith('~') ]
114
        # then, make them all dependencies for the main PDF (the html will get
115
        # auto-generated as well).
116
        to_update.append(
117
            ('docs/dist/ipython.pdf',
118
             docdeps,
119
             "cd docs && make dist")
120
            )
1098 by Fernando Perez
Fixes to build/setup machinery.
121
        
0.15.6 by Fernando Perez
Finish doc/build tools cleanup.
122
    [ target_update(*t) for t in to_update ]
0.1.31 by Ville M. Vainio
more crlf
123
1098 by Fernando Perez
Fixes to build/setup machinery.
124
    
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
125
#---------------------------------------------------------------------------
126
# Find all the packages, package data, scripts and data_files
127
#---------------------------------------------------------------------------
128
129
packages = find_packages()
130
package_data = find_package_data()
131
scripts = find_scripts()
132
data_files = find_data_files()
133
134
#---------------------------------------------------------------------------
135
# Handle dependencies and setuptools specific things
136
#---------------------------------------------------------------------------
137
138
# This dict is used for passing extra arguments that are setuptools 
139
# specific to setup
140
setuptools_extra_args = {}
0.1.31 by Ville M. Vainio
more crlf
141
142
if 'setuptools' in sys.modules:
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
143
    setuptools_extra_args['zip_safe'] = False
144
    setuptools_extra_args['entry_points'] = {
145
        'console_scripts': [
0.1.31 by Ville M. Vainio
more crlf
146
            'ipython = IPython.ipapi:launch_new_instance',
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
147
            'pycolor = IPython.PyColorize:main',
148
            'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
149
            'ipengine = IPython.kernel.scripts.ipengine:main',
1007.3.66 by gvaroquaux
Add entry point for ipythonx to setup.py, when used with setuptools.
150
            'ipcluster = IPython.kernel.scripts.ipcluster:main',
1102.1.13 by Fernando Perez
Fix decorator bug and update build scripts to use setuptools for iptest.
151
            'ipythonx = IPython.frontend.wx.ipythonx:main',
152
            'iptest = IPython.testing.iptest:main',
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
153
        ]
154
    }
1109.1.6 by Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
155
    setup_args['extras_require'] = dict(
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
156
        kernel = [
1109.1.6 by Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
157
            'zope.interface>=3.4.1',
158
            'Twisted>=8.0.1',
159
            'foolscap>=0.2.6'
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
160
        ],
1109.1.6 by Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
161
        doc='Sphinx>=0.3',
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
162
        test='nose>=0.10.1',
1109.1.6 by Brian Granger
Skipping a few tests related to the wx frontend that fail on Windows.
163
        security='pyOpenSSL>=0.6'
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
164
    )
165
    # Allow setuptools to handle the scripts
166
    scripts = []
0.1.31 by Ville M. Vainio
more crlf
167
else:
0.1.100 by ville
setup.py: use package_data to grab UserConfig files, install UserConfig as normal package
168
    # package_data of setuptools was introduced to distutils in 2.4
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
169
    cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
0.1.100 by ville
setup.py: use package_data to grab UserConfig files, install UserConfig as normal package
170
    if sys.version_info < (2,4):
1001.1.4 by Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages
171
        data_files.append(('lib', 'IPython/UserConfig', cfgfiles))
172
    # If we are running without setuptools, call this function which will
173
    # check for dependencies an inform the user what is needed.  This is
174
    # just to make life easy for users.
175
    check_for_dependencies()
176
177
178
#---------------------------------------------------------------------------
179
# Do the actual setup now
180
#---------------------------------------------------------------------------
181
182
setup_args['packages'] = packages
183
setup_args['package_data'] = package_data
184
setup_args['scripts'] = scripts
185
setup_args['data_files'] = data_files
186
setup_args.update(setuptools_extra_args)
187
188
if __name__ == '__main__':
189
    setup(**setup_args)