Opened 3 years ago

Last modified 3 years ago

#21480 closed enhancement

Make sagelib setup.sh self-contained, independent of SAGE_ROOT, and handle --build-base — at Version 44

Reported by: mkoeppe Owned by:
Priority: blocker Milestone: sage-7.4
Component: build Keywords:
Cc: felixs, jdemeyer, fbissey, embray, leif, vbraun, dimpase, jhpalmieri, vdelecroix, saraedum, slabbe, nthiery, mmezzarobba Merged in:
Authors: Matthias Koeppe Reviewers:
Report Upstream: N/A Work issues:
Branch: u/mkoeppe/keep_src__clean_by_using___build_base_when_building_sagelib (Commits) Commit: d829eb435729cf3280a5206d005bffef8e1dfd52
Dependencies: Stopgaps:

Description (last modified by mkoeppe)

This ticket changes the build process of sagelib in the following way:

  • src/Makefile delegates ALL building to src/setup.sh
  • src/setup.sh no longer depends on environment variables $SAGE_ROOT, $SAGE_SRC, $SAGE_DOC_SRC, $SAGE_CYTHONIZED etc. (to demonstrate this, Makefile poisons these environment variables). It still depends on $SAGE_LOCAL and environment variables that point below it.
  • src/setup.sh accepts build --build-base=BUILD-BASE. This is where building takes place (where subdirectories cython_debug, cythonized, lib.UNAME, temp.UNAME are created). The default is the build subdirectory (of src).
  • src/Makefile sets --build-base to the build-sagelib subdirectory (of src).

