Hi,

>  running sage from a symlink is something that should be supported

Absolutely, yes.

In a hurry she forgot to mention that :

SELF=$(cd `dirname $0` ; pwd)/`basename $0`

is for the links from within $SAGE_ROOT only, of course any link from
outside would need to be resolved with 'resolvelinks'.
Unless this 'readlink.py' works on all platforms that 'sage' supports:

<readlink.py>
#!/usr/bin/python
import sys, os

thispath=sys.argv[1]

if os.path.islink( thispath  ):
     thispath  =os.readlink( thispath  )
else:
     thispath  =os.path.abspath( thispath  )

print( thispath  )
</readlink.py>

and in top level 'sage', it is embedded:

readlink() { cat << READLINK
import sys, os
thispath="$0"

if os.path.islink(thispath):
    thispath=os.readlink(thispath)
else:
    thispath=os.path.abspath(thispath)

print(thispath)

READLINK
}

SELF=`readlink | python3`

and exported:

export READLINKPY=$SAGE_ROOT/readlink.py

in 'sage.src.bin.sage':

SELF=`$READLINKPY "${0}"`

In 'sage.src.bin.sage-env':

DOT_SAGE=`$READLINKPY "$HOME/.sage"
nodeenv_activate=`$READLINKPY "$nodeenv_activate"`

Is 'resolvelinks' better than Python 'os.readlink()'? Are there any issues
with  the latter?
Would it be nice if 'Sage' has more Python code?

Regards,

phiho


On Wed, May 4, 2022 at 8:15 AM Michael Orlitzky <mich...@orlitzky.com>
wrote:

> On Wed, 2022-05-04 at 01:56 -0400, ph h wrote:
> > Hi,
> >
> > > Sadly, readlink is not a POSIX standard utility; otherwise we would
> > > already be using it in place of resolvelinks().
> >
> > In that case, please try this:
> >
> > #SELF=$(readlink -f $0)
> > SELF=$(cd `dirname $0` ; pwd)/`basename $0`
> >
>
> That will fail if $0 is a symlink, because `dirname $0` will get the
> directory that contains the symlink itself and not its target.
>
> Our installation instructions suggest creating such a symlink:
>
>   https://doc.sagemath.org/html/en/installation/source.html
>
> I don't have much nice to say about that installation procedure, but
> running sage from a symlink is something that should be supported
> regardless of how it was installed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/c4295d4a6af9e3b69c72b4f4ba425325d52e5634.camel%40orlitzky.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CALZQg1ZtB9ybXYgqiFUkx8g3Mx4j80qoQjWTd_vb8V4Bgsno7Q%40mail.gmail.com.

Reply via email to