Sage: Ticket #21707: Split sage-env into sage-build-env and sage-env
https://trac.sagemath.org/ticket/21707
<p>
<code>sage-env</code> is used by both Sage-the-distribution while building packages,
and by Sage at runtime.
</p>
<p>
It should be split into two or three separate scripts.
</p>
<ul><li><code>sage-build-env</code> is for the <strong>build-time environment variables for sage-the-distribution</strong>, should go into <code>build/bin</code> and not be installed. Or perhaps more stuff should be put into <code>build/make/install</code>
</li><li><code>sagelib-build-env</code> is for the <strong>build-time environment variables for sagelib</strong>
</li><li><code>sage-env</code> is for the <strong>run-time environment variables of sage</strong> and should be installed by <code>src/setup.py</code> (thus very late in the build process), rather than by <code>build/make/Makefile</code>. (<code>sage-env</code> will be very short and at some point hopefully disappear, if we want sagelib to become a standalone Python library - <a class="new ticket" href="https://trac.sagemath.org/ticket/21507" title="task: Task ticket: Make sagelib a pip-installable Python source package, ... (new)">#21507</a>)
</li></ul><p>
This is a step towards the cleaning of <code>src/bin</code> as described in <a class="new ticket" href="https://trac.sagemath.org/ticket/21569" title="enhancement: Install src/bin/* scripts via setup.py (scripts, console_scripts) (new)">#21569</a>, <a class="new ticket" href="https://trac.sagemath.org/ticket/21570" title="enhancement: Move non-scripts of src/bin/ elsewhere (and also move their install ... (new)">#21570</a>, <a class="new ticket" href="https://trac.sagemath.org/ticket/21559" title="enhancement: Move sage-the-distribution scripts from src/bin to build/bin (new)">#21559</a>.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/21707
Trac 1.1.6fbisseySat, 15 Oct 2016 08:54:42 GMT
https://trac.sagemath.org/ticket/21707#comment:1
https://trac.sagemath.org/ticket/21707#comment:1
<p>
One comment. Currently <code>sage_setup</code> is installed because it needs to be installed to be doctested - like the rest of sage. But nothing in <code>sage_setup</code> is really needed at runtime and distro can choose not to install it. I don't in sage-on-gentoo. I tend to push for thing not needed at runtime to be moved in there. And that's where I would have put <code>sage-build-env</code> but I am not going to fight it going into <code>build/bin</code> although I'd like everything used by <code>setup.py</code> to be neatly under <code>src</code>.
</p>
TicketmkoeppeSat, 15 Oct 2016 18:53:56 GMTdescription changed
https://trac.sagemath.org/ticket/21707#comment:2
https://trac.sagemath.org/ticket/21707#comment:2
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/21707?action=diff&version=2">diff</a>)
</li>
</ul>
<p>
Thanks - I've updated the description
</p>
TicketmkoeppeSat, 15 Oct 2016 18:54:23 GMTdescription changed
https://trac.sagemath.org/ticket/21707#comment:3
https://trac.sagemath.org/ticket/21707#comment:3
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/21707?action=diff&version=3">diff</a>)
</li>
</ul>
TicketembrayMon, 17 Oct 2016 09:25:04 GMT
https://trac.sagemath.org/ticket/21707#comment:4
https://trac.sagemath.org/ticket/21707#comment:4
<p>
I agree.
</p>
<p>
Consider a slight alternative: Rewrite sage-env as a Python script. This would give it much more flexibility and probably more legibility, including some command-line options for different environments (<code>--build</code>, especially).
</p>
<p>
The output would of course be the shell commands to actually set the variables. So rather than <code>source sage-env</code> one would <code>eval $(sage-env)</code>. My one concern is that it would be slower, but ideally it's something that shouldn't happen frequently anyways, but rather only when not already in sage-env.
</p>
TicketfbisseyMon, 17 Oct 2016 09:30:20 GMT
https://trac.sagemath.org/ticket/21707#comment:5
https://trac.sagemath.org/ticket/21707#comment:5
<p>
I have a tendency to mix up <code>sage-env</code> the script and <code>sage.env.py</code>, my comment is really an example of that. However a lot is common between the two.
</p>
TicketembrayMon, 17 Oct 2016 09:39:48 GMT
https://trac.sagemath.org/ticket/21707#comment:6
https://trac.sagemath.org/ticket/21707#comment:6
<p>
Right--they could be one in the same.
</p>
TicketfbisseyMon, 17 Oct 2016 09:46:17 GMT
https://trac.sagemath.org/ticket/21707#comment:7
https://trac.sagemath.org/ticket/21707#comment:7
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/21707#comment:6" title="Comment 6">embray</a>:
</p>
<blockquote class="citation">
<p>
Right--they could be one in the same.
</p>
</blockquote>
<blockquote>
<p>
I have thought about it often. Of course that really means that you'll have to removing all the build time stuff. But in sage-on-gentoo where I ship a very simplified sage-env (in /etc as well) they are virtually doing the same thing, one in shell, the other in python.
</p>
</blockquote>
TicketembrayMon, 17 Oct 2016 09:55:32 GMT
https://trac.sagemath.org/ticket/21707#comment:8
https://trac.sagemath.org/ticket/21707#comment:8
<p>
In either case--whether making a single script, or two separate shell scripts, this would be useful for gentoo (and probably other distros as well) then right?
</p>
TicketfbisseyMon, 17 Oct 2016 09:59:20 GMT
https://trac.sagemath.org/ticket/21707#comment:9
https://trac.sagemath.org/ticket/21707#comment:9
<p>
Probably, the current <code>sage-env</code> is a forest mostly dedicated to the build system. I just discard it and bring my own, it takes less space and maintenance than a mega patch.
</p>
TicketmkoeppeMon, 17 Oct 2016 14:34:14 GMT
https://trac.sagemath.org/ticket/21707#comment:10
https://trac.sagemath.org/ticket/21707#comment:10
<p>
Ideally, the configuration for sagelib runtime should take place in a generated Python file and not involve environment variables at all.
</p>
TicketembrayMon, 17 Oct 2016 14:40:26 GMT
https://trac.sagemath.org/ticket/21707#comment:11
https://trac.sagemath.org/ticket/21707#comment:11
<p>
More likely parts of it would be static, and other parts could be generated, but yes, what I meant above in terms of rewriting <code>sage-env</code> in Python was that it would not (by default) involve environment variables at all.
</p>
<p>
But it's still useful for interacting with other tools, especially for build purposes, as well as dropping into <code>./sage -sh</code> to be able to set environment variables, which is why I suggest a mode to output a list of variables that can be read from the shell.
</p>
TicketmkoeppeMon, 20 May 2019 00:29:22 GMTbranch set
https://trac.sagemath.org/ticket/21707#comment:12
https://trac.sagemath.org/ticket/21707#comment:12
<ul>
<li><strong>branch</strong>
set to <em>u/mkoeppe/split_sage_env_into_sage_build_env_and_sage_env</em>
</li>
</ul>
TicketmkoeppeMon, 20 May 2019 00:31:50 GMTstatus, cc, milestone changed; author, dependencies, commit set
https://trac.sagemath.org/ticket/21707#comment:13
https://trac.sagemath.org/ticket/21707#comment:13
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>author</strong>
set to <em>Matthias Koeppe</em>
</li>
<li><strong>cc</strong>
<em>dimpase</em> added
</li>
<li><strong>dependencies</strong>
set to <em>#25130</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-7.5</em> to <em>sage-8.8</em>
</li>
<li><strong>commit</strong>
set to <em>9189d609fa8cc90d616cb7ea05be405ce196295e</em>
</li>
</ul>
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=7405dd5b05259028e4dadc981b5bd309a124fbfb"><span class="icon"></span>7405dd5</a></td><td><code>Move sage-dist-helpers from src/bin to build/bin</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=9189d609fa8cc90d616cb7ea05be405ce196295e"><span class="icon"></span>9189d60</a></td><td><code>Split out build/bin/sage-build-env-config from sage-env-config</code>
</td></tr></table>
TicketembrayTue, 21 May 2019 15:19:50 GMT
https://trac.sagemath.org/ticket/21707#comment:14
https://trac.sagemath.org/ticket/21707#comment:14
<p>
As-is this is going to conflict with tickets like <a class="closed ticket" href="https://trac.sagemath.org/ticket/27825" title="enhancement: spkg-configure.m4 for libgd (closed: fixed)">#27825</a> that are adding still more environment variables needed at build-time to sage-env-config.
</p>
<p>
I'm completely in favor of this separation in principle though. The question is whether we should do this first and then update tickets like <a class="closed ticket" href="https://trac.sagemath.org/ticket/27825" title="enhancement: spkg-configure.m4 for libgd (closed: fixed)">#27825</a> on top of it, or the other way around?
</p>
TicketdimpaseTue, 21 May 2019 15:25:29 GMT
https://trac.sagemath.org/ticket/21707#comment:15
https://trac.sagemath.org/ticket/21707#comment:15
<p>
I really would like to first get our existing tickets (<a class="closed ticket" href="https://trac.sagemath.org/ticket/27825" title="enhancement: spkg-configure.m4 for libgd (closed: fixed)">#27825</a>, <a class="closed ticket" href="https://trac.sagemath.org/ticket/27822" title="task: Update configure with checks for mpfr, mpc, and ntl (closed: fixed)">#27822</a>) touching sage-env-config in.
</p>
TicketmkoeppeWed, 22 May 2019 20:34:34 GMT
https://trac.sagemath.org/ticket/21707#comment:16
https://trac.sagemath.org/ticket/21707#comment:16
<p>
The tickets would be trivial to rebase on top of this one.
</p>
TicketmkoeppeThu, 23 May 2019 15:08:52 GMT
https://trac.sagemath.org/ticket/21707#comment:17
https://trac.sagemath.org/ticket/21707#comment:17
<p>
Probably one should introduce a command <code>sage --buildsh</code>, which would provide the larger environment.
</p>
TicketembrayMon, 01 Jul 2019 12:44:57 GMT
https://trac.sagemath.org/ticket/21707#comment:18
https://trac.sagemath.org/ticket/21707#comment:18
<p>
For the sake of a bit more terseness I wonder if we could call it just <code>sage-env-build.in</code> and <code>sage-env-build</code>. The only reason for the <code>-config</code> in the other one is to distinguish it from plain <code>sage-env</code>.
</p>
<p>
Now that I look I'm not even entirely sure we need to separate <code>sage-env-config</code> from <code>sage-env</code>.
</p>
<p>
I think we could probably have a <code>sage-env.in</code> produce <code>sage-env</code> and get rid of the separate <code>sage-env-config</code> entirely, though it's possible there's some subtlety to that that I'm missing.
</p>
TicketembrayMon, 01 Jul 2019 12:57:45 GMTcommit, branch changed
https://trac.sagemath.org/ticket/21707#comment:19
https://trac.sagemath.org/ticket/21707#comment:19
<ul>
<li><strong>commit</strong>
changed from <em>9189d609fa8cc90d616cb7ea05be405ce196295e</em> to <em>ff0712125a3d05500a1f77e62c371d695d1a9794</em>
</li>
<li><strong>branch</strong>
changed from <em>u/mkoeppe/split_sage_env_into_sage_build_env_and_sage_env</em> to <em>public/split_sage_env_into_sage_build_env_and_sage_env</em>
</li>
</ul>
<p>
Went ahead and rebased on current develop so it could incorporate all the additional variables we've since added.
</p>
<p>
I didn't change the name of the script yet; I would still prefer to shorten it but if anyone disagrees we can leave it as-is.
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=a34a9f1c60297944ef119faafe65342cb9cc6ca2"><span class="icon"></span>a34a9f1</a></td><td><code>Move sage-dist-helpers from src/bin to build/bin</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=ff0712125a3d05500a1f77e62c371d695d1a9794"><span class="icon"></span>ff07121</a></td><td><code>Split out build/bin/sage-build-env-config from sage-env-config</code>
</td></tr></table>
TicketfbisseyMon, 01 Jul 2019 20:45:04 GMT
https://trac.sagemath.org/ticket/21707#comment:20
https://trac.sagemath.org/ticket/21707#comment:20
<p>
The only subtility to <code>sage-env-config</code> in my mind, is that you can touch it or even regenerate it without touching <code>sage-env</code>. But I am sure you don't need a separate file to achieve your objectives in either case.
</p>
TicketembrayTue, 02 Jul 2019 12:02:33 GMT
https://trac.sagemath.org/ticket/21707#comment:21
https://trac.sagemath.org/ticket/21707#comment:21
<p>
No, probably not. I might try it, though we'll leave that as a separate exercise from this ticket.
</p>
TicketembrayWed, 03 Jul 2019 11:37:56 GMTmilestone changed
https://trac.sagemath.org/ticket/21707#comment:22
https://trac.sagemath.org/ticket/21707#comment:22
<ul>
<li><strong>milestone</strong>
changed from <em>sage-8.8</em> to <em>sage-8.9</em>
</li>
</ul>
<p>
Moving tickets from the Sage 8.8 milestone that have been actively worked on in the last six months to the next release milestone (optimistically).
</p>
Ticket