From: <th...@us...> - 2003-10-08 11:54:17
|
Update of /cvsroot/py2exe/py2exe/sandbox/py2exe In directory sc8-pr-cvs1:/tmp/cvs-serv9873 Modified Files: build_exe.py Log Message: Remove the unbuffered global option. Collect all files copied to the dist-dir into a list. Add a typelib target attribute, this allows to add a tlb file as a resource into the executable. Make dry-run work better. Index: build_exe.py =================================================================== RCS file: /cvsroot/py2exe/py2exe/sandbox/py2exe/build_exe.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** build_exe.py 1 Oct 2003 19:25:23 -0000 1.31 --- build_exe.py 8 Oct 2003 11:54:14 -0000 1.32 *************** *** 1,2 **** --- 1,6 ---- + # Todo: + # + # Make 'unbuffered' a per-target option + from distutils.core import Command from distutils.spawn import spawn *************** *** 100,105 **** "optimization level: -O1 for \"python -O\", " "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), ! ('unbuffered', 'u', ! "unbuffered binary stdout and stderr"), ("excludes=", 'e', --- 104,109 ---- "optimization level: -O1 for \"python -O\", " "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), ! ('dist-dir=', 'd', ! "directory to put final built distributions in (default is dist)"), ("excludes=", 'e', *************** *** 153,156 **** --- 157,161 ---- # refactor, refactor, refactor! + # XXX zlib is only needed for zipimport from compressed archives (?) self.includes.append("zlib") # needed for zipimport self.includes.append("warnings") # needed by Python itself *************** *** 238,241 **** --- 243,248 ---- dry_run=self.dry_run) + all_files = [] + print "*** copy extensions ***" # copy the extensions to the target directory *************** *** 254,257 **** --- 261,265 ---- dst = os.path.join(self.lib_dir, os.path.basename(item.__file__)) self.copy_file(src, dst) + all_files.append(dst) # create the shared zipfile containing all Python modules *************** *** 260,263 **** --- 268,272 ---- arcname = self.make_lib_archive(archive_name, base_dir=self.collect_dir, verbose=self.verbose, dry_run=self.dry_run) + all_files.append(arcname) print "*** copy dlls ***" *************** *** 271,274 **** --- 280,284 ---- dst = os.path.join(self.lib_dir, base) self.copy_file(dll, dst) + all_files.append(dst) if self.distribution.has_data_files(): *************** *** 279,289 **** install_data.run() # build the executables for target in dist.console: ! self.build_executable(target, "run.exe", arcname, target.script) for target in dist.windows: ! self.build_executable(target, "run_w.exe", arcname, target.script) for target in dist.service: ! self.build_service(target, "run_svc.exe", arcname) for target in dist.com_server: --- 289,304 ---- install_data.run() + all_files.extend(install_data.get_outputs()) + # build the executables for target in dist.console: ! dst = self.build_executable(target, "run.exe", arcname, target.script) ! all_files.append(dst) for target in dist.windows: ! dst = self.build_executable(target, "run_w.exe", arcname, target.script) ! all_files.append(dst) for target in dist.service: ! dst = self.build_service(target, "run_svc.exe", arcname) ! all_files.append(dst) for target in dist.com_server: *************** *** 292,298 **** # console version for debugging, or is the regular # debug support in win32com sufficient? ! self.build_comserver(target, "run_w.exe", arcname) if getattr(target, "create_dll", True): ! self.build_comserver(target, "run_dll.dll", arcname) def fixup_distribution(self): --- 307,320 ---- # console version for debugging, or is the regular # debug support in win32com sufficient? ! dst = self.build_comserver(target, "run_w.exe", arcname) ! all_files.append(dst) if getattr(target, "create_dll", True): ! dst = self.build_comserver(target, "run_dll.dll", arcname) ! all_files.append(dst) ! ! # XXX debug code! ! ## for name in all_files: ! ## assert name.startswith(self.dist_dir) ! ## print "*", name[len(self.dist_dir)+1:] def fixup_distribution(self): *************** *** 345,349 **** boot = self.get_boot_script("com_servers") # and build it ! self.build_executable(target, template, arcname, boot, vars) def get_service_names(self, module_name): --- 367,371 ---- boot = self.get_boot_script("com_servers") # and build it ! return self.build_executable(target, template, arcname, boot, vars) def get_service_names(self, module_name): *************** *** 392,395 **** --- 414,419 ---- add_resource(exe_path, data, RT_STRING, id, 0) + return exe_path + def build_executable(self, target, template, arcname, script, vars={}): # Build an executable for the target *************** *** 442,446 **** script_bytes = si + code_bytes + '\000\000' self.announce("add script resource, %d bytes" % len(script_bytes)) ! add_resource(exe_path, script_bytes, "PYTHONSCRIPT", 1, 0) # Handle all resources specified by the target bitmap_resources = getattr(target, "bitmap_resources", []) --- 466,471 ---- script_bytes = si + code_bytes + '\000\000' self.announce("add script resource, %d bytes" % len(script_bytes)) ! if not self.dry_run: ! add_resource(exe_path, script_bytes, "PYTHONSCRIPT", 1, 0) # Handle all resources specified by the target bitmap_resources = getattr(target, "bitmap_resources", []) *************** *** 448,455 **** bmp_data = open(bmp_filename, "rb").read() # skip the 14 byte bitmap header. ! add_resource(exe_path, bmp_data[14:], RT_BITMAP, bmp_id, False) icon_resources = getattr(target, "icon_resources", []) for ico_id, ico_filename in icon_resources: ! add_icon(exe_path, ico_filename, ico_id) return exe_path --- 473,488 ---- bmp_data = open(bmp_filename, "rb").read() # skip the 14 byte bitmap header. ! if not self.dry_run: ! add_resource(exe_path, bmp_data[14:], RT_BITMAP, bmp_id, False) icon_resources = getattr(target, "icon_resources", []) for ico_id, ico_filename in icon_resources: ! if not self.dry_run: ! add_icon(exe_path, ico_filename, ico_id) ! ! typelib = getattr(target, "typelib", None) ! if typelib is not None: ! data = open(typelib, "rb").read() ! add_resource(exe_path, data, "TYPELIB", 1, False) ! return exe_path *************** *** 573,576 **** --- 606,611 ---- if not self.dry_run: open(pathname, "w").write(source) + else: + return from modulefinder import Module return Module(item.__name__, pathname) |