import shutil import glob import os import subprocess import zipfile def create_src_zip(out_file, dir_to_zip): f = zipfile.ZipFile(out_file, 'w') # rewritten if exists for dirpath, dirnames, filenames in os.walk(dir_to_zip): for fname in filenames: fullname = os.path.join(dirpath, fname) # Display the added file and add the file to the zip. print fullname f.write(fullname) f.close() if __name__ == "__main__": trunk_dir = os.path.join(os.getcwd(), "trunk") src_out_dir = os.path.join(os.getcwd(), "trunk-src") # Create copy of the source and with svn details, ready to be packaged. print "Removing old src directory..." if os.path.exists(src_out_dir): shutil.rmtree(src_out_dir) print "Creating Trunk Source Package..." shutil.copytree(trunk_dir, src_out_dir, ignore=shutil.ignore_patterns('.svn*', '*.pyc', '*.py.bak', 'build', 'dist', 'bin', 'obj', 'etc', 'share', 'lib')) print "Zipping Source Tree" if os.path.exists("trunk-src.zip"): os.remove("trunk-src.zip") create_src_zip("trunk-src.zip", os.path.split(src_out_dir)[-1]) if os.path.exists(src_out_dir): shutil.rmtree(src_out_dir) # Create exe build. #execfile(os.path.join(os.getcwd(), "trunk", "setup.py")) os.chdir(trunk_dir) subprocess.call(["C:/Python26/Python.exe", "setup.py", "py2exe"]) # Create MSI Package