Opened 4 years ago

Last modified 3 years ago

#27040 closed enhancement

Cleanup sage.env — at Version 10

Reported by: Snark Owned by:
Priority: major Milestone: sage-8.7
Component: porting Keywords:
Cc: ​infinity0, thansen Merged in:
Authors: Jeroen Demeyer Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

  1. sage.all should be importable and mostly usable even if no environment variables like SAGE_ROOT or SAGE_LOCAL are set.
  1. Unneeded variables are removed.
  1. Some code cleanup.
  1. In many places, SAGE_LIB (installed location of Sage) can be used instead of SAGE_SRC.

Change History (10)

comment:1 Changed 4 years ago by Snark

  • Type changed from PLEASE CHANGE to enhancement

comment:2 follow-up: Changed 4 years ago by fbissey

SAGE_ROOT is harder. It doesn't correspond to any configuration features of anything. At best it is SAGE_LOCAL/... Any corners in which that wouldn't be true?

comment:3 Changed 4 years ago by fbissey

  • Description modified (diff)

comment:4 in reply to: ↑ 2 Changed 4 years ago by dunfield

Replying to fbissey:

SAGE_ROOT is harder. It doesn't correspond to any configuration features of anything. At best it is SAGE_LOCAL/... Any corners in which that wouldn't be true?

One place where the SAGE_LOCAL/.. pattern does not hold is the Debian package, where SAGE_LOCAL=/usr but SAGE_ROOT=/usr/share/sagemath. Moreover, on Debian SAGE_SCRIPTS_DIR is $SAGE_ROOT/bin rather than the more typical $SAGE_LOCAL/bin.

comment:5 follow-up: Changed 4 years ago by fbissey

I see. debian choose to do something like that. In sage-on-gentoo SAGE_ROOT points to a location where there used to be something but is now empty. Does debian use SAGE_ROOT anywhere else? Otherwise they could just define SAGE_SCRIPTS_DIR directly.

comment:6 in reply to: ↑ 5 Changed 4 years ago by dunfield

Replying to fbissey:

Does debian use SAGE_ROOT anywhere else? Otherwise they could just define SAGE_SCRIPTS_DIR directly.

To clarify, Debian doesn't change anything in env.py related to SAGE_SCRIPTS_DIR; the only fallback there is $SAGE_LOCAL/bin which does not contain the relevant scripts. Instead, in /usr/share/sagemath/bin/sage-env they manually set SAGE_ROOT=/usr/share/sagemath/ and SAGE_SCRIPTS_DIR=/usr/share/sagemath/bin.

On Debian, I tried setting SAGE_ROOT to a garbage value in sage-env, and Sage still started and worked fine near as I can tell.

comment:7 Changed 4 years ago by fbissey

I can see it now. In vanilla sage SAGE_SCRIPTS_DIR is only set in sage-env and used to source sage-env-config. But I certainly know that debian has plan for that folder.

So as far as we can see, it would be fine to set SAGE_ROOT in env.py. But it could probably be left as is without impacting anything and doing from sage import all in python should work without setting it.

Looking at it there is one thing I have set SAGE_ROOT for! sage/misc/copying.py tries to access SAGE_ROOT/COPYING.txt. So its current value in sage-on-gentoo is just so that bit works :) I need to change that to be more conformant to Gentoo policies.

There is a somewhat harmless appearance of SAGE_ROOT in sage/misc/citation.pyx. There is a more disturbing one in sage/misc/persist.pyx where I would have used DOT_SAGE to be honest. The rest is mostly doctesting, packaging, doctests themselves and documentation strings.

comment:8 Changed 4 years ago by jdemeyer

  • Component changed from scripts to porting
  • Description modified (diff)
  • Priority changed from trivial to major

comment:9 Changed 4 years ago by jdemeyer

  • Authors set to Jeroen Demeyer

comment:10 Changed 4 years ago by jdemeyer

  • Description modified (diff)
  • Summary changed from Make env.py use system values instead of using seeds to Cleanup sage.env
Note: See TracTickets for help on using tickets.