"""Create a distribution of ANUGA from latest revision This script is assumed to be run in the root directory of anuga from a working sandpit connected to svn It will create a distribution of ANUGA from the version which is currently checked out. To use the latest version run svn up before running this script. To use a specific revision (2187, say) run svn up -r 2187 first assuming that create_distribution.py (this script) and anything it depends on still work for that revision. This script works only on Linux! """ import sys import os import tempfile from anuga.utilities.system_tools import get_user_name, get_host_name from anuga.abstract_2d_finite_volumes.util import get_revision_number from anuga.abstract_2d_finite_volumes.util import store_version_info from anuga.config import major_revision from dirs_to_distribute import dirmap from anuga.utilities.data_audit_wrapper import IP_verified if sys.platform == 'win32': msg = ('This script is not written for Windows. ' 'Please run it on a Unix platform') raise Exception(msg) def xlog(msg): """Log a message and print to console.""" print(msg) #log(msg) def do_cmd(cmd): """Execute command. Ignore errors.""" try: xlog(cmd) os.system(cmd) except: pass # line separator lsep = '-' * 72 ###### # Get svn revision number and create file with version info for release. # This will mean that the version currently checked out is the one which # will be released. ###### svn_revision = get_revision_number() revision = '%s_%s' % (major_revision, svn_revision) xlog('Creating ANUGA revision %s' % revision) anuga_release_name = 'anuga-%s' % revision distro_filename = '%s.tgz' % anuga_release_name ###### # Create directory for this release. # It will be named like # anuga_release_1.0beta_4824 ###### release_area = os.path.join('~', 'anuga_releases') release_area = os.path.expanduser(release_area) do_cmd('mkdir %s' % release_area) release_dir = os.path.join(release_area, anuga_release_name ) do_cmd('mkdir %s' % release_dir) ###### # Create temporary area for svn to export source files ###### distro_dir = tempfile.mktemp() do_cmd('mkdir %s' % distro_dir) ###### # Get the ANUGA directories flagged for distribution ###### for source in dirmap: destination = os.path.join(distro_dir, dirmap[source]) do_cmd('svn export -r %d --quiet %s %s' % (svn_revision, source, destination)) # Store file with revision info for use with get_revision_number store_version_info(destination_path=distro_dir+'/anuga', verbose=True) ###### # IP Data Audit ###### xlog('Verifying data IP') if not IP_verified(distro_dir, verbose=True): msg = ('Files have not been verified for IP.\n' 'Each data file must have a license file with it.') raise Exception(msg) ###### # Compile and bundle up the LaTeX documentation ###### print('') print(lsep) xlog('Preparing User Manual (see update_anuga_user_manual.log)') print(lsep) do_cmd('cd anuga_core/documentation/user_manual;' 'python update_anuga_user_manual.py --no_html ' '1>update_anuga_user_manual.log 2>/dev/null') # Copy to distro_dir to become part of one tarball release_name = 'anuga_user_manual-%s.pdf' % revision do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf ' '%s/%s' % (distro_dir, release_name)) release_name = 'anuga_installation_guide-%s.pdf' % revision do_cmd('/bin/mv anuga_core/documentation/user_manual/' 'anuga_installation_guide.pdf %s/%s' % (distro_dir, release_name) release_name = 'anuga_whats_new-%s.pdf' % revision do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' % (distro_dir, release_name) ) ###### # Zip everything up ###### do_cmd('cd %s;tar cvfz %s *' % (distro_dir, distro_filename)) ###### # Move distro to release area ###### do_cmd('/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) ) ###### # Clean up ###### do_cmd('/bin/rm -rf %s/*' % distro_dir) ###### # Generate Windows installer ###### root = os.getcwd() from installation_files.windows.installer import create_config os.chdir('installation_files/windows') # Create ANUGA dir for NSI installer try: os.mkdir(os.path.join('files', anuga_release_name)) os.mkdir(os.path.join('files', 'anuga_viewer')) os.mkdir(os.path.join('files', 'prereqs')) os.mkdir(os.path.join('files', 'prereqs', 'netcdf')) except: pass # and unpack ANUGA into it do_cmd('cd files/%s; tar xvfz %s/%s' % (anuga_release_name, release_dir, distro_filename)) # Must be replaced by local folder to where SourceForge version is downloaded anuga_viewer_folder = 'anuga_viewer' python = 'python-2.5.4.msi' numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe' scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe' matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe' netcdf_folder = 'netcdf' mingw = 'MinGW-5.1.6.exe' # Generate NSI file create_config(revision, anuga_release_name, anuga_viewer_folder, python, numpy, scientific_python, matplotlib, netcdf_folder, mingw) # Package up files necessary to compile the installer on Windows and # move to release area # Cleanup in case there was something left from a previous attempt do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir) # Create subdirectories for windows installer do_cmd('cd %s; mkdir windows_installer; mkdir windows_installer/files' % release_dir) # Copy installion scrips and imagery across do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir) # Copy actual files used by Windows installer across do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir) # Come back to starting directory os.chdir(root) # Grab license file from anuga_core and copy to installer do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files' % release_dir ) xlog('NSI installer created') ###### # Print list of release files ###### xlog('Done') print('') print('') print(lsep) xlog('The release files are in %s:' % release_dir) os.system('ls -la %s' % release_dir) print(lsep) print('') print('') ###### # Copy release to various destinations ###### # FIXME (Ole): I don't think this is the way any more # due to changes at SourceForge. answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') if answer.lower() != 'n': print 'Uploading to sourceforge' import os, os.path release_dir = os.path.expanduser(release_dir) os.chdir(release_dir) print 'Reading from', os.getcwd() s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/' print s os.system(s) #from ftplib import FTP #ftp = FTP('upload.sourceforge.net') #print ftp.login() # Anonymous #print ftp.cwd('incoming') # #for filename in os.listdir('.'): # print 'Uploading %s... ' %filename, # sys.stdout.flush() # # fid=open(filename, 'rb') # print ftp.storbinary('STOR %s' %filename, fid) # fid.close() # #print 'FTP done' #print ftp.quit() print print lsep print ' ********************* NOTE *************************' print lsep print 'To complete this release you must log into' print 'http://sourceforge.net/projects/anuga as ANUGA admin' print 'and complete the process by selecting File Releases ' print 'in the admin menu there.' print lsep print print # Copy to the ANU #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir) print s os.system(s) ###### # Throw away code to drop all files into the RAMP download area # This is hardwired for Ole but shows how such a thing can be done # automatically. ###### if get_user_name() == 'ole' and get_host_name() == 'nautilus': answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') if answer.lower() == 'n': import sys; sys.exit() print 'Attempt to rsync data to perlite and datamining' # Copy to Georisk s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision) print s os.system(s) #os.system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# print 'Remember to update' print ' anuga_whats_new.tex' print ' sourceforge'