annotate Mac/Tools/Doc/setup.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 01a7e66525c2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 # Build and install an Apple Help Viewer compatible version of the Python
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2 # documentation into the framework.
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 # Code by Bill Fancher, with some modifications by Jack Jansen.
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 #
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 # You must run this as a two-step process
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 # 1. python setupDocs.py build
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 # 2. Wait for Apple Help Indexing Tool to finish
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 # 3. python setupDocs.py install
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9 #
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 # To do:
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 # - test whether the docs are available locally before downloading
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12 # - fix buildDocsFromSource
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13 # - Get documentation version from sys.version, fallback to 2.2.1
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 # - See if we can somehow detect that Apple Help Indexing Tool is finished
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 # - data_files to setup() doesn't seem the right way to pass the arguments
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 #
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 import sys, os, re
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 from distutils.cmd import Command
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19 from distutils.command.build import build
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 from distutils.core import setup
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21 from distutils.file_util import copy_file
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 from distutils.dir_util import copy_tree
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 from distutils.log import log
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24 from distutils.spawn import spawn
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 from distutils import sysconfig, dep_util
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 from distutils.util import change_root
29280
8f2c5cf61763 Alternate fix for #728744: use OSA and Apple Help Indexing Tool's idleStatus
Jack Jansen <jack.jansen@cwi.nl>
parents: 28307
diff changeset
27 import HelpIndexingTool
8f2c5cf61763 Alternate fix for #728744: use OSA and Apple Help Indexing Tool's idleStatus
Jack Jansen <jack.jansen@cwi.nl>
parents: 28307
diff changeset
28 import Carbon.File
8f2c5cf61763 Alternate fix for #728744: use OSA and Apple Help Indexing Tool's idleStatus
Jack Jansen <jack.jansen@cwi.nl>
parents: 28307
diff changeset
29 import time
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
31 MAJOR_VERSION='2.4'
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
32 MINOR_VERSION='2.4.1'
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
33 DESTDIR='/Applications/MacPython-%s/PythonIDE.app/Contents/Resources/English.lproj/PythonDocumentation' % MAJOR_VERSION
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
34
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
35 class DocBuild(build):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
36 def initialize_options(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
37 build.initialize_options(self)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
38 self.build_html = None
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
39 self.build_dest = None
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
40 self.download = 1
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
41 self.doc_version = MINOR_VERSION # Only needed if download is true
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
42
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
43 def finalize_options(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
44 build.finalize_options(self)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
45 if self.build_html is None:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
46 self.build_html = os.path.join(self.build_base, 'html')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
47 if self.build_dest is None:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
48 self.build_dest = os.path.join(self.build_base, 'PythonDocumentation')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
49
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
50 def spawn(self, *args):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
51 spawn(args, 1, self.verbose, self.dry_run)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
52
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
53 def downloadDocs(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
54 workdir = os.getcwd()
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
55 # XXX Note: the next strings may change from version to version
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
56 url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tar.bz2' % \
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
57 (self.doc_version,self.doc_version)
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
58 tarfile = 'html-%s.tar.bz2' % self.doc_version
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
59 dirname = 'Python-Docs-%s' % self.doc_version
34920
67a89b43dcc7 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 34914
diff changeset
60
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
61 if os.path.exists(self.build_html):
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
62 raise RuntimeError, '%s: already exists, please remove and try again' % self.build_html
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
63 os.chdir(self.build_base)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
64 self.spawn('curl','-O', url)
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
65 self.spawn('tar', '-xjf', tarfile)
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
66 os.rename(dirname, 'html')
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
67 os.chdir(workdir)
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
68 ## print "** Please unpack %s" % os.path.join(self.build_base, tarfile)
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
69 ## print "** Unpack the files into %s" % self.build_html
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
70 ## raise RuntimeError, "You need to unpack the docs manually"
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
71
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
72 def buildDocsFromSource(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
73 srcdir = '../../..'
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
74 docdir = os.path.join(srcdir, 'Doc')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
75 htmldir = os.path.join(docdir, 'html')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
76 spawn(('make','--directory', docdir, 'html'), 1, self.verbose, self.dry_run)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
77 self.mkpath(self.build_html)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
78 copy_tree(htmldir, self.build_html)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
79
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
80 def ensureHtml(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
81 if not os.path.exists(self.build_html):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
82 if self.download:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
83 self.downloadDocs()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
84 else:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
85 self.buildDocsFromSource()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
86
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
87 def hackIndex(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
88 ind_html = 'index.html'
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
89 #print 'self.build_dest =', self.build_dest
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
90 hackedIndex = file(os.path.join(self.build_dest, ind_html),'w')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
91 origIndex = file(os.path.join(self.build_html,ind_html))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
92 r = re.compile('<style type="text/css">.*</style>', re.DOTALL)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
93 hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Documentation">',origIndex.read()))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
94
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
95 def hackFile(self,d,f):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
96 origPath = os.path.join(d,f)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
97 assert(origPath[:len(self.build_html)] == self.build_html)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
98 outPath = os.path.join(self.build_dest, d[len(self.build_html)+1:], f)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
99 (name, ext) = os.path.splitext(f)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
100 if os.path.isdir(origPath):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
101 self.mkpath(outPath)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
102 elif ext == '.html':
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
103 if self.verbose: print 'hacking %s to %s' % (origPath,outPath)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
104 hackedFile = file(outPath, 'w')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
105 origFile = file(origPath,'r')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
106 hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read()))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
107 else:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
108 copy_file(origPath, outPath)
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
109
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
110 def hackHtml(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
111 self.r = re.compile('<dl><dd>')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
112 os.path.walk(self.build_html, self.visit, None)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
113
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
114 def visit(self, dummy, dirname, filenames):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
115 for f in filenames:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
116 self.hackFile(dirname, f)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
117
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
118 def makeHelpIndex(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
119 app = '/Developer/Applications/Apple Help Indexing Tool.app'
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
120 self.spawn('open', '-a', app , self.build_dest)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
121 print "Please wait until Apple Help Indexing Tool finishes before installing"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
122
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
123 def makeHelpIndex(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
124 app = HelpIndexingTool.HelpIndexingTool(start=1)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
125 app.open(Carbon.File.FSSpec(self.build_dest))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
126 sys.stderr.write("Waiting for Help Indexing Tool to start...")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
127 while 1:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
128 # This is bad design in the suite generation code!
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
129 idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus())
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
130 time.sleep(10)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
131 if not idle: break
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
132 sys.stderr.write(".")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
133 sys.stderr.write("\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
134 sys.stderr.write("Waiting for Help Indexing Tool to finish...")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
135 while 1:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
136 # This is bad design in the suite generation code!
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
137 idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus())
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
138 time.sleep(10)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
139 if idle: break
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
140 sys.stderr.write(".")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
141 sys.stderr.write("\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
142
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
143
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
144 def run(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
145 self.ensure_finalized()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
146 self.mkpath(self.build_base)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
147 self.ensureHtml()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
148 if not os.path.isdir(self.build_html):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
149 raise RuntimeError, \
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
150 "Can't find source folder for documentation."
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
151 self.mkpath(self.build_dest)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
152 if dep_util.newer(os.path.join(self.build_html,'index.html'), os.path.join(self.build_dest,'index.html')):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
153 self.mkpath(self.build_dest)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
154 self.hackHtml()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
155 self.hackIndex()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
156 self.makeHelpIndex()
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
157
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
158 class AHVDocInstall(Command):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
159 description = "install Apple Help Viewer html files"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
160 user_options = [('install-doc=', 'd',
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
161 'directory to install HTML tree'),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
162 ('root=', None,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
163 "install everything relative to this alternate root directory"),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
164 ]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
165
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
166 def initialize_options(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
167 self.build_dest = None
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
168 self.install_doc = None
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
169 self.prefix = None
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
170 self.root = None
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
171
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
172 def finalize_options(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
173 self.set_undefined_options('install',
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
174 ('prefix', 'prefix'),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
175 ('root', 'root'))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
176 # import pdb ; pdb.set_trace()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
177 build_cmd = self.get_finalized_command('build')
46197
01a7e66525c2 #2503 make singletons compared with "is" not == or !=
Benjamin Peterson <benjamin@python.org>
parents: 38643
diff changeset
178 if self.build_dest is None:
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
179 build_cmd = self.get_finalized_command('build')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
180 self.build_dest = build_cmd.build_dest
46197
01a7e66525c2 #2503 make singletons compared with "is" not == or !=
Benjamin Peterson <benjamin@python.org>
parents: 38643
diff changeset
181 if self.install_doc is None:
34914
c4ea17cf5211 Backport:
Jack Jansen <jack.jansen@cwi.nl>
parents: 32736
diff changeset
182 self.install_doc = os.path.join(self.prefix, DESTDIR)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
183 print 'INSTALL', self.build_dest, '->', self.install_doc
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
184
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
185 def run(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
186 self.finalize_options()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
187 self.ensure_finalized()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
188 print "Running Installer"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
189 instloc = self.install_doc
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
190 if self.root:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
191 instloc = change_root(self.root, instloc)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
192 self.mkpath(instloc)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
193 copy_tree(self.build_dest, instloc)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
194 print "Installation complete"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
195
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
196 def mungeVersion(infile, outfile):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
197 i = file(infile,'r')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
198 o = file(outfile,'w')
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
199 o.write(re.sub('\$\(VERSION\)',sysconfig.get_config_var('VERSION'),i.read()))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
200 i.close()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
201 o.close()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
202
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
203 def main():
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
204 # turn off warnings when deprecated modules are imported
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
205 ## import warnings
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
206 ## warnings.filterwarnings("ignore",category=DeprecationWarning)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
207 setup(name = 'Documentation',
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
208 version = '%d.%d' % sys.version_info[:2],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
209 cmdclass = {'install_data':AHVDocInstall, 'build':DocBuild},
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
210 data_files = ['dummy'],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
211 )
27900
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
212
197d64dc04dc Moved setupDocs.py to Doc/setup.py and did some cleanup. It now at least
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
213 if __name__ == '__main__':
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 29644
diff changeset
214 main()