##// END OF EJS Templates
Fixing the setup.py script under setuptools and the __init__.py script.
Brian Granger -
Show More
@@ -1,72 +1,72 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 One of Python's nicest features is its interactive interpreter. This allows
5 One of Python's nicest features is its interactive interpreter. This allows
6 very fast testing of ideas without the overhead of creating test files as is
6 very fast testing of ideas without the overhead of creating test files as is
7 typical in most programming languages. However, the interpreter supplied with
7 typical in most programming languages. However, the interpreter supplied with
8 the standard Python distribution is fairly primitive (and IDLE isn't really
8 the standard Python distribution is fairly primitive (and IDLE isn't really
9 much better).
9 much better).
10
10
11 IPython tries to:
11 IPython tries to:
12
12
13 i - provide an efficient environment for interactive work in Python
13 i - provide an efficient environment for interactive work in Python
14 programming. It tries to address what we see as shortcomings of the standard
14 programming. It tries to address what we see as shortcomings of the standard
15 Python prompt, and adds many features to make interactive work much more
15 Python prompt, and adds many features to make interactive work much more
16 efficient.
16 efficient.
17
17
18 ii - offer a flexible framework so that it can be used as the base
18 ii - offer a flexible framework so that it can be used as the base
19 environment for other projects and problems where Python can be the
19 environment for other projects and problems where Python can be the
20 underlying language. Specifically scientific environments like Mathematica,
20 underlying language. Specifically scientific environments like Mathematica,
21 IDL and Mathcad inspired its design, but similar ideas can be useful in many
21 IDL and Mathcad inspired its design, but similar ideas can be useful in many
22 fields. Python is a fabulous language for implementing this kind of system
22 fields. Python is a fabulous language for implementing this kind of system
23 (due to its dynamic and introspective features), and with suitable libraries
23 (due to its dynamic and introspective features), and with suitable libraries
24 entire systems could be built leveraging Python's power.
24 entire systems could be built leveraging Python's power.
25
25
26 iii - serve as an embeddable, ready to go interpreter for your own programs.
26 iii - serve as an embeddable, ready to go interpreter for your own programs.
27
27
28 IPython requires Python 2.4 or newer.
28 IPython requires Python 2.4 or newer.
29 """
29 """
30
30
31 #*****************************************************************************
31 #*****************************************************************************
32 # Copyright (C) 2008-2009 The IPython Development Team
32 # Copyright (C) 2008-2009 The IPython Development Team
33 # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>
33 # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>
34 #
34 #
35 # Distributed under the terms of the BSD License. The full license is in
35 # Distributed under the terms of the BSD License. The full license is in
36 # the file COPYING, distributed as part of this software.
36 # the file COPYING, distributed as part of this software.
37 #*****************************************************************************
37 #*****************************************************************************
38
38
39 # Enforce proper version requirements
39 # Enforce proper version requirements
40 import sys
40 import sys
41
41
42 if sys.version[0:3] < '2.4':
42 if sys.version[0:3] < '2.4':
43 raise ImportError('Python Version 2.4 or above is required for IPython.')
43 raise ImportError('Python Version 2.4 or above is required for IPython.')
44
44
45 # Make it easy to import extensions - they are always directly on pythonpath.
45 # Make it easy to import extensions - they are always directly on pythonpath.
46 # Therefore, non-IPython modules can be added to Extensions directory
46 # Therefore, non-IPython modules can be added to Extensions directory
47 import os
47 import os
48 sys.path.append(os.path.dirname(__file__) + "/Extensions")
48 sys.path.append(os.path.dirname(__file__) + "/Extensions")
49
49
50 # Define what gets imported with a 'from IPython import *'
50 # Define what gets imported with a 'from IPython import *'
51 __all__ = ['ipapi','generics','ipstruct','Release','Shell']
51 __all__ = ['IPython.core.ipapi','utils.generics','utils.ipstruct','Release','Shell']
52
52
53 # Load __all__ in IPython namespace so that a simple 'import IPython' gives
53 # Load __all__ in IPython namespace so that a simple 'import IPython' gives
54 # access to them via IPython.<name>
54 # access to them via IPython.<name>
55 glob,loc = globals(),locals()
55 glob,loc = globals(),locals()
56 for name in __all__:
56 for name in __all__:
57 #print 'Importing: ',name # dbg
57 #print 'Importing: ',name # dbg
58 __import__(name,glob,loc,[])
58 __import__(name,glob,loc,[])
59
59
60 import Shell
60 import Shell
61
61
62 # Release data
62 # Release data
63 from IPython import Release # do it explicitly so pydoc can see it - pydoc bug
63 from IPython import Release # do it explicitly so pydoc can see it - pydoc bug
64 __author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \
64 __author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \
65 ( Release.authors['Fernando'] + Release.authors['Janko'] + \
65 ( Release.authors['Fernando'] + Release.authors['Janko'] + \
66 Release.authors['Nathan'] )
66 Release.authors['Nathan'] )
67 __license__ = Release.license
67 __license__ = Release.license
68 __version__ = Release.version
68 __version__ = Release.version
69 __revision__ = Release.revision
69 __revision__ = Release.revision
70
70
71 # Namespace cleanup
71 # Namespace cleanup
72 del name,glob,loc
72 del name,glob,loc
@@ -1,189 +1,189 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 The IPython Development Team
10 # Copyright (C) 2008 The IPython Development Team
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #-------------------------------------------------------------------------------
14 #-------------------------------------------------------------------------------
15
15
16 #-------------------------------------------------------------------------------
16 #-------------------------------------------------------------------------------
17 # Imports
17 # Imports
18 #-------------------------------------------------------------------------------
18 #-------------------------------------------------------------------------------
19
19
20 # Stdlib imports
20 # Stdlib imports
21 import os
21 import os
22 import sys
22 import sys
23
23
24 from glob import glob
24 from glob import glob
25
25
26 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
26 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
27 # update it when the contents of directories change.
27 # update it when the contents of directories change.
28 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
28 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
29
29
30 from distutils.core import setup
30 from distutils.core import setup
31
31
32 # Local imports
32 # Local imports
33 from IPython.genutils import target_update
33 from IPython.utils.genutils import target_update
34
34
35 from setupbase import (
35 from setupbase import (
36 setup_args,
36 setup_args,
37 find_packages,
37 find_packages,
38 find_package_data,
38 find_package_data,
39 find_scripts,
39 find_scripts,
40 find_data_files,
40 find_data_files,
41 check_for_dependencies
41 check_for_dependencies
42 )
42 )
43
43
44 isfile = os.path.isfile
44 isfile = os.path.isfile
45
45
46 #-------------------------------------------------------------------------------
46 #-------------------------------------------------------------------------------
47 # Handle OS specific things
47 # Handle OS specific things
48 #-------------------------------------------------------------------------------
48 #-------------------------------------------------------------------------------
49
49
50 if os.name == 'posix':
50 if os.name == 'posix':
51 os_name = 'posix'
51 os_name = 'posix'
52 elif os.name in ['nt','dos']:
52 elif os.name in ['nt','dos']:
53 os_name = 'windows'
53 os_name = 'windows'
54 else:
54 else:
55 print 'Unsupported operating system:',os.name
55 print 'Unsupported operating system:',os.name
56 sys.exit(1)
56 sys.exit(1)
57
57
58 # Under Windows, 'sdist' has not been supported. Now that the docs build with
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
59 # Sphinx it might work, but let's not turn it on until someone confirms that it
60 # actually works.
60 # actually works.
61 if os_name == 'windows' and 'sdist' in sys.argv:
61 if os_name == 'windows' and 'sdist' in sys.argv:
62 print 'The sdist command is not available under Windows. Exiting.'
62 print 'The sdist command is not available under Windows. Exiting.'
63 sys.exit(1)
63 sys.exit(1)
64
64
65 #-------------------------------------------------------------------------------
65 #-------------------------------------------------------------------------------
66 # Things related to the IPython documentation
66 # Things related to the IPython documentation
67 #-------------------------------------------------------------------------------
67 #-------------------------------------------------------------------------------
68
68
69 # update the manuals when building a source dist
69 # update the manuals when building a source dist
70 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
70 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
71 import textwrap
71 import textwrap
72
72
73 # List of things to be updated. Each entry is a triplet of args for
73 # List of things to be updated. Each entry is a triplet of args for
74 # target_update()
74 # target_update()
75 to_update = [
75 to_update = [
76 # FIXME - Disabled for now: we need to redo an automatic way
76 # FIXME - Disabled for now: we need to redo an automatic way
77 # of generating the magic info inside the rst.
77 # of generating the magic info inside the rst.
78 #('docs/magic.tex',
78 #('docs/magic.tex',
79 #['IPython/Magic.py'],
79 #['IPython/Magic.py'],
80 #"cd doc && ./update_magic.sh" ),
80 #"cd doc && ./update_magic.sh" ),
81
81
82 ('docs/man/ipython.1.gz',
82 ('docs/man/ipython.1.gz',
83 ['docs/man/ipython.1'],
83 ['docs/man/ipython.1'],
84 "cd docs/man && gzip -9c ipython.1 > ipython.1.gz"),
84 "cd docs/man && gzip -9c ipython.1 > ipython.1.gz"),
85
85
86 ('docs/man/pycolor.1.gz',
86 ('docs/man/pycolor.1.gz',
87 ['docs/man/pycolor.1'],
87 ['docs/man/pycolor.1'],
88 "cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz"),
88 "cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz"),
89 ]
89 ]
90
90
91 # Only build the docs if sphinx is present
91 # Only build the docs if sphinx is present
92 try:
92 try:
93 import sphinx
93 import sphinx
94 except ImportError:
94 except ImportError:
95 pass
95 pass
96 else:
96 else:
97 # The Makefile calls the do_sphinx scripts to build html and pdf, so
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
98 # just one target is enough to cover all manual generation
99
99
100 # First, compute all the dependencies that can force us to rebuild the
100 # First, compute all the dependencies that can force us to rebuild the
101 # docs. Start with the main release file that contains metadata
101 # docs. Start with the main release file that contains metadata
102 docdeps = ['IPython/Release.py']
102 docdeps = ['IPython/Release.py']
103 # Inculde all the reST sources
103 # Inculde all the reST sources
104 pjoin = os.path.join
104 pjoin = os.path.join
105 for dirpath,dirnames,filenames in os.walk('docs/source'):
105 for dirpath,dirnames,filenames in os.walk('docs/source'):
106 if dirpath in ['_static','_templates']:
106 if dirpath in ['_static','_templates']:
107 continue
107 continue
108 docdeps += [ pjoin(dirpath,f) for f in filenames
108 docdeps += [ pjoin(dirpath,f) for f in filenames
109 if f.endswith('.txt') ]
109 if f.endswith('.txt') ]
110 # and the examples
110 # and the examples
111 for dirpath,dirnames,filenames in os.walk('docs/example'):
111 for dirpath,dirnames,filenames in os.walk('docs/example'):
112 docdeps += [ pjoin(dirpath,f) for f in filenames
112 docdeps += [ pjoin(dirpath,f) for f in filenames
113 if not f.endswith('~') ]
113 if not f.endswith('~') ]
114 # then, make them all dependencies for the main PDF (the html will get
114 # then, make them all dependencies for the main PDF (the html will get
115 # auto-generated as well).
115 # auto-generated as well).
116 to_update.append(
116 to_update.append(
117 ('docs/dist/ipython.pdf',
117 ('docs/dist/ipython.pdf',
118 docdeps,
118 docdeps,
119 "cd docs && make dist")
119 "cd docs && make dist")
120 )
120 )
121
121
122 [ target_update(*t) for t in to_update ]
122 [ target_update(*t) for t in to_update ]
123
123
124
124
125 #---------------------------------------------------------------------------
125 #---------------------------------------------------------------------------
126 # Find all the packages, package data, scripts and data_files
126 # Find all the packages, package data, scripts and data_files
127 #---------------------------------------------------------------------------
127 #---------------------------------------------------------------------------
128
128
129 packages = find_packages()
129 packages = find_packages()
130 package_data = find_package_data()
130 package_data = find_package_data()
131 scripts = find_scripts()
131 scripts = find_scripts()
132 data_files = find_data_files()
132 data_files = find_data_files()
133
133
134 #---------------------------------------------------------------------------
134 #---------------------------------------------------------------------------
135 # Handle dependencies and setuptools specific things
135 # Handle dependencies and setuptools specific things
136 #---------------------------------------------------------------------------
136 #---------------------------------------------------------------------------
137
137
138 # This dict is used for passing extra arguments that are setuptools
138 # This dict is used for passing extra arguments that are setuptools
139 # specific to setup
139 # specific to setup
140 setuptools_extra_args = {}
140 setuptools_extra_args = {}
141
141
142 if 'setuptools' in sys.modules:
142 if 'setuptools' in sys.modules:
143 setuptools_extra_args['zip_safe'] = False
143 setuptools_extra_args['zip_safe'] = False
144 setuptools_extra_args['entry_points'] = {
144 setuptools_extra_args['entry_points'] = {
145 'console_scripts': [
145 'console_scripts': [
146 'ipython = IPython.ipapi:launch_new_instance',
146 'ipython = IPython.core.ipapi:launch_new_instance',
147 'pycolor = IPython.PyColorize:main',
147 'pycolor = IPython.PyColorize:main',
148 'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
148 'ipcontroller = IPython.kernel.scripts.ipcontroller:main',
149 'ipengine = IPython.kernel.scripts.ipengine:main',
149 'ipengine = IPython.kernel.scripts.ipengine:main',
150 'ipcluster = IPython.kernel.scripts.ipcluster:main',
150 'ipcluster = IPython.kernel.scripts.ipcluster:main',
151 'ipythonx = IPython.frontend.wx.ipythonx:main',
151 'ipythonx = IPython.frontend.wx.ipythonx:main',
152 'iptest = IPython.testing.iptest:main',
152 'iptest = IPython.testing.iptest:main',
153 ]
153 ]
154 }
154 }
155 setup_args['extras_require'] = dict(
155 setup_args['extras_require'] = dict(
156 kernel = [
156 kernel = [
157 'zope.interface>=3.4.1',
157 'zope.interface>=3.4.1',
158 'Twisted>=8.0.1',
158 'Twisted>=8.0.1',
159 'foolscap>=0.2.6'
159 'foolscap>=0.2.6'
160 ],
160 ],
161 doc='Sphinx>=0.3',
161 doc='Sphinx>=0.3',
162 test='nose>=0.10.1',
162 test='nose>=0.10.1',
163 security='pyOpenSSL>=0.6'
163 security='pyOpenSSL>=0.6'
164 )
164 )
165 # Allow setuptools to handle the scripts
165 # Allow setuptools to handle the scripts
166 scripts = []
166 scripts = []
167 else:
167 else:
168 # package_data of setuptools was introduced to distutils in 2.4
168 # package_data of setuptools was introduced to distutils in 2.4
169 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
169 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
170 if sys.version_info < (2,4):
170 if sys.version_info < (2,4):
171 data_files.append(('lib', 'IPython/UserConfig', cfgfiles))
171 data_files.append(('lib', 'IPython/UserConfig', cfgfiles))
172 # If we are running without setuptools, call this function which will
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
173 # check for dependencies an inform the user what is needed. This is
174 # just to make life easy for users.
174 # just to make life easy for users.
175 check_for_dependencies()
175 check_for_dependencies()
176
176
177
177
178 #---------------------------------------------------------------------------
178 #---------------------------------------------------------------------------
179 # Do the actual setup now
179 # Do the actual setup now
180 #---------------------------------------------------------------------------
180 #---------------------------------------------------------------------------
181
181
182 setup_args['packages'] = packages
182 setup_args['packages'] = packages
183 setup_args['package_data'] = package_data
183 setup_args['package_data'] = package_data
184 setup_args['scripts'] = scripts
184 setup_args['scripts'] = scripts
185 setup_args['data_files'] = data_files
185 setup_args['data_files'] = data_files
186 setup_args.update(setuptools_extra_args)
186 setup_args.update(setuptools_extra_args)
187
187
188 if __name__ == '__main__':
188 if __name__ == '__main__':
189 setup(**setup_args)
189 setup(**setup_args)
General Comments 0
You need to be logged in to leave comments. Login now