##// END OF EJS Templates
Updated setup.py and do_sphinx.py for new manual distribution
Ville M. Vainio -
Show More
@@ -1,64 +1,64 b''
1 import fileinput,os,sys
1 import fileinput,os,sys
2
2
3 def oscmd(c):
3 def oscmd(c):
4 os.system(c)
4 os.system(c)
5
5
6 # html manual.
6 # html manual.
7 oscmd('sphinx-build -d build/doctrees source build/html')
7 oscmd('sphinx-build -d build/doctrees source build/html')
8
8
9 if sys.platform != 'win32':
9 if sys.platform != 'win32':
10 # LaTeX format.
10 # LaTeX format.
11 oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
11 oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
12
12
13 # Produce pdf.
13 # Produce pdf.
14 os.chdir('build/latex')
14 os.chdir('build/latex')
15
15
16 # Change chapter style to section style: allows chapters to start on
16 # Change chapter style to section style: allows chapters to start on
17 # the current page. Works much better for the short chapters we have.
17 # the current page. Works much better for the short chapters we have.
18 # This must go in the class file rather than the preamble, so we modify
18 # This must go in the class file rather than the preamble, so we modify
19 # manual.cls at runtime.
19 # manual.cls at runtime.
20 chapter_cmds=r'''
20 chapter_cmds=r'''
21 % Local changes.
21 % Local changes.
22 \renewcommand\chapter{
22 \renewcommand\chapter{
23 \thispagestyle{plain}
23 \thispagestyle{plain}
24 \global\@topnum\z@
24 \global\@topnum\z@
25 \@afterindentfalse
25 \@afterindentfalse
26 \secdef\@chapter\@schapter
26 \secdef\@chapter\@schapter
27 }
27 }
28 \def\@makechapterhead#1{
28 \def\@makechapterhead#1{
29 \vspace*{10\p@}
29 \vspace*{10\p@}
30 {\raggedright \reset@font \Huge \bfseries \thechapter \quad #1}
30 {\raggedright \reset@font \Huge \bfseries \thechapter \quad #1}
31 \par\nobreak
31 \par\nobreak
32 \hrulefill
32 \hrulefill
33 \par\nobreak
33 \par\nobreak
34 \vspace*{10\p@}
34 \vspace*{10\p@}
35 }
35 }
36 \def\@makeschapterhead#1{
36 \def\@makeschapterhead#1{
37 \vspace*{10\p@}
37 \vspace*{10\p@}
38 {\raggedright \reset@font \Huge \bfseries #1}
38 {\raggedright \reset@font \Huge \bfseries #1}
39 \par\nobreak
39 \par\nobreak
40 \hrulefill
40 \hrulefill
41 \par\nobreak
41 \par\nobreak
42 \vspace*{10\p@}
42 \vspace*{10\p@}
43 }
43 }
44 '''
44 '''
45
45
46 unmodified=True
46 unmodified=True
47 for line in fileinput.FileInput('manual.cls',inplace=1):
47 for line in fileinput.FileInput('manual.cls',inplace=1):
48 if 'Support for module synopsis' in line and unmodified:
48 if 'Support for module synopsis' in line and unmodified:
49 line=chapter_cmds+line
49 line=chapter_cmds+line
50 elif 'makechapterhead' in line:
50 elif 'makechapterhead' in line:
51 # Already have altered manual.cls: don't need to again.
51 # Already have altered manual.cls: don't need to again.
52 unmodified=False
52 unmodified=False
53 print line,
53 print line,
54
54
55 # Copying the makefile produced by sphinx...
55 # Copying the makefile produced by sphinx...
56 oscmd('pdflatex ipython.tex')
56 oscmd('pdflatex ipython.tex')
57 oscmd('pdflatex ipython.tex')
57 oscmd('pdflatex ipython.tex')
58 oscmd('pdflatex ipython.tex')
58 oscmd('pdflatex ipython.tex')
59 oscmd('makeindex -s python.ist ipython.idx')
59 oscmd('makeindex -s python.ist ipython.idx')
60 oscmd('makeindex -s python.ist modipython.idx')
60 oscmd('makeindex -s python.ist modipython.idx')
61 oscmd('pdflatex ipython.tex')
61 oscmd('pdflatex ipython.tex')
62 oscmd('pdflatex ipython.tex')
62 oscmd('pdflatex ipython.tex')
63
63 oscmd('cp ipython.pdf ../html')
64 os.chdir('../..')
64 os.chdir('../..')
@@ -1,185 +1,171 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) 2001-2005 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
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 # Stdlib imports
16 # Stdlib imports
17 import os
17 import os
18 import sys
18 import sys
19
19
20 from glob import glob
20 from glob import glob
21 from setupext import install_data_ext
21 from setupext import install_data_ext
22
22
23 # A few handy globals
23 # A few handy globals
24 isfile = os.path.isfile
24 isfile = os.path.isfile
25 pjoin = os.path.join
25 pjoin = os.path.join
26
26
27 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
27 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
28 # update it when the contents of directories change.
28 # update it when the contents of directories change.
29 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
29 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
30
30
31 if os.name == 'posix':
31 if os.name == 'posix':
32 os_name = 'posix'
32 os_name = 'posix'
33 elif os.name in ['nt','dos']:
33 elif os.name in ['nt','dos']:
34 os_name = 'windows'
34 os_name = 'windows'
35 else:
35 else:
36 print 'Unsupported operating system:',os.name
36 print 'Unsupported operating system:',os.name
37 sys.exit(1)
37 sys.exit(1)
38
38
39 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
39 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
40 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
40 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
41 if os_name == 'windows' and 'sdist' in sys.argv:
41 if os_name == 'windows' and 'sdist' in sys.argv:
42 print 'The sdist command is not available under Windows. Exiting.'
42 print 'The sdist command is not available under Windows. Exiting.'
43 sys.exit(1)
43 sys.exit(1)
44
44
45 from distutils.core import setup
45 from distutils.core import setup
46
46
47 # update the manuals when building a source dist
47 # update the manuals when building a source dist
48 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
48 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
49 import textwrap
49 from IPython.genutils import target_update
50 from IPython.genutils import target_update
50 # list of things to be updated. Each entry is a triplet of args for
51 # list of things to be updated. Each entry is a triplet of args for
51 # target_update()
52 # target_update()
52 to_update = [('doc/magic.tex',
53
53 ['IPython/Magic.py'],
54 def oscmd(s):
54 "cd doc && ./update_magic.sh" ),
55 cwd = os.getcwd()
55
56 for l in textwrap.dedent(s).splitlines():
56 ('doc/manual.lyx',
57 print ">", l.strip()
57 ['IPython/Release.py','doc/manual_base.lyx'],
58 os.system(l.strip())
58 "cd doc && ./update_version.sh" ),
59
59
60 os.chdir(cwd)
60 ('doc/manual/manual.html',
61
61 ['doc/manual.lyx',
62 oscmd("""\
62 'doc/magic.tex',
63 cd doc
63 'doc/examples/example-gnuplot.py',
64 python do_sphinx.py""")
64 'doc/examples/example-embed.py',
65
65 'doc/examples/example-embed-short.py',
66 oscmd("cd doc && gzip -9c ipython.1 > ipython.1.gz")
66 'IPython/UserConfig/ipythonrc',
67 oscmd("cd doc && gzip -9c pycolor.1 > pycolor.1.gz")
67 ],
68 "cd doc && "
69 "lyxport -tt --leave --pdf "
70 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
71
72 ('doc/new_design.pdf',
73 ['doc/new_design.lyx'],
74 "cd doc && lyxport -tt --pdf new_design.lyx"),
75
76 ('doc/ipython.1.gz',
77 ['doc/ipython.1'],
78 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
79
80 ('doc/pycolor.1.gz',
81 ['doc/pycolor.1'],
82 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
83 ]
84 for target in to_update:
85 target_update(*target)
86
68
87 # Release.py contains version, authors, license, url, keywords, etc.
69 # Release.py contains version, authors, license, url, keywords, etc.
88 execfile(pjoin('IPython','Release.py'))
70 execfile(pjoin('IPython','Release.py'))
89
71
90 # A little utility we'll need below, since glob() does NOT allow you to do
72 # A little utility we'll need below, since glob() does NOT allow you to do
91 # exclusion on multiple endings!
73 # exclusion on multiple endings!
92 def file_doesnt_endwith(test,endings):
74 def file_doesnt_endwith(test,endings):
93 """Return true if test is a file and its name does NOT end with any
75 """Return true if test is a file and its name does NOT end with any
94 of the strings listed in endings."""
76 of the strings listed in endings."""
95 if not isfile(test):
77 if not isfile(test):
96 return False
78 return False
97 for e in endings:
79 for e in endings:
98 if test.endswith(e):
80 if test.endswith(e):
99 return False
81 return False
100 return True
82 return True
101
83
102 # I can't find how to make distutils create a nested dir. structure, so
84 # I can't find how to make distutils create a nested dir. structure, so
103 # in the meantime do it manually. Butt ugly.
85 # in the meantime do it manually. Butt ugly.
104 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
86 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
105 # information on how to do this more cleanly once python 2.4 can be assumed.
87 # information on how to do this more cleanly once python 2.4 can be assumed.
106 # Thanks to Noel for the tip.
88 # Thanks to Noel for the tip.
107 docdirbase = 'share/doc/ipython'
89 docdirbase = 'share/doc/ipython'
108 manpagebase = 'share/man/man1'
90 manpagebase = 'share/man/man1'
109
91
110 # We only need to exclude from this things NOT already excluded in the
92 # We only need to exclude from this things NOT already excluded in the
111 # MANIFEST.in file.
93 # MANIFEST.in file.
112 exclude = ('.sh','.1.gz')
94 exclude = ('.sh','.1.gz')
113 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
95 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
114
96
115 examfiles = filter(isfile, glob('doc/examples/*.py'))
97 examfiles = filter(isfile, glob('doc/examples/*.py'))
116 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
98 manfiles = filter(isfile, glob('doc/build/html/*'))
117 filter(isfile, glob('doc/manual/*.css')) + \
99 manstatic = filter(isfile, glob('doc/build/html/_static/*'))
118 filter(isfile, glob('doc/manual/*.png'))
100
101 # filter(isfile, glob('doc/manual/*.css')) + \
102 # filter(isfile, glob('doc/manual/*.png'))
103
119 manpages = filter(isfile, glob('doc/*.1.gz'))
104 manpages = filter(isfile, glob('doc/*.1.gz'))
120 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
105 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
121 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor',
106 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor',
122 'scripts/irunner'])
107 'scripts/irunner'])
123 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
108 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
124
109
125 # Script to be run by the windows binary installer after the default setup
110 # Script to be run by the windows binary installer after the default setup
126 # routine, to add shortcuts and similar windows-only things. Windows
111 # routine, to add shortcuts and similar windows-only things. Windows
127 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
112 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
128 # doesn't find them.
113 # doesn't find them.
129 if 'bdist_wininst' in sys.argv:
114 if 'bdist_wininst' in sys.argv:
130 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
115 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
131 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
116 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
132 sys.exit(1)
117 sys.exit(1)
133 scriptfiles.append('scripts/ipython_win_post_install.py')
118 scriptfiles.append('scripts/ipython_win_post_install.py')
134
119
135 datafiles = [('data', docdirbase, docfiles),
120 datafiles = [('data', docdirbase, docfiles),
136 ('data', pjoin(docdirbase, 'examples'),examfiles),
121 ('data', pjoin(docdirbase, 'examples'),examfiles),
137 ('data', pjoin(docdirbase, 'manual'),manfiles),
122 ('data', pjoin(docdirbase, 'manual'),manfiles),
123 ('data', pjoin(docdirbase, 'manual/_static'),manstatic),
138 ('data', manpagebase, manpages),
124 ('data', manpagebase, manpages),
139 ('data',pjoin(docdirbase, 'extensions'),igridhelpfiles),
125 ('data',pjoin(docdirbase, 'extensions'),igridhelpfiles),
140 ]
126 ]
141
127
142 if 'setuptools' in sys.modules:
128 if 'setuptools' in sys.modules:
143 # setuptools config for egg building
129 # setuptools config for egg building
144 egg_extra_kwds = {
130 egg_extra_kwds = {
145 'entry_points': {
131 'entry_points': {
146 'console_scripts': [
132 'console_scripts': [
147 'ipython = IPython.ipapi:launch_new_instance',
133 'ipython = IPython.ipapi:launch_new_instance',
148 'pycolor = IPython.PyColorize:main'
134 'pycolor = IPython.PyColorize:main'
149 ]}
135 ]}
150 }
136 }
151 scriptfiles = []
137 scriptfiles = []
152 # eggs will lack docs, eaxmples
138 # eggs will lack docs, eaxmples
153 datafiles = []
139 datafiles = []
154
140
155 #datafiles = [('lib', 'IPython/UserConfig', cfgfiles)]
141 #datafiles = [('lib', 'IPython/UserConfig', cfgfiles)]
156 else:
142 else:
157 egg_extra_kwds = {}
143 egg_extra_kwds = {}
158 # package_data of setuptools was introduced to distutils in 2.4
144 # package_data of setuptools was introduced to distutils in 2.4
159 if sys.version_info < (2,4):
145 if sys.version_info < (2,4):
160 datafiles.append(('lib', 'IPython/UserConfig', cfgfiles))
146 datafiles.append(('lib', 'IPython/UserConfig', cfgfiles))
161
147
162
148
163
149
164
150
165 # Call the setup() routine which does most of the work
151 # Call the setup() routine which does most of the work
166 setup(name = name,
152 setup(name = name,
167 version = version,
153 version = version,
168 description = description,
154 description = description,
169 long_description = long_description,
155 long_description = long_description,
170 author = authors['Fernando'][0],
156 author = authors['Fernando'][0],
171 author_email = authors['Fernando'][1],
157 author_email = authors['Fernando'][1],
172 url = url,
158 url = url,
173 download_url = download_url,
159 download_url = download_url,
174 license = license,
160 license = license,
175 platforms = platforms,
161 platforms = platforms,
176 keywords = keywords,
162 keywords = keywords,
177 packages = ['IPython', 'IPython.Extensions', 'IPython.external', 'IPython.gui', 'IPython.gui.wx', 'IPython.UserConfig'],
163 packages = ['IPython', 'IPython.Extensions', 'IPython.external', 'IPython.gui', 'IPython.gui.wx', 'IPython.UserConfig'],
178 scripts = scriptfiles,
164 scripts = scriptfiles,
179 package_data = {'IPython.UserConfig' : ['*'] },
165 package_data = {'IPython.UserConfig' : ['*'] },
180
166
181 cmdclass = {'install_data': install_data_ext},
167 cmdclass = {'install_data': install_data_ext},
182 data_files = datafiles,
168 data_files = datafiles,
183 # extra params needed for eggs
169 # extra params needed for eggs
184 **egg_extra_kwds
170 **egg_extra_kwds
185 )
171 )
General Comments 0
You need to be logged in to leave comments. Login now