Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

come up with a better way of deciding whether or not the SAGE install has moved #552

Closed
williamstein opened this issue Sep 1, 2007 · 4 comments

Comments

@williamstein
Copy link
Contributor

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???

Component: packages: standard

Issue created by migration from https://trac.sagemath.org/ticket/552

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 26, 2008

comment:2

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

@sagetrac-anakha
Copy link
Mannequin

sagetrac-anakha mannequin commented Oct 23, 2008

comment:3

Attachment: trac_552.patch.gz

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

It's that simple folks.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Oct 31, 2008

comment:4

Positive review.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.2.1, sage-3.2 Oct 31, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Oct 31, 2008

comment:5

Merged in Sage 3.2.alpha2

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Oct 31, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants