source: CMIP6dreq/manage/step1.py @ 422

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/manage/step1.py@422
Revision 422, 2.1 KB checked in by mjuckes, 5 years ago (diff)

miscellaneous cleaning for package installation

Line 
1""" Tag generation script.
2--------------------------
3
4USAGE
5-----
6
7python step1.py <version> "<comment on version>"  ## updates versionConfig.py and creates "step2.sh"
8bash step2.sh    ## checks trunk into repository, creates tagged version
9"""
10
11import sys, os, glob, string
12if os.path.isfile( 'step2.sh' ):
13  os.unlink( 'step2.sh' )
14
15svnBaseUrl = 'http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq'
16
17ii = string.join( open( 'versionConfig.tmpl' ).readlines() )
18tags = glob.glob( '../tags/*' )
19
20f1 = lambda x: map( int, string.split(x, '.' ) )
21def f1( vs ):
22  if vs == 'latest':
23    return (0,0)
24  bits = string.split(vs, '.' )
25  estr = 'Version string should be "nn.nn" or "nn.[alpha|beta].nn": %s' % vs
26  assert len(bits) in [2,3], estr
27  if len( bits ) == 3:
28    assert bits[1] in ['alpha','beta'], estr
29  assert len(bits[0]) == 2 and len(bits[-1]) == 2, estr
30  bits[0] = int( bits[0] )
31  bits[-1] = int( bits[-1] )
32  return bits
33
34def tcmp(t1,t2):
35  if len(t1) != len(t2):
36    if t1[0] == t2[0]:
37      return cmp( len(t1), len(t2) )
38    else:
39      return cmp( t1[0], t2[0] )
40  elif len(t1) == 2:
41    if t1[0] == t2[0]:
42      return cmp( t1[1], t2[1] )
43    else:
44      return cmp( t1[0], t2[0] )
45  elif len(t1) == 3:
46    if t1[0] == t2[0]:
47      if t1[1] == t2[1]:
48        return cmp( t1[2], t2[2] )
49      else:
50        return cmp( t1[1], t2[1] )
51    else:
52      return cmp( t1[0], t2[0] )
53   
54thistag, thiscomment = sys.argv[1:]
55thistn = tuple( f1( thistag ) )
56if len(tags) > 0:
57  tn = map( lambda x: tuple( f1(string.split(x,'/')[-1]) ),  tags )
58  tn.sort(tcmp)
59  assert thistn > tn[-1], 'Requested tag not greater than last tag: %s' % str(tn[-1])
60
61oo = open( '../trunk/dreqPy/versionConfig.py', 'w' )
62for l in string.split( ii % (thistag, thiscomment), '\n' ):
63  oo.write( '%s\n' % string.strip(l) )
64oo.close()
65
66bashtmpl = """
67tag=%(thistag)s
68comment='"%(thiscomment)s"'
69
70echo $tag, $comment
71cd ../trunk
72svn ci -m "Updated setup for tag %(thistag)s"
73svn copy %(svnBaseUrl)s/trunk %(svnBaseUrl)s/tags/%(thistag)s -m "%(thiscomment)s"
74"""
75
76oo = open( 'step2.sh', 'w' )
77oo.write( bashtmpl % locals() )
78oo.close()
Note: See TracBrowser for help on using the repository browser.