sagemath/sage

Meta-ticket: Remove use of SAGE_LIB and SAGE_EXTCODE variables

mkoeppe opened this issue · 11 comments

Portions of namespace packages can be installed in separate locations.

Hence, the variable sage.env.SAGE_LIB is no longer meaningful.

Instead, we should make use of the __path__ attribute of packages, https://python.readthedocs.io/en/stable/reference/import.html#module-path, which in the case of namespace packages is an iterable.

  • Use of SAGE_LIB in src/sage/misc/lazy_import_cache.py can possibly be removed after #33308

  • #33407 sage -t --all-installed

  • #33821 Remove use of SAGE_LIB in sage.misc

  • #33137 sage.env.sage_include_directories: Don't use distutils and SAGE_LIB

SAGE_EXTCODE should be replaced by using importlib.resources (more precisely, the backport package importlib-resources). Version 5.9.0 can do as_file with directories (https://importlib-resources.readthedocs.io/en/latest/history.html#v5-9-0)

Depends on #31306

CC: @tornaria

Component: refactoring

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

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
 Portions of namespace packages can be installed in separate locations. 
 
-Hence, the `SAGE_LIB` environment variable is no longer meaningful.
+Hence, the variable `sage.env.SAGE_LIB` is no longer meaningful.
 
comment:2

This could have some interesting consequences. At the moment SAGE_SRC default to SAGE_LIB if SAGE_ROOT is undefined. The most interesting thing about this behavior is that you can run the test suite on an installed version of sage without having the source. There may be other interesting things about using cython from inside sage witht the sage install rather than the source.

So those things may have to be thought about while removing that variable.

comment:3

It should also depend on the work on extcode, from env.py

SAGE_EXTCODE = var("SAGE_EXTCODE", join(SAGE_LIB, "sage", "ext_data"))

Description changed:

--- 
+++ 
@@ -2,3 +2,5 @@
 
 Hence, the variable `sage.env.SAGE_LIB` is no longer meaningful.
 
+Instead, we should make use of the `__path__` attribute of packages, https://python.readthedocs.io/en/stable/reference/import.html#module-path, which in the case of namespace packages is an iterable.
+

Dependencies: #31306

comment:6

Replying to @kiwifb:

It should also depend on the work on extcode, from env.py

SAGE_EXTCODE = var("SAGE_EXTCODE", join(SAGE_LIB, "sage", "ext_data"))

Yes, I've added #31306 as a dependency.

Description changed:

--- 
+++ 
@@ -4,3 +4,5 @@
 
 Instead, we should make use of the `__path__` attribute of packages, https://python.readthedocs.io/en/stable/reference/import.html#module-path, which in the case of namespace packages is an iterable.
 
+- Use of `SAGE_LIB` in `src/sage/misc/lazy_import_cache.py` can possibly be removed after #33308
+

Description changed:

--- 
+++ 
@@ -6,3 +6,5 @@
 
 - Use of `SAGE_LIB` in `src/sage/misc/lazy_import_cache.py` can possibly be removed after #33308
 
+- #33407 `sage -t --all-installed`
+

Description changed:

--- 
+++ 
@@ -7,4 +7,5 @@
 - Use of `SAGE_LIB` in `src/sage/misc/lazy_import_cache.py` can possibly be removed after #33308
 
 - #33407 `sage -t --all-installed`
+- #33821 Remove use of `SAGE_LIB` in `sage.misc`
 

Description changed:

--- 
+++ 
@@ -8,4 +8,4 @@
 
 - #33407 `sage -t --all-installed`
 - #33821 Remove use of `SAGE_LIB` in `sage.misc`
-
+- #33137 `sage.env.sage_include_directories`: Don't use `distutils` and `SAGE_LIB`

Description changed:

--- 
+++ 
@@ -9,3 +9,6 @@
 - #33407 `sage -t --all-installed`
 - #33821 Remove use of `SAGE_LIB` in `sage.misc`
 - #33137 `sage.env.sage_include_directories`: Don't use `distutils` and `SAGE_LIB`
+
+`SAGE_EXTCODE` should be replaced by using `importlib.resources` (more precisely, the backport package `importlib-resources`). Version 5.9.0 can do `as_file` with directories (https://importlib-resources.readthedocs.io/en/latest/history.html#v5-9-0)
+