id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
21707,Meta-ticket: Split sage-env into 5 to clean up sage configuration,mkoeppe,,"`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:
1. Sage-the-distribution while building spkgs,
2. Sage-the-distribution for building sagelib,
3. for environment variables needed to start Sage,
4. as variables by Sage at runtime (through `sage.env`), and
5. for environment variables affecting subprocesses of Python invoked by sagelib modules.
This ticket proposes to split the configuration according to these 5 contexts. This will make the installation of Sage more modular and flexible.
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.
b. In `build/make/Makefile.in` and the scripts generated by `build/bin/sage-spkg`, source `build/bin/sage-build-env` in addition to `src/bin/sage-env`. This is #29052.
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./2. (Note that not all compiler-related environment variables can be moved exclusively to 1./2. – 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`.) As well as users' use of `pip` to install additional Python packages!
d. Eventually, we will remove the call to `src/bin/sage-env` from the build scripts.
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).
a. In `src/Makefile`, poison the `SAGE_LOCAL` variable.
- #29411: make sagelib a script package
- #29779: `pkg-config` installed from SPKG `pkgconf` should not depend on environment variable `SAGE_LOCAL`
b. Pass `SAGE_PKGS` (if still needed at all - see #28815 or #29705) via `sage-config` instead of from `src/Makefile`.
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`).
a. Initially, phase out `src/bin/sage-env-config` by using `sage-config` instead.
- #29384: Clean up `src/bin/sage-env-config.in`: Move logic to `src/bin/sage-env`, move non-environment configuration variables to `sage_conf.py`
- #29825: Clean-up for src/bin/sage-env
b. Set `sage.env` variables via the Python module `sage_conf` instead of relying on information from environment variables. Example: `CYSIGNALS_CRASH_DAYS`
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`
- #30563: Use configuration variable `MAXIMA` instead of hardcoding ""maxima""
- #30818 Set environment for subprocesses invoked by Sage
d. Finally, remove use of `sage-env` for all purposes except for `sage -sh`.
**Aspects of downstream sage packaging:**
- The goal is to enable downstream sage packagers to use a whole unmodified `src` directory to build and install sagelib.
- more precisely, to use the pip-installable source package created by `build/pkgs/sagelib/spkg-src` (#29950); see also #30036 (pip-installable sage)
- Downstream packagers could provide their own ""implementation"" (one Python module [https://git.sagemath.org/sage.git/tree/build/pkgs/sage_conf/src/sage_conf.py.in?id=1c5d011b5f05a954dd2ea810635c9d59cc48e7b5 sage_conf.py]) of the configuration module defined by #29038, instead of patching sources. They would not necessarily use the reference implementation in `build/pkgs/sage_conf`, which is intended for use with sage-the-distribution.
**Binary packages:**
- #31417 version of package `sage_conf` for relocatable binary distributions
**pip-installable Sage**
- #29039 pip-installable version of package `sage_conf` - installs non-Python bits of the Sage distribution in `~/.sage/`
- #31396 relocatable wheel version of package `sage_conf`
**More related tickets:**
- cleaning of `src/bin` as described in #21570, #21559.
- #25486: Discover `SAGE_SCRIPTS_DIR` to make `$SAGE_LOCAL/bin/sage` work from any directory, in an environment without `SAGE_*` variables - this adds a `SAGE_ROOT` variable to `sage-env-config`
- #30724: `src/bin/sage-env`, `src/bin/sage-env-config.in`: Remove PYTHON_FOR_VENV
- #29133 META-META-TICKET: Build, packaging, testing improvements",task,needs_work,major,sage-9.5,build,,sd109,embray jdemeyer leif fbissey dimpase isuruf arojas infinity0 gh-timokau mjo jhpalmieri,,Matthias Koeppe,,N/A,,,,"#29038, #29052",