Changeset 631
- Timestamp:
- 09/18/08 15:55:26 (2 months ago)
- Files:
-
- trunk/pysynphot/stsci_distutils_hack.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pysynphot/stsci_distutils_hack.py
r585 r631 1 1 # 2 2 # $HeadURL: https://www.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/pytools/lib/stsci_distutils_hack.py $ 3 # $Rev: 6933 $3 # $Rev: 7093 $ 4 4 # 5 5 # Implements setup.py code common to many of our packages. … … 17 17 # actually perform the install 18 18 # 19 # NOTE: This is not used to install pytools itself! 19 20 20 21 import sys … … 47 48 __set_svn_version__() 48 49 49 if "versiononly" in sys.argv[:2] : 50 # save the date when we last ran setup.py 51 __set_setup_date__() 52 53 if "version" in sys.argv : 50 54 sys.exit(0) 51 55 … … 205 209 # 206 210 207 def __set_svn_version__(path="./", fname='svn_version.py' ) :211 def __set_svn_version__(path="./", fname='svn_version.py' ) : 208 212 # 209 213 # path is the package where the version information will be stored. Default … … 215 219 # 216 220 217 if not os.path.isdir(".svn") :218 print "NO .svn DIR"219 # if there is no .svn directory here, there is no point in doing anything more.220 return221 222 221 info = None 223 222 rev = __get_svn_rev__(path) … … 242 241 243 242 f = open(version_file,'w') 244 f.write(" \n__svn_version__ = %s\n" % repr(revision))243 f.write("__svn_version__ = %s\n" % repr(revision)) 245 244 246 245 # info will be a multi-line string. We are not using repr(info) 247 246 # for readability; the output of "svn info" can not contain ''' 248 247 # unless you are doing something bad. 249 f.write("\n__full_svn_info__ = '''\n%s'''\n " % info)248 f.write("\n__full_svn_info__ = '''\n%s'''\n\n" % info) 250 249 f.close() 251 250 … … 256 255 # with popen3, stderr goes into a pipe where we ignore it, 257 256 # This means the user does not see errors. 258 (sin, sout, serr) = os.popen3('svnversion') 257 cmd = 'svnversion '+path 258 (sin, sout, serr) = os.popen3(cmd) 259 259 260 260 # pick up the first line of output … … 296 296 return "unknown" 297 297 298 ######## ######## ######## ######## ######## ######## ######## ######## 299 # 300 # note when we last ran setup.py -- what we really want is when the 301 # software was installed, but we can use the time we ran setup.py as 302 # a proxy for that. 303 # 304 305 def __set_setup_date__( path="./", fname='svn_version.py') : 306 import datetime 307 file = os.path.join(path,'lib',fname) 308 d = datetime.datetime.now() 309 l = [ ] 310 try : 311 # we don't expect this to fail ever, but it might 312 f = open(file,"r") 313 for line in f : 314 if line.find("# setupdate") < 0 : 315 l.append(line) 316 f.close() 317 except IOError : 318 pass 319 f=open(file,"w") 320 for line in l : 321 f.write(line) 322 323 f.write("%s # setupdate\n" % "import datetime") 324 f.write("%s # setupdate\n" % ("setupdate = "+repr(d))) 325 f.close() 326