This ticket is meant as:

  • preparation for VPATH builds of sage-the-distribution (#21469)
  • working towards the goal of making sagelib pip-installable

. . . . . . .

Some possibly useful information:

  • Documentation on distutils (https://docs.python.org/2/install/), describing use of --build-base to do VPATH builds.
  • pip install keeps the source directory clean, building instead in a temporary directory, by copying the sources. pip install also offers options --build to select a build directory, but there are some pip issues: 2060, 2053, 804 that affect this
  • #14807 has some tricks to making VPATH builds work without copying all python source files. But it uses automake instead of setup.sh; we will not do this in our ticket.

Change History (44)

comment:1 Changed 3 years ago by fbissey

Am interesting issue is that technically cython_debug has to be installed somewhere (preferably somewhere standard) to be accessible at runtime separately from the source.

I do something in sage-on-gentoo but that's not really satisfactory.

Last edited 3 years ago by fbissey (previous) (diff)

comment:2 in reply to: ↑ description ; follow-up: Changed 3 years ago by leif

Replying to mkoeppe:

In preparation for VPATH builds of sage-the-distribution (#21469), let's keep src/ clean by using setup.py --build-base=$SAGE_ROOT/var/tmp/sage/build/sagelib

Please use --build-base=$SAGE_BUILD_DIR/sagelib.

comment:3 Changed 3 years ago by leif

... and sagelib perhaps with a version suffix.

comment:4 in reply to: ↑ 2 ; follow-up: Changed 3 years ago by mkoeppe

Replying to leif:

Replying to mkoeppe:

In preparation for VPATH builds of sage-the-distribution (#21469), let's keep src/ clean by using setup.py --build-base=$SAGE_ROOT/var/tmp/sage/build/sagelib

Please use --build-base=$SAGE_BUILD_DIR/sagelib.

Yes, the plan *after* #21469 is to use the Sage builddir -- not just for sagelib, but also for other packages.

*Before* #21469 is merged, I want to use $SAGE_ROOT/var/tmp/sage/build/sagelib to match what other packages do.

comment:5 Changed 3 years ago by mkoeppe

  • Description modified (diff)

Ah, I see what you meant, now I've found $SAGE_BUILD_DIR. Changed description accordingly.

comment:6 in reply to: ↑ 4 ; follow-up: Changed 3 years ago by leif

Replying to mkoeppe:

Replying to leif:

Replying to mkoeppe:

In preparation for VPATH builds of sage-the-distribution (#21469), let's keep src/ clean by using setup.py --build-base=$SAGE_ROOT/var/tmp/sage/build/sagelib

Please use --build-base=$SAGE_BUILD_DIR/sagelib.

Yes, the plan *after* #21469 is to use the Sage builddir -- not just for sagelib, but also for other packages.

??? SAGE_BUILD_DIR exists since years already... (Its default is $SAGE_ROOT/var/tmp/sage/build/.)


*Before* #21469 is merged, I want to use $SAGE_ROOT/var/tmp/sage/build/sagelib to match what other packages do.

comment:7 in reply to: ↑ 6 Changed 3 years ago by mkoeppe

Replying to leif:

??? SAGE_BUILD_DIR exists since years already... (Its default is $SAGE_ROOT/var/tmp/sage/build/.)

Yes, thanks, see my other comment.

comment:8 Changed 3 years ago by leif

Ah ok, race condition.

comment:9 Changed 3 years ago by mkoeppe

By the way, help with implementing this change would be appreciated. I haven't looked at the sagelib build system at all so far.

comment:10 Changed 3 years ago by mkoeppe

  • Branch set to u/mkoeppe/keep_src__clean_by_using___build_base_when_building_sagelib

comment:11 Changed 3 years ago by mkoeppe

  • Authors set to Matthias Koeppe
  • Commit set to e399bf41d805da7ea602daa5b554e0c7ecf2e7b5

New commits:

e399bf4First, wishful step

comment:12 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:13 Changed 3 years ago by jdemeyer

Really sagelib-$SAGE_VERSION? Do you want to fill up everybody's hard disks with Sage build directories? Not to mention that this would require to rebuild everything whenever the Sage version changes.

Last edited 3 years ago by jdemeyer (previous) (diff)

comment:14 Changed 3 years ago by jdemeyer

  • Description modified (diff)

comment:15 Changed 3 years ago by mkoeppe

Fine with me without $SAGE_VERSION; I was just following leif's suggestion in comment 3.

comment:16 follow-up: Changed 3 years ago by felixs

i understand that SAGE_BUILD_DIR is the srcdir for toplevel configure.

as long as sagelib is rooted in $(toplevel)/src, it might be less confusing to choose $SAGE_BUILD_DIR/src (not $SAGE_BUILD_DIR/sagelib) as the builddir for sagelib.

(future: replace src by sagelib, but on both ends)

i dont know exactly how the approach using setup.py will emulate VPATH builds. i think it should imitate "what automake would do", where applicable.

comment:17 in reply to: ↑ 16 Changed 3 years ago by mkoeppe

Replying to felixs:

i understand that SAGE_BUILD_DIR is the srcdir for toplevel configure.

No, it's $SAGE_ROOT/var/tmp/sage/build/

comment:18 Changed 3 years ago by felixs

ok, nevermind (i meant to write "SAGE_BUILD_DIR is the *builddir* for toplevel"). that does not seem to be the case either.

still i am wondering why "src" does not (simply) translate to "src". (sure, i am slightly autotools biased).

comment:19 Changed 3 years ago by git

  • Commit changed from e399bf41d805da7ea602daa5b554e0c7ecf2e7b5 to a73fa065f5030c3b260c04a7e36867fd7f89362f

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

f3f275ePut .cython_version next to cythonized files
94a58f1Make SAGE_BUILD_DIR variable available in sage-env, not just in sage-spkg
a73fa06Use SAGE_BUILD_DIR

comment:20 Changed 3 years ago by mkoeppe

  • Status changed from new to needs_review

Here's a first version for review. It seems to work for me.

There are still some to-do items (see comments in src/Makefile):

  • I am now using --build-base, but setup.sh also depends on SAGE_CYTHONIZED, defined in src/sage/env.py.

I think it would be better if setup.sh instead inferred that location from the build-base that was passed to it.

However, setup.sh already does a lot of stuff depending on SAGE_CYTHONIZED before distutils.core.setup is even called. Can this be fixed?

I think I could use some help from the Python experts in the cc list of this ticket on this.

  • sage/libs/pari/auto_gen.pxi and sage/ext/interpreters/__init__.py still need to be taken care of in preparation for the VPATH build.

comment:21 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:22 follow-ups: Changed 3 years ago by jdemeyer

  • Status changed from needs_review to needs_work

Thinking about it more, I disagree with building in $SAGE_BUILD_DIR/sagelib by default.

$SAGE_LOCAL (which contains $SAGE_BUILD_DIR) is meant as install directory, not as build directory.

Let's keep $SAGE_LOCAL to be exactly the install directory and nothing else (*).

I do agree with making the build directory configurable for VPATH builds. For typical packages however, if you do not do a VPATH build, the build directory is the same as the source directory. Sage should follow the same model. This means that the build directory should be $SAGE_SRC by default.

(*) One could argue that $SAGE_BUILD_DIR is currently used as build directory for packages. That is true, but they are only used temporarily, they are not meant to actually store stuff. So this isn't so bad.

comment:23 follow-ups: Changed 3 years ago by felixs

Let's keep $SAGE_LOCAL to be exactly the install directory and nothing else (*).

this is part of the problem with the current "build system". SAGE_LOCAL is *not* the install directory. it is where stuff ends up during the build process.

outside sage, an install directory is typically what you pass to --prefix, and where stuff is put into by "make install". you do that (if you are a sysadmin), after assuring that "make check" passes...

yes i know why SAGE_LOCAL exists, but it should be clear that it's not necessary and that it only has "evolved" that way. having simplified things in the past, now it is falling on your feet.

note how i tried to fix/work\ around that in my attempt to autotoolize sage (both the library and the distribution)... my point: the best approach will be to *not use SAGE_LOCAL* at all. here's the chance to cleanup sagelib, as a start.

that said: keep up the good and interesting work @mkoeppe. i hope i will have some more time later this year ...

comment:24 in reply to: ↑ 23 Changed 3 years ago by jdemeyer

Replying to felixs:

this is part of the problem with the current "build system". SAGE_LOCAL is *not* the install directory.

Why do you think that $SAGE_LOCAL is not the install directory? It is the directory where everything is installed, which by definition makes it the install directory. The fact that Sage does not (yet) support --prefix doesn't change this fact.

the best approach will be to *not use SAGE_LOCAL* at all.

I like to know why you think that.

that said: keep up the good and interesting work @mkoeppe. i hope i will have some more time later this year ...

To be clear: I didn't say that this branch needs to be thrown out. I am just saying: keep the build directory configurable but keep the default what it currently is.

comment:25 follow-up: Changed 3 years ago by felixs

Why do you think that $SAGE_LOCAL is not the install directory?

you wrote it. "--prefix" is not implemented/supported. (but it should be). there's no way to really "install" stuff in the usual sense. e.g., there is no way to *install stuff after make check has passed*. (i don't know if toplevel make check is currently implemented at all, just a thought).

where everything is installed, which by definition makes it the install directory

actually nothing gets installed. what is done is mostly overhead. working around the fact that some packages don't work right after the build alone. when i was done with the "package content lists" for spkg-install, i noticed that it was a huge waste of time... don't repeat that, better just skip the "install" step.

I like to know why you think that [SAGE_LOCAL should not be used].

every instance/use of SAGE_LOCAL breaks sagelib on (lets call it) foreign distros a bit. that's not helpful. it will as well interfere with any attempt on rewriting sage-the-distribution (be it autotools based, or pip or ebuild). the autotools approach (not a necessary step, but an example) provides a transition path to anything...

sage-the-distribution is a platform for sage (core) development. no more, no less. other platforms will come and go. what is needed is sagelib without the dependency on this (and on SAGE_LOCAL). why: because developers should be able to use sagelib and develop sage extensions on *their own platforms*, with *their own* tools and *their own* review policies.

so: please embrace contributions that reduce the use of SAGE_LOCAL.

(yes, its getting off-topic. but i hope, this answers the question.)

comment:26 in reply to: ↑ 22 Changed 3 years ago by mkoeppe

Replying to jdemeyer:

Thinking about it more, I disagree with building in $SAGE_BUILD_DIR/sagelib by default.

$SAGE_LOCAL (which contains $SAGE_BUILD_DIR) is meant as install directory, not as build directory.

Let's keep $SAGE_LOCAL to be exactly the install directory and nothing else (*).

I agree with you; see #21479.

Last edited 3 years ago by mkoeppe (previous) (diff)

comment:27 in reply to: ↑ 23 Changed 3 years ago by mkoeppe

Replying to felixs:

outside sage, an install directory is typically what you pass to --prefix, and where stuff is put into by "make install". you do that (if you are a sysadmin), after assuring that "make check" passes...

See #21479 for a discussion of --prefix and make vs. make install.

But let's keep the discussion of the present ticket focused on the task at hand.

Last edited 3 years ago by mkoeppe (previous) (diff)

comment:28 in reply to: ↑ 22 Changed 3 years ago by mkoeppe

Replying to jdemeyer:

I do agree with making the build directory configurable for VPATH builds. For typical packages however, if you do not do a VPATH build, the build directory is the same as the source directory. Sage should follow the same model. This means that the build directory should be $SAGE_SRC by default.

I agree on this as well. #21469 (VPATH for distro) will do that.

In this ticket, I first want to make the --build-base work. In particular, get rid of SAGE_CYTHONIZED.

This also works towards the eventual goal of making 'sagelib' pip-installable.

The actual location used is a detail that will be easy to change later.

(*) One could argue that $SAGE_BUILD_DIR is currently used as build directory for packages. That is true, but they are only used temporarily, they are not meant to actually store stuff. So this isn't so bad.

Yes, the current patch follows this practice. But this is temporary until #21469 is done.

comment:29 in reply to: ↑ 25 ; follow-up: Changed 3 years ago by jdemeyer

Replying to felixs:

Why do you think that $SAGE_LOCAL is not the install directory?

you wrote it. "--prefix" is not implemented/supported.

The fact that the installation process does not implement ./configure --prefix does not mean that it's not an installation process...

every instance/use of SAGE_LOCAL breaks sagelib

But why?

Of course, it's all a matter of definition. I consider the process of copying files to $SAGE_LOCAL an "installation" and you do not (for reasons which are still unclear to me). I think things will become much simpler for you if you accept the fact that $SAGE_LOCAL is the installation directory and that copying files to $SAGE_LOCAL is an installation.

but i hope, this answers the question

I absolutely does not. You are just saying "it breaks stuff" but not explaining why.

comment:30 in reply to: ↑ 29 ; follow-up: Changed 3 years ago by dimpase

Replying to jdemeyer:

Replying to felixs:

[...]

but i hope, this answers the question

I absolutely does not. You are just saying "it breaks stuff" but not explaining why.

One reason why is that in many deployment scenarios you will want to test what you have built before installing it. And Sage does not support this.

comment:31 follow-up: Changed 3 years ago by felixs

indeed. in "build"-"check"-"install" there is not much room for definitions of "build" and "install".

this is drifting towards the question of whether or not sage should stick to common practices and terminology. you know i think it should.

apologies for being off-topic again, this may be more related to #15105 -- there is no ticket for just "practices and terminology".

comment:32 in reply to: ↑ 30 ; follow-up: Changed 3 years ago by jdemeyer

Replying to dimpase:

One reason why is that in many deployment scenarios you will want to test what you have built before installing it. And Sage does not support this.

How does this relate to the existence of $SAGE_LOCAL?

comment:33 Changed 3 years ago by git

  • Commit changed from a73fa065f5030c3b260c04a7e36867fd7f89362f to a854831e3274b69eadc52eb4642b8c0bd221a391

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

a854831Put setup.sh in charge of all sagelib building

comment:34 in reply to: ↑ 31 Changed 3 years ago by jdemeyer

Replying to felixs:

this is drifting towards the question of whether or not sage should stick to common practices and terminology. you know i think it should.

If those "common" practices and terminology make sense, of course it should.

Anyway, I am completely not following what you are trying to say. I feel that you are always wandering around my questions instead of answering them.

comment:35 Changed 3 years ago by mkoeppe

I have created #21495 as a place for such discussions.

comment:36 Changed 3 years ago by mkoeppe

  • Description modified (diff)

comment:37 in reply to: ↑ 32 ; follow-up: Changed 3 years ago by dimpase

Replying to jdemeyer:

Replying to dimpase:

One reason why is that in many deployment scenarios you will want to test what you have built before installing it. And Sage does not support this.

How does this relate to the existence of $SAGE_LOCAL?

$SAGE_LOCAL is fine as long as you can also install things from there somewhere else. Currently you cannot do this in a proper way (yes, you can certainly create symbolic links etc, but this is often not enough).

comment:38 in reply to: ↑ 37 Changed 3 years ago by jdemeyer

Replying to dimpase:

$SAGE_LOCAL is fine as long as you can also install things from there somewhere else. Currently you cannot do this in a proper way

Of course you can:

$ cd $package_source
$ sage --sh
$ ./configure --prefix="$SAGE_LOCAL"
$ make install

I have done this many times as first step of testing a new package or a package upgrade.

comment:39 Changed 3 years ago by mkoeppe

If I understand Dima correctly, he wants to install "from" $SAGE_LOCAL, not "to" $SAGE_LOCAL.

But really this discussion should go to #21495. Thanks!

comment:40 Changed 3 years ago by git

  • Commit changed from a854831e3274b69eadc52eb4642b8c0bd221a391 to 1a027d5d535f4dbf7314479e8c6905ad8af34bca

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

1a027d5Have setup.sh derive SAGE_CYTHONIZED from --build-base

comment:41 Changed 3 years ago by mkoeppe

  • Status changed from needs_work to needs_review

Jeroen, how does this look to you now? (I haven't changed $SAGE_BUILD_DIR yet, but will in a moment.)

comment:42 Changed 3 years ago by git

  • Commit changed from 1a027d5d535f4dbf7314479e8c6905ad8af34bca to f6555cea1f1695c99a9011ba13bd64c6995d17fc

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

f6555ceFix last change - handle --build-base earlier

comment:43 Changed 3 years ago by git

  • Commit changed from f6555cea1f1695c99a9011ba13bd64c6995d17fc to d829eb435729cf3280a5206d005bffef8e1dfd52

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

853a1aaMake src/Makefile a generated file
1931b43Define SAGE_PKGS in sage.env, not sage.misc.package
c1dc4f8Set SAGE_CYTHONIZED earlier
d829eb4Build in $(abs_builddir)/build-sagelib. Poison directory env variables

comment:44 Changed 3 years ago by mkoeppe

  • Description modified (diff)
  • Summary changed from Keep src/ clean by using --build-base when building sagelib to Make sagelib setup.sh self-contained, independent of SAGE_ROOT, and handle --build-base

I've changed the description of this ticket, as it has changed its focus. Ready for review.

Note: See TracTickets for help on using tickets.