| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | # This python script creates Finder aliases for all the | 
					
						
							|  |  |  | # dynamically-loaded modules that "live in" in a single | 
					
						
							|  |  |  | # shared library. | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											1996-08-28 14:19:53 +00:00
										 |  |  | # This is sort-of a merger between Jack's MkPluginAliases | 
					
						
							|  |  |  | # and Guido's mkaliases. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Jack Jansen, CWI, August 1996 | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | import sys | 
					
						
							| 
									
										
										
										
											1996-08-28 14:19:53 +00:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											1995-09-24 21:06:50 +00:00
										 |  |  | import macfs | 
					
						
							| 
									
										
										
										
											1997-09-08 13:16:29 +00:00
										 |  |  | import MacOS | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | SPLASH_COPYCORE=512 | 
					
						
							|  |  |  | SPLASH_COPYCARBON=513 | 
					
						
							|  |  |  | SPLASH_COPYCLASSIC=514 | 
					
						
							|  |  |  | SPLASH_BUILDAPPLETS=515 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ALERT_NOCORE=516 | 
					
						
							| 
									
										
										
										
											2000-10-13 23:33:34 +00:00
										 |  |  | ALERT_NONBOOT=517 | 
					
						
							|  |  |  | ALERT_NONBOOT_COPY=1 | 
					
						
							|  |  |  | ALERT_NONBOOT_ALIAS=2 | 
					
						
							| 
									
										
										
										
											1997-09-08 13:16:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | APPLET_LIST=[ | 
					
						
							|  |  |  | 		(":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs", None), | 
					
						
							|  |  |  | 		(":Mac:scripts:BuildApplet.py", "BuildApplet", None), | 
					
						
							|  |  |  | 		(":Mac:scripts:BuildApplication.py", "BuildApplication", None), | 
					
						
							|  |  |  | ##		(":Mac:scripts:ConfigurePython.py", "ConfigurePython", None), | 
					
						
							|  |  |  | ##		(":Mac:scripts:ConfigurePython.py", "ConfigurePythonCarbon", "PythonInterpreterCarbon"), | 
					
						
							|  |  |  | ##		(":Mac:scripts:ConfigurePython.py", "ConfigurePythonClassic", "PythonInterpreterClassic"), | 
					
						
							|  |  |  | 		(":Mac:Tools:IDE:PythonIDE.py", "Python IDE", None), | 
					
						
							|  |  |  | 		(":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave", None), | 
					
						
							|  |  |  | 		(":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet", None), | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | def getextensiondirfile(fname): | 
					
						
							|  |  |  | 	import macfs | 
					
						
							|  |  |  | 	import MACFS | 
					
						
							|  |  |  | 	vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kExtensionFolderType, 0) | 
					
						
							|  |  |  | 	fss = macfs.FSSpec((vrefnum, dirid, fname)) | 
					
						
							|  |  |  | 	return fss.as_pathname() | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | def mkcorealias(src, altsrc): | 
					
						
							|  |  |  | 	import string | 
					
						
							|  |  |  | 	import macostools | 
					
						
							|  |  |  | 	version = string.split(sys.version)[0] | 
					
						
							|  |  |  | 	dst = getextensiondirfile(src+ ' ' + version) | 
					
						
							| 
									
										
										
										
											1999-01-30 17:46:34 +00:00
										 |  |  | 	if not os.path.exists(os.path.join(sys.exec_prefix, src)): | 
					
						
							|  |  |  | 		if not os.path.exists(os.path.join(sys.exec_prefix, altsrc)): | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | 			return 0 | 
					
						
							|  |  |  | 		src = altsrc | 
					
						
							|  |  |  | 	try: | 
					
						
							|  |  |  | 		os.unlink(dst) | 
					
						
							|  |  |  | 	except os.error: | 
					
						
							|  |  |  | 		pass | 
					
						
							| 
									
										
										
										
											2000-10-13 23:33:34 +00:00
										 |  |  | 	do_copy = 0 | 
					
						
							|  |  |  | 	if macfs.FSSpec(sys.exec_prefix).as_tuple()[0] != -1: # XXXX | 
					
						
							|  |  |  | 		try: | 
					
						
							|  |  |  | 			import Dlg | 
					
						
							|  |  |  | 			rv = Dlg.CautionAlert(ALERT_NONBOOT, None) | 
					
						
							|  |  |  | 			if rv == ALERT_NONBOOT_COPY: | 
					
						
							|  |  |  | 				do_copy = 1 | 
					
						
							|  |  |  | 		except ImportError: | 
					
						
							|  |  |  | 			pass | 
					
						
							|  |  |  | 	if do_copy: | 
					
						
							|  |  |  | 		macostools.copy(os.path.join(sys.exec_prefix, src), dst) | 
					
						
							|  |  |  | 	else: | 
					
						
							|  |  |  | 		macostools.mkalias(os.path.join(sys.exec_prefix, src), dst) | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | 	return 1 | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Copied from fullbuild, should probably go to buildtools | 
					
						
							|  |  |  | def buildapplet(top, dummy, list): | 
					
						
							|  |  |  | 	"""Create python applets""" | 
					
						
							|  |  |  | 	import buildtools | 
					
						
							|  |  |  | 	for src, dst, tmpl in list: | 
					
						
							|  |  |  | 		template = buildtools.findtemplate(tmpl) | 
					
						
							|  |  |  | 		if src[-3:] != '.py': | 
					
						
							|  |  |  | 			raise 'Should end in .py', src | 
					
						
							|  |  |  | 		base = os.path.basename(src) | 
					
						
							|  |  |  | 		src = os.path.join(top, src) | 
					
						
							|  |  |  | 		dst = os.path.join(top, dst) | 
					
						
							|  |  |  | 		try: | 
					
						
							|  |  |  | 			os.unlink(dst) | 
					
						
							|  |  |  | 		except os.error: | 
					
						
							|  |  |  | 			pass | 
					
						
							|  |  |  | 		try: | 
					
						
							|  |  |  | 			buildtools.process(template, src, dst, 1) | 
					
						
							|  |  |  | 		except buildtools.BuildError, arg: | 
					
						
							|  |  |  | 			print '**', dst, arg | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | def buildcopy(top, dummy, list): | 
					
						
							|  |  |  | 	import macostools | 
					
						
							|  |  |  | 	for src, dst in list: | 
					
						
							|  |  |  | 		src = os.path.join(top, src) | 
					
						
							|  |  |  | 		dst = os.path.join(top, dst) | 
					
						
							|  |  |  | 		import pdb ; pdb.set_trace() | 
					
						
							|  |  |  | 		macostools.copy(src, dst) | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | 	os.chdir(sys.prefix) | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											1997-10-10 15:49:36 +00:00
										 |  |  | 	sys.path.append('::Mac:Lib') | 
					
						
							| 
									
										
										
										
											1996-08-28 14:19:53 +00:00
										 |  |  | 	import macostools | 
					
						
							| 
									
										
										
										
											2001-02-14 17:04:51 +00:00
										 |  |  | 				 | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | 	# Create the PythonCore alias(es) | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | 	MacOS.splash(SPLASH_COPYCORE) | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | 	n = 0 | 
					
						
							| 
									
										
										
										
											1997-08-19 13:58:57 +00:00
										 |  |  | 	n = n + mkcorealias('PythonCore', 'PythonCore') | 
					
						
							| 
									
										
										
										
											2001-02-14 17:04:51 +00:00
										 |  |  | 	n = n + mkcorealias('PythonCoreCarbon', 'PythonCoreCarbon') | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | 	if n == 0: | 
					
						
							|  |  |  | 		Dlg.CautionAlert(ALERT_NOCORE, None) | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	if sys.argv[0][-7:] == 'Classic': | 
					
						
							|  |  |  | 		do_classic = 1 | 
					
						
							|  |  |  | 	elif sys.argv[0][-6:] == 'Carbon': | 
					
						
							|  |  |  | 		do_classic = 0 | 
					
						
							|  |  |  | 	elif sys.argv[0][-15:] == 'ConfigurePython' or sys.argv[0][-18:] == 'ConfigurePython.py': | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	else: | 
					
						
							|  |  |  | 		print "I don't know the sys.argv[0] function", sys.argv[0] | 
					
						
							| 
									
										
										
										
											1996-10-22 15:32:06 +00:00
										 |  |  | 		sys.exit(1) | 
					
						
							| 
									
										
										
										
											2001-02-17 23:31:48 +00:00
										 |  |  | 	if do_classic: | 
					
						
							|  |  |  | 		MacOS.splash(SPLASH_COPYCLASSIC) | 
					
						
							|  |  |  | 		buildcopy(sys.prefix, None, [("PythonInterpreterClassic", "PythonInterpreter")]) | 
					
						
							|  |  |  | 	else: | 
					
						
							|  |  |  | 		MacOS.splash(SPLASH_COPYCARBON) | 
					
						
							|  |  |  | 		buildcopy(sys.prefix, None, [("PythonInterpreterCarbon", "PythonInterpreter")]) | 
					
						
							|  |  |  | 	MacOS.splash(SPLASH_BUILDAPPLETS) | 
					
						
							|  |  |  | 	buildapplet(sys.prefix, None, APPLET_LIST) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-08-09 15:16:58 +00:00
										 |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  | 	main() |