source: create_distribution.py @ 7567

Last change on this file since 7567 was 7513, checked in by nariman, 15 years ago

addition of matplotlib to the windows one-click installer.

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