sagemath/sage

Only ./bootstrap should glob build/pkgs

mkoeppe opened this issue · 61 comments

Right now both ./bootstrap and ./configure (via m4/sage_spkg_collect.m4) glob build/pkgs.

In this ticket, we move this code into bootstrap, making the generated configure script more static, more straightforward to read and debug, and slightly faster because less work (and file system accesses) is done at the run time of configure.

Before:

$ time ./configure -q --without-system-ntl
real	0m40.860s
user	0m24.260s
sys	0m16.266s

After:

real	0m32.485s
user	0m20.773s
sys	0m10.462s

There are no changes in functionality.

We make a cosmetic fix to the ./configure --help output, fixing #33345 comment:20.

Even after this ticket, package-version.txt and dependencies are processed at configure run time, not at bootstrap time. So simple package upgrades can still be done by developers without having to run ./bootstrap.

CC: @dimpase @embray @orlitzky @jhpalmieri

Component: build: configure

Author: Matthias Koeppe

Branch/Commit: e7b8c3b

Reviewer: Michael Orlitzky

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

Description changed:

--- 
+++ 
@@ -1,3 +1,6 @@
 Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) glob.
 This should be streamlined. 
 
+Currently `./configure` is too sensitive to stray files/subdirectories in `build/pkgs` (such as those that are `.gitignore`'d in another branch), as noted in https://groups.google.com/d/msg/sage-release/eVvjvJ6Iii8/W51ouUKpDwAJ (thread).
+
+

Author: Matthias Koeppe

Dependencies: #28095

comment:6

Branch is on top of #28095.


New commits:

cf5607eAdd configure options '--enable-SPKG', --disable-SPKG' for optional/experimental SPKG
e4675d1Actually implement --enable-SPKG and --disable-SPKG
a3e0e47Change type of gmp, mpir to 'standard' (they are mutually exclusive standard packages)
4ed7b05Fix indentation of '--with-mp=' options in configure --help
82ee84dsage_spkg_enable.m4: Popdef what wass pushdef-ed
f7a84e0Enumerate packages in ./bootstrap; only warn about missing 'type' files; use the generated list in m4/sage_spkg_collect.m4 instead of globbing

Commit: f7a84e0

Changed commit from f7a84e0 to 355d147

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

6ec6413Merge branch 'develop' of git://trac.sagemath.org/sage into t/29114/no-spkg-globbing-in-configure
9295a74sage_spkg_enable.m4: Popdef what wass pushdef-ed
355d147Enumerate packages in ./bootstrap; only warn about missing 'type' files; use the generated list in m4/sage_spkg_collect.m4 instead of globbing

Branch pushed to git repo; I updated commit sha1. New commits:

bbd6521Makefile [configure]: also depend on build/pkgs/type

Changed commit from 355d147 to bbd6521

comment:9

Could you explain what "glob" means here?

comment:10

This reminds me of #27373 - which becomes obsolete as soon as this ticket and #29113 is done.

comment:11

It seems this is adding a bunch of previously unnecessary complication only because #29038, which I strongly objected to, was merged. I didn't step in then because I was busy with other things. Can we please roll back #29038 instead? I'm absolute convinced there's no need for it.

comment:13

See #29118 for an alternative proposal.

comment:14

I think we should progress, even if the route is not optimal, and Matthias has a lot of time for working on the build system now.

I hate to see ./configure running many times as I launch make, it really slows working on build system down, and I hope #29113 will happen soon.

comment:15

I should add, some of the changes in this ticket look reasonable. But it's mixed up with a bunch of other stuff (the way this is built on top of #28095 in particular is confusing). I'd like to start with #29118 and then see some fixes to individual bugs that predate #29038 .

comment:16

Replying to @dimpase:

I think we should progress, even if the route is not optimal, and Matthias has a lot of time for working on the build system now.

Progress on what though? I don't think you can "progress" on unsolid footing. I should note that part of the motivation behind #29038 is to enable the approach in #27824 which I also think is overcomplicated.

I don't think we should be making complicated changes on top of complicated changes to enable even more complicated changes. I hate to sound like Jeroen here because I've been on the other side of disagreements like this with him. But he'd probably be saying the same if he were here and I'd agree this time.

I would like to know what the bigger picture is to all this before making changes that don't seem well-motivated. Don't commit a sunk cost fallacy especially when it's relatively early...

comment:17

If you want to talk about simplification, why don't we just drop sage -i/-f instead of trying to keep this awful hack - something I proposed a year ago, and Jeroen objected...

Description changed:

--- 
+++ 
@@ -1,6 +1,8 @@
 Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) glob.
 This should be streamlined. 
 
