source: CMIP6dreq/manage/step1.py @ 1352

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/manage/step1.py
Revision 1352, 2.5 KB checked in by mjuckes, 3 months ago (diff)

update to python3

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