Ticket #4317: trac_4317_scripts.patch

File trac_4317_scripts.patch, 1.4 KB (added by was, 11 years ago)
  • sage-location

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1228120492 28800
    # Node ID ee7dd24af3f01562ffc673615734a8f264400267
    # Parent  8f87628eda2e8ce28dccbe98524387509ebec437
    trac #4317 -- Fix easy-install.pth after moving Sage)
    
    diff -r 8f87628eda2e -r ee7dd24af3f0 sage-location
    a b  
    127127        O.write(SAGE_ROOT)
    128128        O.close()       
    129129
     130def update_easy_install():
     131    """
     132    Find the easy-install.pth file in the current true, and replace the line
     133    with site-packages in it with a new line that has the correct path to
     134    our new site-packages.
     135    """
     136    base = '%s/local/lib/python2.5/site-packages'%SAGE_ROOT
     137    file = '%s/easy-install.pth'%base
     138    r = open(file).readlines()
     139    for i in range(len(r)):
     140        if 'site-packages' in r[i]:   # found it
     141            r[i] = base + '\n'
     142            open(file,'w').write(''.join(r))
     143            return
     144    print "Warning: something went wrong updating the easy-install.pth file."  # non fatal
     145
    130146def __mysig(a,b):
    131147    raise KeyboardInterrupt, "computation timed out because alarm was set for %s seconds"%__alarm_time
    132148
     
    143159        print "Do not interrupt this."
    144160        update_library_files(R)
    145161        update_hardcoded_files(SAGE_ROOT + '/local/lib/python/')
     162        update_easy_install()
    146163
    147164