source: CMIP6dreq/manage/step1.py @ 637

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

updated step1 to use parse_version from pkg_resources

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, string, 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 = string.join( open( 'versionConfig.tmpl' ).readlines() )
32tags = glob.glob( '../tags/*' )
33
34##f1 = lambda x: map( int, string.split(x, '.' ) )
35def f1( vs ):
36  if vs == 'latest':
37    return (0,0)
38  bits = string.split(vs, '.' )
39  estr = 'Version string should be "nn.nn" or "nn.[alpha|beta].nn": %s' % vs
40  assert len(bits) in [2,3,4], estr
41  if len( bits ) == 3:
42    assert bits[1] in ['alpha','beta'], estr
43  assert len(bits[0]) == 2 and len(bits[-1]) == 2, estr
44  bits[0] = int( bits[0] )
45  bits[-1] = int( bits[-1] )
46  return bits
47
48def tcmp(t1,t2):
49  if len(t1) != len(t2):
50    if t1[0] == t2[0]:
51      return cmp( len(t1), len(t2) )
52    else:
53      return cmp( t1[0], t2[0] )
54  elif len(t1) == 2:
55    if t1[0] == t2[0]:
56      return cmp( t1[1], t2[1] )
57    else:
58      return cmp( t1[0], t2[0] )
59  elif len(t1) == 3:
60    if t1[0] == t2[0]:
61      if t1[1] == t2[1]:
62        return cmp( t1[2], t2[2] )
63      else:
64        return cmp( t1[1], t2[1] )
65    else:
66      return cmp( t1[0], t2[0] )
67   
68##thistag, thiscomment = sys.argv[1:]
69thiscomment = sys.argv[1]
70thistag = version
71thistn = parse_version( version )
72if len(tags) > 0:
73  tn = map( parse_version,  tags )
74  tn.sort()
75  assert thistn > tn[-1], 'Requested tag not greater than last tag: %s' % str(tn[-1])
76
77oo = open( '../trunk/dreqPy/versionConfig.py', 'w' )
78for l in string.split( ii % (thistag, thiscomment), '\n' ):
79  oo.write( '%s\n' % string.strip(l) )
80oo.close()
81
82bashtmpl = """
83tag=%(thistag)s
84comment='"%(thiscomment)s"'
85
86echo $tag, $comment
87cd ../trunk
88svn ci -m "Updated setup for tag %(thistag)s"
89svn copy %(svnBaseUrl)s/trunk %(svnBaseUrl)s/tags/%(thistag)s -m "%(thiscomment)s"
90
91## cd %(svnBaseUrl)s/tags
92## svn del latest
93## svn ci -m "removed latest"
94#svn copy   %(svnBaseUrl)s/tags/%(thistag)s  %(svnBaseUrl)s/tags/latest
95"""
96
97oo = open( 'step2.sh', 'w' )
98oo.write( bashtmpl % locals() )
99oo.close()
Note: See TracBrowser for help on using the repository browser.