-Currently `./configure` is too sensitive to stray files/subdirectories in `build/pkgs` (such as those that are `.gitignore`'d in another branch), as noted in https://groups.google.com/d/msg/sage-release/eVvjvJ6Iii8/W51ouUKpDwAJ (thread).
+Currently `./configure` is too sensitive to stray files/subdirectories in `build/pkgs` (such as those that are `.gitignore`'d in another branch), as noted in https://groups.google.com/d/msg/sage-release/eVvjvJ6Iii8/W51ouUKpDwAJ (thread). 
+While #29120 provides a quick workaround, the present ticket has the proper fix.
 
 
+

Changed dependencies from #28095 to #28095, #29120

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
-Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) glob.
+Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) [glob](https://en.wikipedia.org/wiki/Glob_(programming)) `build/pkgs`.
 This should be streamlined. 
 
 Currently `./configure` is too sensitive to stray files/subdirectories in `build/pkgs` (such as those that are `.gitignore`'d in another branch), as noted in https://groups.google.com/d/msg/sage-release/eVvjvJ6Iii8/W51ouUKpDwAJ (thread). 

Changed commit from bbd6521 to 7214ed7

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

1f193bfIssue only a warning, not an error, if there are stray files in build/pkgs
a04733aMerge branch 't/29120/one-line-fix-configure-too-sensitive-to-stray-files-in-build-pkgs' into t/29114/no-spkg-globbing-in-configure
25a55e0Enumerate packages in ./bootstrap; only warn about missing 'type' files; use the generated list in m4/sage_spkg_collect.m4 instead of globbing
7214ed7Makefile [configure]: also depend on build/pkgs/type
comment:21

I've rebased on top of #29120, which has the "hot fix", which may be easier to review and should go into the next beta.

The present ticket, #29114, is not so urgent.

comment:25

Since this list changes maybe once a year, we could just write it into configure.ac and avoid that part of the bootstrap process.

comment:26

I think that may be too radical a change (although I am personally in favor of it - agreeing with the autotools policies) - Sage has traditionally used source discovery instead of listing files explicitly. That's why in this ticket I just want to put the source discovery for build/pkgs into 1 script

comment:29

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

Changed commit from 7214ed7 to 0f59e29

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

0f59e29Enumerate packages in ./bootstrap; only warn about missing 'type' files; use the generated list in m4/sage_spkg_collect.m4 instead of globbing

Changed dependencies from #28095, #29120 to none

Description changed:

--- 
+++ 
@@ -1,8 +1,3 @@
 Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) [glob](https://en.wikipedia.org/wiki/Glob_(programming)) `build/pkgs`.
 This should be streamlined. 
 
-Currently `./configure` is too sensitive to stray files/subdirectories in `build/pkgs` (such as those that are `.gitignore`'d in another branch), as noted in https://groups.google.com/d/msg/sage-release/eVvjvJ6Iii8/W51ouUKpDwAJ (thread). 
-While #29120 provides a quick workaround, the present ticket has the proper fix.
-
-
-

Changed commit from 0f59e29 to c5c6caa

Branch pushed to git repo; I updated commit sha1. New commits:

a34f10bbootstrap, m4/sage_spkg_collect.m4: Pass SPKG_TYPE to SAGE_SPKG
025eb95bootstrap: Improve the SPKG.rst title parser
5813473bootstrap: First SAGE_SPKG_CONFIGURE, then SAGE_SPKG_FINALIZE
c5c6caam4/sage_spkg_collect.m4 (SAGE_SPKG_COLLECT_INIT): Rename from SAGE_SPKG_INIT

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

54974a3m4/sage_spkg_collect.m4 (SAGE_SPKG_COLLECT_INIT): Rename from SAGE_SPKG_INIT

Changed commit from c5c6caa to 54974a3

Branch pushed to git repo; I updated commit sha1. New commits:

2eba1f4m4/sage_spkg_collect.m4 (SAGE_SPKG_FINALIZE): Make SPKG_NAME, SPKG_TYPE m4 definitions, not shell variables
1e9c638m4/sage_spkg_collect.m4: Distinguish cases of SPKG_TYPE at macroexpansion time, not runtime
7310bd5bootstrap: First SAGE_SPKG_CONFIGURE, then SAGE_SPKG_FINALIZE (fixup)

Changed commit from 54974a3 to 7310bd5

Branch pushed to git repo; I updated commit sha1. New commits:

1eceb52bootstrap: Determine SPKG_SOURCE here, pass it as a macro argument to SAGE_SPKG_FINALIZE

Changed commit from 7310bd5 to 1eceb52

Branch pushed to git repo; I updated commit sha1. New commits:

a013698m4/sage_spkg_collect.m4: Distinguish underscore packages at macroexpansion time
8421854m4/sage_spkg_collect.m4: Handle in_sdist at macroexpansion time
7115a72m4/sage_spkg_collect.m4: Suppress some whitespace in the macroexpansion

Changed commit from 1eceb52 to 7115a72

Changed commit from 7115a72 to be824d6

Branch pushed to git repo; I updated commit sha1. New commits:

35fa89fbootstrap: Determine SPKG_TREE_VAR here, pass it as a macro argument to SAGE_SPKG_FINALIZE
8070dd9m4/sage_spkg_collect.m4: Make want_spkg a macro definition only
be824d6m4/sage_spkg_collect.m4: Replace read from requirements.txt by use of macro argument

Changed commit from be824d6 to e796fcf

Branch pushed to git repo; I updated commit sha1. New commits:

e796fcfm4/sage_spkg_enable.m4: Do not AC_REQUIRE([SAGE_SPKG_COLLECT_INIT]) here

Description changed:

--- 
+++ 
@@ -1,3 +1,23 @@
 Right now both `./bootstrap` and `./configure` (via `m4/sage_spkg_collect.m4`) [glob](https://en.wikipedia.org/wiki/Glob_(programming)) `build/pkgs`.
-This should be streamlined. 
 
+In this ticket, we move this code into `bootstrap`, making the generated `configure` script more static, more straightforward to read and debug, and slightly faster because less work (and file system accesses) is done at the run time of `configure`.
+
+Before:
+
+```
+$ time ./configure -q --without-system-ntl
+real	0m40.860s
+user	0m24.260s
+sys	0m16.266s
+```
+
+After:
+
+```
+real	0m32.485s
+user	0m20.773s
+sys	0m10.462s
+```
+
+There are no changes in functionality.
+

Branch pushed to git repo; I updated commit sha1. New commits:

a6d70c1m4/sage_spkg_collect.m4: Make SAGE_NEED_SYSTEM_PACKAGES_VAR a macro

Changed commit from e796fcf to a6d70c1

Changed commit from a6d70c1 to e7b8c3b

Branch pushed to git repo; I updated commit sha1. New commits:

7d77884bootstrap: More "installing..."
3b04496bootstrap: Consolidate output redirections
e7b8c3bm4/sage_spkg_collect.m4: Add missing m4_popdef
comment:45

./configure -q is a useful command. I see this output:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named lzma
./configure: line 39392: ,: command not found

The first is probably coming from the line if "$SAGE_BOOTSTRAP_PYTHON" -c "import lzma"; then :, no big deal. The other error is from a comma all by itself on line 39392 (that's with develop; it's line 42361 with this branch). Maybe an extra comma in build/pkgs/qhull/spkg-configure.m4?

comment:46

This is unrelated to the ticket and fixed in #33247

Description changed:

--- 
+++ 
@@ -21,3 +21,5 @@
 
 There are no changes in functionality.
 
+Even after this ticket, `package-version.txt` and `dependencies` are processed at `configure` run time, not at `bootstrap` time. So simple package upgrades can still be done by developers without having to run `./bootstrap`.
+

Description changed:

--- 
+++ 
@@ -21,5 +21,7 @@
 
 There are no changes in functionality.
 
+We make a cosmetic fix to the `./configure --help` output, fixing [#33345 comment:20](https://github.com/sagemath/sage/issues/33345#comment:20). 
+
 Even after this ticket, `package-version.txt` and `dependencies` are processed at `configure` run time, not at `bootstrap` time. So simple package upgrades can still be done by developers without having to run `./bootstrap`.
 
comment:49

In principle this looks good to me, and Sage builds. It would be great if someone more familiar with .m4 code could check the details.

comment:50

I looked through it all and don't see anything too scary. My one question is about the grep -v ^= that was added to bootstrap. It looks like that only affects the sagemath_categories, sagemath_objects, and sage_docbuild packages. Why do those have ======... headers in their SPKG.rst to begin with?

comment:51

Replying to @orlitzky:

It looks like that only affects the sagemath_categories, sagemath_objects, and sage_docbuild packages. Why do those have ======... headers in their SPKG.rst to begin with?

These files double as README.rst for these distributions, so this affects how it displays on PyPI.

Reviewer: Michael Orlitzky

comment:52

Ok, I don't believe in parsing SPKG.rst for package information anyway, so I don't mind the hack. (In the futue, I would rather we quit parsing that file than try to make them all nice and consistent.)

Everything else looks reasonable. Nothing broke in my sage build and there aren't any new subtle ./configure errors logged to the console.

John, don't forget to add yourself as a reviewer if you want to.

comment:53

Thanks.