source: branches/anuga_1_2_0/create_distribution.py @ 9737

Last change on this file since 9737 was 7889, checked in by wilsonr, 15 years ago

Initial try at getting it working.

File size: 8.5 KB
RevLine 
[3892]1"""Create a distribution of ANUGA from latest revision
2
3   This script is assumed to be run in the root directory of anuga
4   from a working sandpit connected to svn
5
[4170]6   It will create a distribution of ANUGA from the version which is
7   currently checked out.
8
9   To use the latest version run
10
11     svn up
12
13   before running this script. To use a specific revision (2187, say) run
14
15     svn up -r 2187
16
17   first assuming that create_distribution.py (this script) and anything
18   it depends on still work for that revision.
19
[5018]20   This script works only on Linux!
[3892]21"""
22
[7889]23import sys
[7489]24import os
[7889]25import tempfile
26
[3937]27from anuga.utilities.system_tools import get_user_name, get_host_name
[4170]28from anuga.abstract_2d_finite_volumes.util import get_revision_number
29from anuga.abstract_2d_finite_volumes.util import store_version_info
[5016]30from anuga.config import major_revision
[5068]31from dirs_to_distribute import dirmap
[5018]32from anuga.utilities.data_audit_wrapper import IP_verified
[3892]33
[7506]34
[7889]35if sys.platform == 'win32':
36    msg = ('This script is not written for Windows.  '
37           'Please run it on a Unix platform')
38    raise Exception(msg)
[3892]39
[7889]40def xlog(msg):
41    """Log a message and print to console."""
[3892]42
[7889]43    print(msg)
44    #log(msg)
45
46def do_cmd(cmd):
47    """Execute command.  Ignore errors."""
48   
49    try:
50        xlog(cmd)
51        os.system(cmd)
52    except:
53        pass
54
55
[4531]56# line separator
[7889]57lsep = '-' * 72
[3892]58
[4168]59
[7889]60######
61# Get svn revision number and create file with version info for release.
62# This will mean that the version currently checked out is the one which
63# will be released.
64######
[4168]65
[4170]66svn_revision = get_revision_number()
[7889]67revision = '%s_%s' % (major_revision, svn_revision)
68xlog('Creating ANUGA revision %s' % revision)
[3934]69
[7489]70anuga_release_name = 'anuga-%s' % revision
71distro_filename = '%s.tgz' % anuga_release_name
[3892]72
[7889]73######
[4837]74# Create directory for this release.
75# It will be named like
76#        anuga_release_1.0beta_4824
[7889]77######
[5540]78
[7889]79release_area = os.path.join('~', 'anuga_releases')
80release_area = os.path.expanduser(release_area)
81do_cmd('mkdir %s' % release_area)
82   
83release_dir = os.path.join(release_area, anuga_release_name )
84do_cmd('mkdir %s' % release_dir)
[5540]85
[7889]86######
[4837]87# Create temporary area for svn to export source files
[7889]88######
[3892]89
[7889]90distro_dir = tempfile.mktemp()
91do_cmd('mkdir %s' % distro_dir)
[3892]92
[7889]93######
[5068]94# Get the ANUGA directories flagged for distribution
[7889]95######
[5068]96
97for source in dirmap:
[7889]98    destination = os.path.join(distro_dir, dirmap[source])
[5068]99   
[7889]100    do_cmd('svn export -r %d --quiet %s %s'
101           % (svn_revision, source, destination))
[5068]102
[5016]103# Store file with revision info for use with get_revision_number
104store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
[4865]105
[7889]106######
107# IP Data Audit
108######
[4865]109
[7889]110xlog('Verifying data IP')
[5028]111if not IP_verified(distro_dir, verbose=True):
[7889]112    msg = ('Files have not been verified for IP.\n'
113           'Each data file must have a license file with it.')
114    raise Exception(msg)
[5016]115
[7889]116######
117# Compile and bundle up the LaTeX documentation
118######
[5016]119
[7889]120print('')
121print(lsep)
122xlog('Preparing User Manual (see update_anuga_user_manual.log)')
123print(lsep)
124do_cmd('cd anuga_core/documentation/user_manual;'
125       'python update_anuga_user_manual.py --no_html '
126           '1>update_anuga_user_manual.log 2>/dev/null')
[7607]127
128# Copy to distro_dir to become part of one tarball
129release_name = 'anuga_user_manual-%s.pdf' % revision
[7889]130do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf '
131       '%s/%s' % (distro_dir, release_name))
[7607]132
133release_name = 'anuga_installation_guide-%s.pdf' % revision
[7889]134do_cmd('/bin/mv anuga_core/documentation/user_manual/'
135           'anuga_installation_guide.pdf %s/%s' % (distro_dir, release_name)   
[7607]136
137release_name = 'anuga_whats_new-%s.pdf' % revision
[7889]138do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s'
139       % (distro_dir, release_name)    )
[7607]140   
[7889]141######
[4802]142# Zip everything up
[7889]143######
[3987]144
[7889]145do_cmd('cd %s;tar cvfz %s *' % (distro_dir, distro_filename))
146
147######
[3987]148# Move distro to release area
[7889]149######
[3987]150
[7889]151do_cmd('/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) )
152
153######
[3987]154# Clean up
[7889]155######
[3987]156
[7889]157do_cmd('/bin/rm -rf %s/*' % distro_dir) 
[3987]158
[7889]159######
[7489]160# Generate Windows installer
[7889]161######
[3892]162
[7489]163root = os.getcwd()
164from installation_files.windows.installer import create_config
[3902]165
[7489]166os.chdir('installation_files/windows')
[4531]167
[7489]168# Create ANUGA dir for NSI installer
169try:
[7889]170    os.mkdir(os.path.join('files', anuga_release_name))
171    os.mkdir(os.path.join('files', 'anuga_viewer'))
172    os.mkdir(os.path.join('files', 'prereqs'))
173    os.mkdir(os.path.join('files', 'prereqs', 'netcdf'))
[7489]174except:
175    pass
[4531]176
[7489]177# and unpack ANUGA into it
[7889]178do_cmd('cd files/%s; tar xvfz %s/%s'
179       % (anuga_release_name, release_dir, distro_filename))
[7489]180
181# Must be replaced by local folder to where SourceForge version is downloaded
[7506]182anuga_viewer_folder = 'anuga_viewer'
[7489]183python = 'python-2.5.4.msi'
[7506]184numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe'
185scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe'
[7513]186matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe'
[7506]187netcdf_folder = 'netcdf'
[7610]188mingw = 'MinGW-5.1.6.exe'
[7489]189
190# Generate NSI file
[7889]191create_config(revision, anuga_release_name, anuga_viewer_folder, python,
192              numpy, scientific_python, matplotlib, netcdf_folder, mingw)
[7489]193
194# Package up files necessary to compile the installer on Windows and
195# move to release area
[7889]196# Cleanup in case there was something left from a previous attempt
197do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir)
[7489]198   
199# Create subdirectories for windows installer
[7889]200do_cmd('cd %s; mkdir windows_installer; mkdir windows_installer/files'
201       % release_dir)
[7489]202
203# Copy installion scrips and imagery across
[7889]204do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir)
[7489]205
206# Copy actual files used by Windows installer across
[7889]207do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir)
[7489]208
209# Come back to starting directory
210os.chdir(root)
211                                                     
212# Grab license file from anuga_core and copy to installer
[7889]213do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'
214       % release_dir                                                       )
[7489]215
[7889]216xlog('NSI installer created')
[7489]217
[7889]218######
219# Print list of release files
220######
[7489]221
[7889]222xlog('Done')
223print('')
224print('')
225print(lsep)
226xlog('The release files are in %s:' % release_dir)
227os.system('ls -la %s' % release_dir)
228print(lsep)
229print('')
230print('')
[3922]231
[3934]232
[7889]233######
[4837]234# Copy release to various destinations
[7889]235######
[7489]236# FIXME (Ole): I don't think this is the way any more
237# due to changes at SourceForge.
238
[4531]239answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
240if answer.lower() != 'n':
241   
242    print 'Uploading to sourceforge'
[3934]243
[4531]244    import os, os.path
245    release_dir = os.path.expanduser(release_dir)
246    os.chdir(release_dir)
247    print 'Reading from', os.getcwd()
248
249
[5748]250    s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/'
[5746]251    print s
252    os.system(s)
[4531]253
[5746]254   
[4531]255
[5746]256    #from ftplib import FTP
257    #ftp = FTP('upload.sourceforge.net')
258    #print ftp.login() # Anonymous
259    #print ftp.cwd('incoming')
260    #
261    #for filename in os.listdir('.'):
262    #    print 'Uploading %s... ' %filename,
[7889]263    #    sys.stdout.flush()
[5746]264    #
265    #    fid=open(filename, 'rb')
266    #    print ftp.storbinary('STOR %s' %filename, fid)
267    #    fid.close()
268    #
269    #print 'FTP done'
270    #print ftp.quit()
[4531]271
272    print
273    print lsep
274    print '    ********************* NOTE *************************'
275    print lsep
276    print 'To complete this release you must log into'
277    print 'http://sourceforge.net/projects/anuga as ANUGA admin'
278    print 'and complete the process by selecting File Releases '
279    print 'in the admin menu there.'
280    print lsep
281    print
282    print
283   
284
285
[6426]286# Copy to the ANU
287#s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
288s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
289print s
[7889]290os.system(s)
[6426]291   
292   
[7889]293######
[3934]294# Throw away code to drop all files into the RAMP download area
[4532]295# This is hardwired for Ole but shows how such a thing can be done
296# automatically.
[7889]297######
[3934]298
[3937]299if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[6426]300    answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]')
[4802]301    if answer.lower() == 'n':
302        import sys; sys.exit()
303
[4531]304    print 'Attempt to rsync data to perlite and datamining'
[5746]305    # Copy to Georisk
[7406]306    s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision)
[3937]307    print s
[7889]308    os.system(s)
[3937]309   
[7889]310    #os.system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
[3990]311   
[6426]312print 'Remember to update' 
313print '    anuga_whats_new.tex'
314print '    sourceforge'
[5540]315   
Note: See TracBrowser for help on using the repository browser.