Ticket #552 (closed defect: fixed)

Opened 1 year ago

Last modified 1 month ago

[with patch; positive review] come up with a better way of deciding whether or not the SAGE install has moved

Reported by: was Assigned to: was
Priority: major Milestone: sage-3.2
Component: packages Keywords:
Cc:

Description

All too often, because of symlinks, etc., my script for detecting whether or not the SAGE install tree has moved gets it wrong. This is frickin' annoying. I would like a way to determine this that is much more intelligent.

The relevant code is SAGE_ROOT/local/bin/sage-location:

#!/usr/bin/env sage.bin

import os

SAGE_ROOT = os.environ['SAGE_ROOT']

location_file = '%s/local/lib/sage-current-location.txt'%SAGE_ROOT

def install_moved():
    if not os.path.exists(location_file):
        O = open(location_file,'w')
        O.write(SAGE_ROOT)
        O.close()
        return False, ''   # first time -- so no need to update; this was during the build.

    O = open(location_file)
    R = O.read().strip()
    O.close()
    if os.path.abspath(R) != os.path.abspath(SAGE_ROOT):  # really different
        return True, R  # it moved
    return False, ''

Any better ideas???

Attachments

trac_552.patch (0.7 kB) - added by anakha on 10/23/2008 04:23:14 PM.

Change History

09/06/2007 10:27:52 PM changed by craigcitro

  • component changed from algebraic geometry to packages.

09/26/2008 02:24:53 AM changed by mabshoff

We can use the shell program "readlink" since that follows symbolic links and friends. We already use it in the sage script to determine the actual location of the sage script.

Cheers,

Michael

10/23/2008 04:23:14 PM changed by anakha

  • attachment trac_552.patch added.

10/23/2008 04:24:24 PM changed by anakha

  • summary changed from come up with a better way of deciding whether or not the SAGE install has moved to [with patch; needs review] come up with a better way of deciding whether or not the SAGE install has moved.

os.path.realpath() takes care of symlinks.

It's that simple folks.

10/31/2008 02:27:13 PM changed by mabshoff

  • summary changed from [with patch; needs review] come up with a better way of deciding whether or not the SAGE install has moved to [with patch; positive review] come up with a better way of deciding whether or not the SAGE install has moved.
  • milestone changed from sage-3.2.1 to sage-3.2.

Positive review.

Cheers,

Michael

10/31/2008 02:30:19 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged in Sage 3.2.alpha2