export SAGE_ROOT from '$SAGE_LOCAL/bin/sage'

18 views
Skip to first unread message

ph h

unread,
May 16, 2022, 11:07:48 PM5/16/22
to sage-devel
Dear All,

Please advise the use of SAGE_ROOT when it is exported from  '$SAGE_LOCAL/bin/sage':

# Determine SAGE_ROOT, SAGE_LOCAL, and SAGE_VENV.
unset SAGE_VENV
if [ -x "${SELF}-config" ]; then
    # optional sage-config console script, installed by sage_conf
    export SAGE_ROOT=$("${SELF}-config" SAGE_ROOT)
    export SAGE_LOCAL=$("${SELF}-config" SAGE_LOCAL)
fi

What if $SAGE_ROOT was deleted?

Thank you for your help.

Regards,

phiho

Matthias Koeppe

unread,
May 16, 2022, 11:14:46 PM5/16/22
to sage-devel
On Monday, May 16, 2022 at 8:07:48 PM UTC-7 hohoa...@gmail.com wrote:
Please advise the use of SAGE_ROOT when it is exported from  '$SAGE_LOCAL/bin/sage':

# Determine SAGE_ROOT, SAGE_LOCAL, and SAGE_VENV.
unset SAGE_VENV
if [ -x "${SELF}-config" ]; then
    # optional sage-config console script, installed by sage_conf
    export SAGE_ROOT=$("${SELF}-config" SAGE_ROOT)
    export SAGE_LOCAL=$("${SELF}-config" SAGE_LOCAL)
fi

What if $SAGE_ROOT was deleted?

see src/bin/sage-env around line 111
 

 

ph h

unread,
May 17, 2022, 12:12:53 AM5/17/22
to sage-...@googlegroups.com
Hi,

Is it this snippet, would you please elaborate?

<snippet from src/bin/sage-env around line 111>
# Make sure that SAGE_ROOT is either an absolute physical directory name
# or empty.
if [ -n "$SAGE_ROOT" ]; then
    export SAGE_ROOT=$(cd "$SAGE_ROOT" 2>/dev/null && pwd -P)
fi
</snippet from src/bin/sage-env around line 111>

BTW, it is rather confusing to see in '$SAGE_LOCAL/bin/sage':

if [ -f "${SELF}-env-config" ]; then
    # As of Trac #22731, sage-env-config is optional.
    . "${SELF}-env-config" >&2
fi

again export SAGE_ROOT and SAGE_LOCAL (same as in the original question, about 10 lines below)

Many references to $SAGE_ROOT in  '$SAGE_LOCAL/bin/sage'.

Is it a prerequisite that $SAGE_ROOT be part of the installation and it must stay as long as $SAGE_LOCAL is around?
Or these parts of  '$SAGE_LOCAL/bin/sage'. should be factored out?

Thank you for your help.

Regards,

phiho






--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/68b66f75-0fec-4e9b-bca3-e2ee04bde2e8n%40googlegroups.com.

Matthias Koeppe

unread,
May 17, 2022, 1:20:15 AM5/17/22
to sage-devel
On Monday, May 16, 2022 at 9:12:53 PM UTC-7 hohoa...@gmail.com wrote:
Is it this snippet, would you please elaborate?

<snippet from src/bin/sage-env around line 111>
# Make sure that SAGE_ROOT is either an absolute physical directory name
# or empty.
if [ -n "$SAGE_ROOT" ]; then
    export SAGE_ROOT=$(cd "$SAGE_ROOT" 2>/dev/null && pwd -P)
fi
</snippet from src/bin/sage-env around line 111>

Yes. You asked what happens when SAGE_ROOT has disappeared.
Well, in this case, after these lines are run, SAGE_ROOT will be empty.

BTW, it is rather confusing to see in '$SAGE_LOCAL/bin/sage':

if [ -f "${SELF}-env-config" ]; then
    # As of Trac #22731, sage-env-config is optional.
    . "${SELF}-env-config" >&2
fi

again export SAGE_ROOT and SAGE_LOCAL (same as in the original question, about 10 lines below)
 
It is actually $SAGE_VENV/bin/sage. When this script is invoked directly, it does not know about SAGE_ROOT. It first sources $SAGE_LOCAL/bin/sage-config to find the value of SAGE_ROOT and SAGE_LOCAL. Afterwards it sources $SAGE_LOCAL/bin/sage-env-config (and then $SAGE_LOCAL/bin/sage-env) to find the value of SAGE_ROOT and SAGE_LOCAL.

There is some redundancy there. sage-config is relatively new (it was added in https://trac.sagemath.org/ticket/29038), and it might be that in some downstream packaging of Sage it is not installed. sage-env-config has been around for a longer time, and eventually we may want to get rid of it.
See https://trac.sagemath.org/ticket/21707 for an overview of this work.
 
Is it a prerequisite that $SAGE_ROOT be part of the installation and it must stay as long as $SAGE_LOCAL is around?

No, it is not required. SAGE_LOCAL is a self-contained installation hierarchy. If you use "configure --prefix=..." to set SAGE_LOCAL to a directory outside of SAGE_ROOT, then it is OK to delete SAGE_ROOT afterwards. After you delete it, of course the commands that need SAGE_ROOT, such as "sage -i" for package installation, are no longer available.

Reply all
Reply to author
Forward
0 new messages