2828import Carbon .File
2929import time
3030
31+ MAJOR_VERSION = '2.4'
32+ MINOR_VERSION = '2.4.1'
33+ DESTDIR = '/Applications/MacPython-%s/PythonIDE.app/Contents/Resources/English.lproj/PythonDocumentation' % MAJOR_VERSION
34+
3135class DocBuild (build ):
3236 def initialize_options (self ):
3337 build .initialize_options (self )
3438 self .build_html = None
3539 self .build_dest = None
36- self .download = 0
37- self .doc_version = '2.3b1' # Only needed if download is true
40+ self .download = 1
41+ self .doc_version = MINOR_VERSION # Only needed if download is true
3842
3943 def finalize_options (self ):
4044 build .finalize_options (self )
@@ -48,20 +52,22 @@ def spawn(self, *args):
4852
4953 def downloadDocs (self ):
5054 workdir = os .getcwd ()
51- url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % \
55+ # XXX Note: the next strings may change from version to version
56+ url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tar.bz2' % \
5257 (self .doc_version ,self .doc_version )
58+ tarfile = 'html-%s.tar.bz2' % self .doc_version
59+ dirname = 'Python-Docs-%s' % self .doc_version
60+
61+ if os .path .exists (self .build_html ):
62+ raise RuntimeError , '%s: already exists, please remove and try again' % self .build_html
5363 os .chdir (self .build_base )
5464 self .spawn ('curl' ,'-O' , url )
65+ self .spawn ('tar' , '-xjf' , tarfile )
66+ os .rename (dirname , 'html' )
5567 os .chdir (workdir )
56- tarfile = 'html-%s.tgz' % self .doc_version
57- ## This no longer works due to name changes
58- ## self.mkpath(self.build_html)
59- ## os.chdir(self.build_html)
60- ## self.spawn('tar', '-xzf', '../' + tarfile)
61- ## os.chdir(workdir)
62- print "** Please unpack %s" % os .path .join (self .build_base , tarfile )
63- print "** Unpack the files into %s" % self .build_html
64- raise RuntimeError , "You need to unpack the docs manually"
68+ ## print "** Please unpack %s" % os.path.join(self.build_base, tarfile)
69+ ## print "** Unpack the files into %s" % self.build_html
70+ ## raise RuntimeError, "You need to unpack the docs manually"
6571
6672 def buildDocsFromSource (self ):
6773 srcdir = '../../..'
@@ -173,7 +179,7 @@ def finalize_options(self):
173179 build_cmd = self .get_finalized_command ('build' )
174180 self .build_dest = build_cmd .build_dest
175181 if self .install_doc == None :
176- self .install_doc = os .path .join (self .prefix , 'Resources/Python.app/Contents/Resources/English.lproj/PythonDocumentation' )
182+ self .install_doc = os .path .join (self .prefix , DESTDIR )
177183 print 'INSTALL' , self .build_dest , '->' , self .install_doc
178184
179185 def run (self ):
0 commit comments