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