Ticket #552 (closed defect: fixed)

Opened 3 years ago

Last modified 17 months ago

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

Reported by: was Owned by: was
Priority: major Milestone: sage-3.2
Component: packages Keywords:
Cc: Author(s):
Report Upstream: Reviewer(s):
Merged in: Work issues:

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 Download (0.7 KB) - added by anakha 17 months ago.

Change History

Changed 3 years ago by craigcitro

  • component changed from algebraic geometry to packages

Changed 18 months ago 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

Changed 17 months ago by anakha

Changed 17 months ago 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.

Changed 17 months ago 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

Changed 17 months ago by mabshoff

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

Merged in Sage 3.2.alpha2

Note: See TracTickets for help on using tickets.