diff options
Diffstat (limited to 'Mac/OSX')
-rw-r--r-- | Mac/OSX/Doc/HelpIndexingTool/Standard_Suite.py | 6 | ||||
-rw-r--r-- | Mac/OSX/Doc/HelpIndexingTool/__init__.py | 1 | ||||
-rw-r--r-- | Mac/OSX/Doc/setup.py | 340 | ||||
-rw-r--r-- | Mac/OSX/Extras.install.py | 78 | ||||
-rw-r--r-- | Mac/OSX/fixversions.py | 101 |
5 files changed, 262 insertions, 264 deletions
diff --git a/Mac/OSX/Doc/HelpIndexingTool/Standard_Suite.py b/Mac/OSX/Doc/HelpIndexingTool/Standard_Suite.py index e986d75..4f6604c 100644 --- a/Mac/OSX/Doc/HelpIndexingTool/Standard_Suite.py +++ b/Mac/OSX/Doc/HelpIndexingTool/Standard_Suite.py @@ -304,9 +304,9 @@ document._privpropdict = { document._privelemdict = { } _Enum_savo = { - 'yes' : 'yes ', # Save objects now - 'no' : 'no ', # Do not save objects - 'ask' : 'ask ', # Ask the user whether to save + 'yes' : 'yes ', # Save objects now + 'no' : 'no ', # Do not save objects + 'ask' : 'ask ', # Ask the user whether to save } diff --git a/Mac/OSX/Doc/HelpIndexingTool/__init__.py b/Mac/OSX/Doc/HelpIndexingTool/__init__.py index 2745086..5359df5 100644 --- a/Mac/OSX/Doc/HelpIndexingTool/__init__.py +++ b/Mac/OSX/Doc/HelpIndexingTool/__init__.py @@ -76,4 +76,3 @@ class HelpIndexingTool(Standard_Suite_Events, _signature = 'hiti' _moduleName = 'HelpIndexingTool' - diff --git a/Mac/OSX/Doc/setup.py b/Mac/OSX/Doc/setup.py index 58d8df6..ae86b80 100644 --- a/Mac/OSX/Doc/setup.py +++ b/Mac/OSX/Doc/setup.py @@ -29,180 +29,180 @@ import Carbon.File import time class DocBuild(build): - def initialize_options(self): - build.initialize_options(self) - self.build_html = None - self.build_dest = None - self.download = 0 - self.doc_version = '2.3b1' # Only needed if download is true - - def finalize_options(self): - build.finalize_options(self) - if self.build_html is None: - self.build_html = os.path.join(self.build_base, 'html') - if self.build_dest is None: - self.build_dest = os.path.join(self.build_base, 'PythonDocumentation') - - def spawn(self, *args): - spawn(args, 1, self.verbose, self.dry_run) - - def downloadDocs(self): - workdir = os.getcwd() - url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % \ - (self.doc_version,self.doc_version) - os.chdir(self.build_base) - self.spawn('curl','-O', url) - os.chdir(workdir) - tarfile = 'html-%s.tgz' % self.doc_version + def initialize_options(self): + build.initialize_options(self) + self.build_html = None + self.build_dest = None + self.download = 0 + self.doc_version = '2.3b1' # Only needed if download is true + + def finalize_options(self): + build.finalize_options(self) + if self.build_html is None: + self.build_html = os.path.join(self.build_base, 'html') + if self.build_dest is None: + self.build_dest = os.path.join(self.build_base, 'PythonDocumentation') + + def spawn(self, *args): + spawn(args, 1, self.verbose, self.dry_run) + + def downloadDocs(self): + workdir = os.getcwd() + url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % \ + (self.doc_version,self.doc_version) + os.chdir(self.build_base) + self.spawn('curl','-O', url) + os.chdir(workdir) + tarfile = 'html-%s.tgz' % self.doc_version ## This no longer works due to name changes -## self.mkpath(self.build_html) -## os.chdir(self.build_html) -## self.spawn('tar', '-xzf', '../' + tarfile) -## os.chdir(workdir) - print "** Please unpack %s" % os.path.join(self.build_base, tarfile) - print "** Unpack the files into %s" % self.build_html - raise RuntimeError, "You need to unpack the docs manually" - - def buildDocsFromSource(self): - srcdir = '../../..' - docdir = os.path.join(srcdir, 'Doc') - htmldir = os.path.join(docdir, 'html') - spawn(('make','--directory', docdir, 'html'), 1, self.verbose, self.dry_run) - self.mkpath(self.build_html) - copy_tree(htmldir, self.build_html) - - def ensureHtml(self): - if not os.path.exists(self.build_html): - if self.download: - self.downloadDocs() - else: - self.buildDocsFromSource() - - def hackIndex(self): - ind_html = 'index.html' - #print 'self.build_dest =', self.build_dest - hackedIndex = file(os.path.join(self.build_dest, ind_html),'w') - origIndex = file(os.path.join(self.build_html,ind_html)) - r = re.compile('<style type="text/css">.*</style>', re.DOTALL) - hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Documentation">',origIndex.read())) - - def hackFile(self,d,f): - origPath = os.path.join(d,f) - assert(origPath[:len(self.build_html)] == self.build_html) - outPath = os.path.join(self.build_dest, d[len(self.build_html)+1:], f) - (name, ext) = os.path.splitext(f) - if os.path.isdir(origPath): - self.mkpath(outPath) - elif ext == '.html': - if self.verbose: print 'hacking %s to %s' % (origPath,outPath) - hackedFile = file(outPath, 'w') - origFile = file(origPath,'r') - hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read())) - else: - copy_file(origPath, outPath) - - def hackHtml(self): - self.r = re.compile('<dl><dd>') - os.path.walk(self.build_html, self.visit, None) - - def visit(self, dummy, dirname, filenames): - for f in filenames: - self.hackFile(dirname, f) - - def makeHelpIndex(self): - app = '/Developer/Applications/Apple Help Indexing Tool.app' - self.spawn('open', '-a', app , self.build_dest) - print "Please wait until Apple Help Indexing Tool finishes before installing" - - def makeHelpIndex(self): - app = HelpIndexingTool.HelpIndexingTool(start=1) - app.open(Carbon.File.FSSpec(self.build_dest)) - sys.stderr.write("Waiting for Help Indexing Tool to start...") - while 1: - # This is bad design in the suite generation code! - idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus()) - time.sleep(10) - if not idle: break - sys.stderr.write(".") - sys.stderr.write("\n") - sys.stderr.write("Waiting for Help Indexing Tool to finish...") - while 1: - # This is bad design in the suite generation code! - idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus()) - time.sleep(10) - if idle: break - sys.stderr.write(".") - sys.stderr.write("\n") - - - def run(self): - self.ensure_finalized() - self.mkpath(self.build_base) - self.ensureHtml() - if not os.path.isdir(self.build_html): - raise RuntimeError, \ - "Can't find source folder for documentation." - self.mkpath(self.build_dest) - if dep_util.newer(os.path.join(self.build_html,'index.html'), os.path.join(self.build_dest,'index.html')): - self.mkpath(self.build_dest) - self.hackHtml() - self.hackIndex() - self.makeHelpIndex() +## self.mkpath(self.build_html) +## os.chdir(self.build_html) +## self.spawn('tar', '-xzf', '../' + tarfile) +## os.chdir(workdir) + print "** Please unpack %s" % os.path.join(self.build_base, tarfile) + print "** Unpack the files into %s" % self.build_html + raise RuntimeError, "You need to unpack the docs manually" + + def buildDocsFromSource(self): + srcdir = '../../..' + docdir = os.path.join(srcdir, 'Doc') + htmldir = os.path.join(docdir, 'html') + spawn(('make','--directory', docdir, 'html'), 1, self.verbose, self.dry_run) + self.mkpath(self.build_html) + copy_tree(htmldir, self.build_html) + + def ensureHtml(self): + if not os.path.exists(self.build_html): + if self.download: + self.downloadDocs() + else: + self.buildDocsFromSource() + + def hackIndex(self): + ind_html = 'index.html' + #print 'self.build_dest =', self.build_dest + hackedIndex = file(os.path.join(self.build_dest, ind_html),'w') + origIndex = file(os.path.join(self.build_html,ind_html)) + r = re.compile('<style type="text/css">.*</style>', re.DOTALL) + hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Documentation">',origIndex.read())) + + def hackFile(self,d,f): + origPath = os.path.join(d,f) + assert(origPath[:len(self.build_html)] == self.build_html) + outPath = os.path.join(self.build_dest, d[len(self.build_html)+1:], f) + (name, ext) = os.path.splitext(f) + if os.path.isdir(origPath): + self.mkpath(outPath) + elif ext == '.html': + if self.verbose: print 'hacking %s to %s' % (origPath,outPath) + hackedFile = file(outPath, 'w') + origFile = file(origPath,'r') + hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read())) + else: + copy_file(origPath, outPath) + + def hackHtml(self): + self.r = re.compile('<dl><dd>') + os.path.walk(self.build_html, self.visit, None) + + def visit(self, dummy, dirname, filenames): + for f in filenames: + self.hackFile(dirname, f) + + def makeHelpIndex(self): + app = '/Developer/Applications/Apple Help Indexing Tool.app' + self.spawn('open', '-a', app , self.build_dest) + print "Please wait until Apple Help Indexing Tool finishes before installing" + + def makeHelpIndex(self): + app = HelpIndexingTool.HelpIndexingTool(start=1) + app.open(Carbon.File.FSSpec(self.build_dest)) + sys.stderr.write("Waiting for Help Indexing Tool to start...") + while 1: + # This is bad design in the suite generation code! + idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus()) + time.sleep(10) + if not idle: break + sys.stderr.write(".") + sys.stderr.write("\n") + sys.stderr.write("Waiting for Help Indexing Tool to finish...") + while 1: + # This is bad design in the suite generation code! + idle = app._get(HelpIndexingTool.Help_Indexing_Tool_Suite._Prop_idleStatus()) + time.sleep(10) + if idle: break + sys.stderr.write(".") + sys.stderr.write("\n") + + + def run(self): + self.ensure_finalized() + self.mkpath(self.build_base) + self.ensureHtml() + if not os.path.isdir(self.build_html): + raise RuntimeError, \ + "Can't find source folder for documentation." + self.mkpath(self.build_dest) + if dep_util.newer(os.path.join(self.build_html,'index.html'), os.path.join(self.build_dest,'index.html')): + self.mkpath(self.build_dest) + self.hackHtml() + self.hackIndex() + self.makeHelpIndex() class AHVDocInstall(Command): - description = "install Apple Help Viewer html files" - user_options = [('install-doc=', 'd', - 'directory to install HTML tree'), - ('root=', None, - "install everything relative to this alternate root directory"), - ] - - def initialize_options(self): - self.build_dest = None - self.install_doc = None - self.prefix = None - self.root = None - - def finalize_options(self): - self.set_undefined_options('install', - ('prefix', 'prefix'), - ('root', 'root')) -# import pdb ; pdb.set_trace() - build_cmd = self.get_finalized_command('build') - if self.build_dest == None: - build_cmd = self.get_finalized_command('build') - self.build_dest = build_cmd.build_dest - if self.install_doc == None: - self.install_doc = os.path.join(self.prefix, 'Resources/Python.app/Contents/Resources/English.lproj/PythonDocumentation') - print 'INSTALL', self.build_dest, '->', self.install_doc - - def run(self): - self.finalize_options() - self.ensure_finalized() - print "Running Installer" - instloc = self.install_doc - if self.root: - instloc = change_root(self.root, instloc) - self.mkpath(instloc) - copy_tree(self.build_dest, instloc) - print "Installation complete" - + description = "install Apple Help Viewer html files" + user_options = [('install-doc=', 'd', + 'directory to install HTML tree'), + ('root=', None, + "install everything relative to this alternate root directory"), + ] + + def initialize_options(self): + self.build_dest = None + self.install_doc = None + self.prefix = None + self.root = None + + def finalize_options(self): + self.set_undefined_options('install', + ('prefix', 'prefix'), + ('root', 'root')) +# import pdb ; pdb.set_trace() + build_cmd = self.get_finalized_command('build') + if self.build_dest == None: + build_cmd = self.get_finalized_command('build') + self.build_dest = build_cmd.build_dest + if self.install_doc == None: + self.install_doc = os.path.join(self.prefix, 'Resources/Python.app/Contents/Resources/English.lproj/PythonDocumentation') + print 'INSTALL', self.build_dest, '->', self.install_doc + + def run(self): + self.finalize_options() + self.ensure_finalized() + print "Running Installer" + instloc = self.install_doc + if self.root: + instloc = change_root(self.root, instloc) + self.mkpath(instloc) + copy_tree(self.build_dest, instloc) + print "Installation complete" + def mungeVersion(infile, outfile): - i = file(infile,'r') - o = file(outfile,'w') - o.write(re.sub('\$\(VERSION\)',sysconfig.get_config_var('VERSION'),i.read())) - i.close() - o.close() - + i = file(infile,'r') + o = file(outfile,'w') + o.write(re.sub('\$\(VERSION\)',sysconfig.get_config_var('VERSION'),i.read())) + i.close() + o.close() + def main(): - # turn off warnings when deprecated modules are imported -## import warnings -## warnings.filterwarnings("ignore",category=DeprecationWarning) - setup(name = 'Documentation', - version = '%d.%d' % sys.version_info[:2], - cmdclass = {'install_data':AHVDocInstall, 'build':DocBuild}, - data_files = ['dummy'], - ) + # turn off warnings when deprecated modules are imported +## import warnings +## warnings.filterwarnings("ignore",category=DeprecationWarning) + setup(name = 'Documentation', + version = '%d.%d' % sys.version_info[:2], + cmdclass = {'install_data':AHVDocInstall, 'build':DocBuild}, + data_files = ['dummy'], + ) if __name__ == '__main__': - main() + main() diff --git a/Mac/OSX/Extras.install.py b/Mac/OSX/Extras.install.py index 1939904..2521f06 100644 --- a/Mac/OSX/Extras.install.py +++ b/Mac/OSX/Extras.install.py @@ -9,45 +9,45 @@ verbose = 1 debug = 0 def isclean(name): - if name == 'CVS': return 0 - if name == '.cvsignore': return 0 - if name == '.DS_store': return 0 - if name.endswith('~'): return 0 - if name.endswith('.BAK'): return 0 - if name.endswith('.pyc'): return 0 - if name.endswith('.pyo'): return 0 - if name.endswith('.orig'): return 0 - return 1 - + if name == 'CVS': return 0 + if name == '.cvsignore': return 0 + if name == '.DS_store': return 0 + if name.endswith('~'): return 0 + if name.endswith('.BAK'): return 0 + if name.endswith('.pyc'): return 0 + if name.endswith('.pyo'): return 0 + if name.endswith('.orig'): return 0 + return 1 + def copycleandir(src, dst): - for cursrc, dirs, files in os.walk(src): - assert cursrc.startswith(src) - curdst = dst + cursrc[len(src):] - if verbose: - print "mkdir", curdst - if not debug: - if not os.path.exists(curdst): - os.makedirs(curdst) - for fn in files: - if isclean(fn): - if verbose: - print "copy", os.path.join(cursrc, fn), os.path.join(curdst, fn) - if not debug: - shutil.copy2(os.path.join(cursrc, fn), os.path.join(curdst, fn)) - else: - if verbose: - print "skipfile", os.path.join(cursrc, fn) - for i in range(len(dirs)-1, -1, -1): - if not isclean(dirs[i]): - if verbose: - print "skipdir", os.path.join(cursrc, dirs[i]) - del dirs[i] - + for cursrc, dirs, files in os.walk(src): + assert cursrc.startswith(src) + curdst = dst + cursrc[len(src):] + if verbose: + print "mkdir", curdst + if not debug: + if not os.path.exists(curdst): + os.makedirs(curdst) + for fn in files: + if isclean(fn): + if verbose: + print "copy", os.path.join(cursrc, fn), os.path.join(curdst, fn) + if not debug: + shutil.copy2(os.path.join(cursrc, fn), os.path.join(curdst, fn)) + else: + if verbose: + print "skipfile", os.path.join(cursrc, fn) + for i in range(len(dirs)-1, -1, -1): + if not isclean(dirs[i]): + if verbose: + print "skipdir", os.path.join(cursrc, dirs[i]) + del dirs[i] + def main(): - if len(sys.argv) != 3: - sys.stderr.write("Usage: %s srcdir dstdir\n" % sys.argv[0]) - sys.exit(1) - copycleandir(sys.argv[1], sys.argv[2]) - + if len(sys.argv) != 3: + sys.stderr.write("Usage: %s srcdir dstdir\n" % sys.argv[0]) + sys.exit(1) + copycleandir(sys.argv[1], sys.argv[2]) + if __name__ == '__main__': - main()
\ No newline at end of file + main() diff --git a/Mac/OSX/fixversions.py b/Mac/OSX/fixversions.py index e782e8c..0277c79 100644 --- a/Mac/OSX/fixversions.py +++ b/Mac/OSX/fixversions.py @@ -8,63 +8,62 @@ import plistlib SHORTVERSION = "%d.%d" % (sys.version_info[0], sys.version_info[1]) if sys.version_info[2]: - SHORTVERSION = SHORTVERSION + ".%d" % sys.version_info[2] + SHORTVERSION = SHORTVERSION + ".%d" % sys.version_info[2] if sys.version_info[3] != 'final': - SHORTVERSION = SHORTVERSION + "%s%d" % (sys.version_info[3], sys.version_info[4]) + SHORTVERSION = SHORTVERSION + "%s%d" % (sys.version_info[3], sys.version_info[4]) COPYRIGHT = "(c) %d Python Software Foundation." % time.gmtime()[0] LONGVERSION = SHORTVERSION + ", " + COPYRIGHT def fix(file): - plist = plistlib.Plist.fromFile(file) - changed = False - if plist.has_key("CFBundleGetInfoString") and \ - plist["CFBundleGetInfoString"] != LONGVERSION: - plist["CFBundleGetInfoString"] = LONGVERSION - changed = True - if plist.has_key("CFBundleLongVersionString") and \ - plist["CFBundleLongVersionString"] != LONGVERSION: - plist["CFBundleLongVersionString"] = LONGVERSION - changed = True - if plist.has_key("NSHumanReadableCopyright") and \ - plist["NSHumanReadableCopyright"] != COPYRIGHT: - plist["NSHumanReadableCopyright"] = COPYRIGHT - changed = True - if plist.has_key("CFBundleVersion") and \ - plist["CFBundleVersion"] != SHORTVERSION: - plist["CFBundleVersion"] = SHORTVERSION - changed = True - if plist.has_key("CFBundleShortVersionString") and \ - plist["CFBundleShortVersionString"] != SHORTVERSION: - plist["CFBundleShortVersionString"] = SHORTVERSION - changed = True - if changed: - os.rename(file, file + '~') - plist.write(file) - + plist = plistlib.Plist.fromFile(file) + changed = False + if plist.has_key("CFBundleGetInfoString") and \ + plist["CFBundleGetInfoString"] != LONGVERSION: + plist["CFBundleGetInfoString"] = LONGVERSION + changed = True + if plist.has_key("CFBundleLongVersionString") and \ + plist["CFBundleLongVersionString"] != LONGVERSION: + plist["CFBundleLongVersionString"] = LONGVERSION + changed = True + if plist.has_key("NSHumanReadableCopyright") and \ + plist["NSHumanReadableCopyright"] != COPYRIGHT: + plist["NSHumanReadableCopyright"] = COPYRIGHT + changed = True + if plist.has_key("CFBundleVersion") and \ + plist["CFBundleVersion"] != SHORTVERSION: + plist["CFBundleVersion"] = SHORTVERSION + changed = True + if plist.has_key("CFBundleShortVersionString") and \ + plist["CFBundleShortVersionString"] != SHORTVERSION: + plist["CFBundleShortVersionString"] = SHORTVERSION + changed = True + if changed: + os.rename(file, file + '~') + plist.write(file) + def main(): - if len(sys.argv) < 2: - print "Usage: %s plistfile ..." % sys.argv[0] - print "or: %s -a fix standard Python plist files" - sys.exit(1) - if sys.argv[1] == "-a": - files = [ - "../OSXResources/app/Info.plist", - "../OSXResources/framework/version.plist", - "../Tools/IDE/PackageManager.plist", - "../Tools/IDE/PythonIDE.plist", - "../scripts/BuildApplet.plist" - ] - if not os.path.exists(files[0]): - print "%s -a must be run from Mac/OSX directory" - sys.exit(1) - else: - files = sys.argv[1:] - for file in files: - fix(file) - sys.exit(0) - + if len(sys.argv) < 2: + print "Usage: %s plistfile ..." % sys.argv[0] + print "or: %s -a fix standard Python plist files" + sys.exit(1) + if sys.argv[1] == "-a": + files = [ + "../OSXResources/app/Info.plist", + "../OSXResources/framework/version.plist", + "../Tools/IDE/PackageManager.plist", + "../Tools/IDE/PythonIDE.plist", + "../scripts/BuildApplet.plist" + ] + if not os.path.exists(files[0]): + print "%s -a must be run from Mac/OSX directory" + sys.exit(1) + else: + files = sys.argv[1:] + for file in files: + fix(file) + sys.exit(0) + if __name__ == "__main__": - main() -
\ No newline at end of file + main() |