Changeset 631

Show
Ignore:
Timestamp:
09/18/08 15:55:26 (2 months ago)
Author:
sienkiew
Message:

bring over distutils hack from stsci_python

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pysynphot/stsci_distutils_hack.py

    r585 r631  
    11# 
    22# $HeadURL: https://www.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/pytools/lib/stsci_distutils_hack.py $ 
    3 # $Rev: 6933 $ 
     3# $Rev: 7093 $ 
    44# 
    55# Implements setup.py code common to many of our packages. 
     
    1717# actually perform the install 
    1818# 
     19# NOTE: This is not used to install pytools itself! 
    1920 
    2021import sys 
     
    4748    __set_svn_version__() 
    4849 
    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 : 
    5054        sys.exit(0) 
    5155 
     
    205209# 
    206210 
    207 def __set_svn_version__(path="./", fname='svn_version.py' )
     211def __set_svn_version__(path="./", fname='svn_version.py' )
    208212    # 
    209213    # path is the package where the version information will be stored.  Default 
     
    215219    # 
    216220 
    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         return 
    221  
    222221    info = None 
    223222    rev = __get_svn_rev__(path) 
     
    242241 
    243242    f = open(version_file,'w') 
    244     f.write("\n__svn_version__ = %s\n" % repr(revision)) 
     243    f.write("__svn_version__ = %s\n" % repr(revision)) 
    245244 
    246245    # info will be a multi-line string.  We are not using repr(info) 
    247246    # for readability; the output of "svn info" can not contain ''' 
    248247    # 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) 
    250249    f.close() 
    251250 
     
    256255        # with popen3,  stderr goes into a pipe where we ignore it,  
    257256        # 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) 
    259259 
    260260        # pick up the first line of output 
     
    296296    return "unknown" 
    297297 
     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 
     305def __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