1 | | `sage-env` is used by both Sage-the-distribution while building packages, |
2 | | and by Sage at runtime. |
| 1 | `src/bin/sage-env` (with generated configuration in `src/bin/sage-env-config`; installed in `$SAGE_LOCAL/bin`) is used in all of the following contexts: |
| 2 | 1. Sage-the-distribution while building spkgs, |
| 3 | 2. Sage-the-distribution for building sagelib, |
| 4 | 3. for environment variables needed to start Sage, |
| 5 | 4. as variables by Sage at runtime (through `sage.env`), and |
| 6 | 5. for environment variables affecting subprocesses of Python invoked by sagelib modules. |
4 | | It should be split into two or three separate scripts. |
5 | | - `sage-build-env` is for the '''build-time environment variables for sage-the-distribution''', should go into `build/bin` and not be installed. Or perhaps more stuff should be put into `build/make/install` |
6 | | - `sagelib-build-env` is for the '''build-time environment variables for sagelib''' |
7 | | - `sage-env` is for the '''run-time environment variables of sage''' and should be installed by `src/setup.py` (thus very late in the build process), rather than by `build/make/Makefile`. (`sage-env` will be very short and at some point hopefully disappear, if we want sagelib to become a standalone Python library - #21507) |
| 8 | This ticket proposes to split the configuration according to these 5 contexts. This will make the installation of Sage more modular and flexible. |
9 | | This is a step towards the cleaning of `src/bin` as described in #21569, #21570, #21559. |
| 10 | 1./2. Create `build/bin/sage-build-env`(with generated configuration in `build/bin/sage-build-env-config`) for the build-time environment variables for sage-the-distribution (spkg and sagelib). It is not installed in $SAGE_LOCAL. |
| 11 | a. Initially, `build/bin/sage-env` will call `src/bin/sage-env`. |
| 12 | b. In `build/make/deps`, call `build/bin/sage-build-env` instead of `src/bin/sage-env`. |
| 13 | c. Gradually, we will move settings from `src/bin/sage-env[-config]` to `build/bin/sage-build-env[-config]` that are known to be only needed for 1. (Note that not all compiler-related environment variables can be moved exclusively to 1 – some need to be added to 5 as well for some some calls to compilers needed at runtime to support things like `%cython` (?) and `sage.calculus.desolvers.desolve_mintides`.) |
| 14 | d. Eventually, we will remove the call to `src/bin/sage-env`. |
| 15 | |
| 16 | 2./3. Obtain sagelib's build-time configuration such as `src/setup.py`'s `library_dirs` and runtime information (`sage.env`) from `sage-config` (introduced in #29038). |
| 17 | a. In `src/Makefile`, poison the `SAGE_LOCAL` variable. |
| 18 | b. Pass `SAGE_PKGS` (if still needed at all - see #28815) via `sage-config` instead of from `src/Makefile`. |
| 19 | |
| 20 | 3./4./5. Using `sage_conf` (Python module and script `sage-config`, #29038), make `sage.all` fully functional when imported from a Python, without setting any environment variables (`sage-env`). |
| 21 | a. Initially, phase out `src/bin/sage-env-config` by using `sage-config` instead. |
| 22 | b. Set `sage.env` variables via the Python module `sage_conf` instead of relying on information from environment variables. Example: `CYSIGNALS_CRASH_DAYS` |
| 23 | c. Set environment variables that are needed only by subprocesses invoked by sagelib in the environment of these subprocesses, rather than relying on them begin set in `sage-env`. This environment could be provided by a variable `sage_conf.SAGE_SUBPROCESS_ENV` and/or more invidual variables. Example: `R_PROFILE` |
| 24 | d. Finally, remove use of `sage-env` for all purposes except for `sage -sh`. |
| 25 | |
| 26 | Related: |
| 27 | - cleaning of `src/bin` as described in #21569, #21570, #21559. |
| 28 | - sagelib as a standalone Python library - #21507) |