Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downgrade giac to optional #38712

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

downgrade giac to optional #38712

wants to merge 9 commits into from

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Sep 25, 2024

This will resolve #38668

It's actually almost done, we just need to change the package type, and make sure that an external
giac does not get picked up by feature if --disable-giac is in effect.

For the latter, we substitute the value of an automatically generated variable
SAGE_ENABLE_giac into a variable in sage.env, and use it in sage.feature.giac
to poison the executable name if giac is disabled.
(maybe there is a better than poisoning way)

Testing:

./bootstrap
make giac-clean giac-uninstall
./configure --disable-giac
# ... run tests ...
./configure --enable-giac
# ... run tests ...

📝 Checklist

  • [ x] The title is concise and informative.
  • [ x] The description explains in detail what this PR is about.
  • [x ] I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

orlitzky and others added 5 commits September 24, 2024 22:42
In preparation for adding a --disable-giac option, we add a new
feature that detects the presence of the "giac" executable. We already
have a feature for sage.libs.giac, but that only guards the libgiac
interface; we still have code that runs "giac" behind pexpect. This
will allow us to skip those tests when giac is not installed.
Various implementations get it a little (1e-10) different.
…wers

We have an integration test in this file that is looking for the giac
result, but sympy gives an equivalent one. We should accept that, too.
There's one piecewise test that uses algorithm='giac', but it will
soon be possible to install sage without giac. We could make the test
conditional on giac's presence, but the same thing works with sympy,
so let's just use that.
@dimpase
Copy link
Member Author

dimpase commented Sep 25, 2024

The dependencies are rebased over the latest beta5

Copy link

github-actions bot commented Sep 25, 2024

Documentation preview for this PR (built with commit a451352; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dimpase
Copy link
Member Author

dimpase commented Sep 25, 2024

This works if giac needs to be built. But if a system-wide giac is detected and approved for use, then feature giac is detected, and doctests are run, even though we don't want it in case we configure with --disable-giac

So --disable-giac should include stopping feature giac from being detected. Currently it's not the case.

EDIT - fixed by d47e633

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

I tried testing locally, this "Build & Test / test-new (pull_request)" seems to be failing due to a shortcut taken by this CI step.
All works for me locally.

@antonio-rojas
Copy link
Contributor

Is this supposed to make it optional only at runtime? Because it still fails to build if giac is not present.

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

to build, you need to configure with --enable-giac (as it's the case for any optional package)
Have you tried this?

@antonio-rojas
Copy link
Contributor

I'm building sagelib (aka sagemath-standard), not sage-the-distro. And if giac is not installed, build fails with

build/cythonized/sage/libs/giac/giac.cpp:1286:10: fatal error: giac/giac.h: No such file or directory

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

I've added explicit testing instructions in the description

@mkoeppe
Copy link

mkoeppe commented Sep 26, 2024

Of course the extension modules can no longer be built and shipped by sagemath-standard when the package is made optional. They need to go into a new distribution, along the lines of sagemath-bliss etc. (and sagemath-brial as done in #36380.

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

I'm building sagelib (aka sagemath-standard), not sage-the-distro. And if giac is not installed, build fails with

build/cythonized/sage/libs/giac/giac.cpp:1286:10: fatal error: giac/giac.h: No such file or directory

Why would you expect sagelib to be able to build giac? Building giac is something entirely different.

As we don't have a standard, documented, procedure for building a standalone sagelib,
I really don't see what you're doing. If your undocumented way to build sagelib is not working, it doesn't mean that this ticket is not doing what's advertised to do - downgrade giac to optional within the only documented way to build Sage.

We really should get on with getting a common way to build sagelib standalone, in particular as it's basically done in #36524, so we should get on with getting #36524 fixed and merged, document it, etc. @tobiasdiez

@kiwifb
Copy link
Member

kiwifb commented Sep 26, 2024

@dimpase me and a lot of other distro have managed to build sage as modular parts and in fact it is the only proper way to do it anymore as a distro in my opinion.

sage upstream (aka you) should get on and eat your own food properly. One thing modular sage has done for us that is extremely positive is split those optional packages that had a terrible build system involving detection in sagelib at build time. Now we can build them independently and that's a good thing(TM).

And if you are going to make giac optional, I am expecting you to go all the way and create a sagemath-giac package. Anything else is half backed and will be disputed by me.

@mkoeppe
Copy link

mkoeppe commented Sep 26, 2024

We really should get on with getting a common way to build sagelib standalone

@dimpase What are you talking about. The sagemath-standard distribution on PyPI exists for this very purpose.

@mkoeppe
Copy link

mkoeppe commented Sep 26, 2024

@kiwifb Note that the sagemath-giac package is defined already in #35095, and I can split it out from there after #36380 is merged.

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

We really should get on with getting a common way to build sagelib standalone

What are you talking about. The sagemath-standard distribution on PyPI exists for this very purpose.

There is no documentation on how sagemath-standard is built. There is some talk about sagemath-standard in src/doc/en/developer/packaging_sage_library.rst, but it leaves one in the dark on how one can build it in a stand-alone mode.

One can put as much sagemath-* stuff on PyPI as one pleases, but it's not replacing documentation.

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

@dimpase me and a lot of other distro have managed to build sage as modular parts and in fact it is the only proper way to do it anymore as a distro in my opinion.

I fully agree with you here.

sage upstream (aka you) should get on and eat your own food properly.

We have a problem defining the diet, as you know.
You somehow on one hand want "to build sage as modular parts" (and I want this too), and on the other hand don't want
to facilitate this here, instead pulling Sage towards even tighter integration of sagelib into sage the distro.

One thing modular sage has done for us that is extremely positive is split those optional packages that had a terrible build system involving detection in sagelib at build time. Now we can build them independently and that's a good thing(TM).

And if you are going to make giac optional, I am expecting you to go all the way and create a sagemath-giac package. Anything else is half backed and will be disputed by me.

giac is much more half-baked, as you perfectly know. I don't want to spend my time writing endless undocumented configs for something that's broken beyond repair.

If you want a sagemath-giac package so badly, you can work on it in a follow-up PR, but downgrading a package to optional should not take more time and effort than is already taken. It used to be easy, and it should stay so.

@dimpase
Copy link
Member Author

dimpase commented Sep 26, 2024

@kiwifb Note that the sagemath-giac package is defined already in #35095, and I can split it out from there after #36380 is merged.

Why is splitting sagemath-giac package from the 4K-commits long patchbomb #35095 touching almost 4K files requires merging a seemingly unrelated #36380 ?

@mkoeppe
Copy link

mkoeppe commented Sep 27, 2024

pulling Sage towards even tighter integration of sagelib into sage the distro.

I see this repeated many times, but it has absolutely nothing to do with anything that has been happening in the past 5 years.

@mkoeppe
Copy link

mkoeppe commented Sep 27, 2024

Why is splitting sagemath-giac package [...] requires merging a seemingly unrelated #36380 ?

It does not "require" it. I was describing what I intend to do.

@mkoeppe
Copy link

mkoeppe commented Sep 27, 2024

downgrading a package to optional should not take more time and effort than is already taken.

No, you are mistaken. The changes that you have here on this branch would not at any point in the past 10 years have sufficed to take care of extension modules that depend on an optional library, such as those in src/sage/libs/giac.

The mechanism that one would have used for this task 5 years ago (declaring OptionalExtensions) no longer exists.

We have eliminated it in favor of separately buildable distributions, to align with modern Python packaging practices and to enable proper downstream packaging (as done by @kiwifb for Gentoo). The last bit of this work, #37857, was merged in Sage 10.4.

@antonio-rojas
Copy link
Contributor

I'm building sagelib (aka sagemath-standard), not sage-the-distro. And if giac is not installed, build fails with

build/cythonized/sage/libs/giac/giac.cpp:1286:10: fatal error: giac/giac.h: No such file or directory

Why would you expect sagelib to be able to build giac? Building giac is something entirely different.

I never said I expect such a thing. I do expect that "making giac optional" means one can build sagelib without giac, though.

@dimpase
Copy link
Member Author

dimpase commented Sep 27, 2024

We don't have a defined, documented concept of "building sagelib". I am told it's "sagemath-standard" that needs to be built. But the only thing I know about it, that it magically appears every time I run "make build". There is no documentation on how it can be built without make.

@mkoeppe
Copy link

mkoeppe commented Sep 27, 2024

"Undocumented" means that documentation is not written.
There are other words for not reading the documentation.

@dimpase
Copy link
Member Author

dimpase commented Sep 28, 2024

"Undocumented" means that documentation is not written.
There are other words for not reading the documentation.

Please point out at the place where creating packages such as sagemath-brial is documented in sufficient detail (or even is some detail). There is no such place. Or point me to this place, because I cannot find it.

@dimpase dimpase added s: needs review disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ and removed s: needs work labels Sep 28, 2024
@tobiasdiez
Copy link
Contributor

tobiasdiez commented Sep 28, 2024

@dimpase You probably want to manually add the files that need giac (like giac.pyx) to

files_to_exclude = filter_cython_sources(SAGE_SRC, distributions_to_exclude)
when it's not available. Otherwise pip install will try to compile them, which fails with the error mentioned in #38712 (comment). This will indeed become way easier and, in fact, automatic with the Meson build system which is able to track such dependencies.

@dimpase
Copy link
Member Author

dimpase commented Sep 28, 2024

@kiwifb Note that the sagemath-giac package is defined already in #35095, and I can split it out from there after #36380 is merged.

Why can't you split it out before unrelated to it #36380 is merged?

If you do it, add it here (the PRs on https://github.com/dimpase/sage are open), we'll get this PR done and dusted, instead of starting yet another fight. Or do it in a follow-up PR, if you prefer, do not block this one.

@dimpase
Copy link
Member Author

dimpase commented Sep 28, 2024

@dimpase You probably want to manually add the files that need giac (like giac.pyx) to

files_to_exclude = filter_cython_sources(SAGE_SRC, distributions_to_exclude)

when it's not available. Otherwise pip install will try to compile them, which fails with the error mentioned in #38712 (comment). This will indeed become way easier and, in fact, automatic with the Meson build system which is able to track such dependencies.

Thanks for the pointer! I see in that file

optional_packages = ['mcqd', 'bliss', 'tdlib',
                         'coxeter3', 'sirocco', 'meataxe']

which appears to be a semi-random list of optional packages - or are these "distributions" ?

Yes, indeed, these are used to form sagemath- names, of things in pkgs/:

$ ls pkgs/
README.rst       sage-conf_pypi  sagemath-brial       sagemath-environment  sagemath-objects  sagemath-standard  sage-sws2rst
sage-conf        sage-docbuild   sagemath-categories  sagemath-mcqd         sagemath-repl     sagemath-tdlib
sage-conf_conda  sagemath-bliss  sagemath-coxeter3    sagemath-meataxe      sagemath-sirocco  sage-setup


By the way, why isn't pkgs/ split into pkgs/standard/ and pkgs/optional/ ? For more confusion, and maintaining lists by hand?

@mkoeppe
Copy link

mkoeppe commented Sep 28, 2024

Why can't you split it out before unrelated to it #36380 is merged?

It's not "unrelated". The giac bindings likely also need the enlarged sagemath-categories done in #36380.

@mkoeppe
Copy link

mkoeppe commented Sep 28, 2024

Why isn't pkgs/ split into pkgs/standard/ and pkgs/optional/ ?

Because that would be less convenient.

@mkoeppe
Copy link

mkoeppe commented Sep 28, 2024

list of optional packages - or are these "distributions" ?

"distribution" is the same as "distribution package" is the same as "pip-installable package".

@tobiasdiez
Copy link
Contributor

@dimpase You probably want to manually add the files that need giac (like giac.pyx) to

files_to_exclude = filter_cython_sources(SAGE_SRC, distributions_to_exclude)

when it's not available. Otherwise pip install will try to compile them, which fails with the error mentioned in #38712 (comment). This will indeed become way easier and, in fact, automatic with the Meson build system which is able to track such dependencies.

Thanks for the pointer! I see in that file

optional_packages = ['mcqd', 'bliss', 'tdlib',
                         'coxeter3', 'sirocco', 'meataxe']

which appears to be a semi-random list of optional packages - or are these "distributions" ?

Yes, indeed, these are used to form sagemath- names, of things in pkgs/:

They are indeed intended to be used in conjunction with sagemath-xyz distributions. But in this context, they essentially match whatever files have the magic distribution-comment at the beginning. So if you want to exclude certain "giac" files, just add giac to the optional_packages array and add # sage_setup: distribution = sagemath-giac at the beginning of the files in src/sage/libs/giac. No need to create a whole distribution package (which apparently is hard problem).

@dimpase
Copy link
Member Author

dimpase commented Sep 29, 2024

Why isn't pkgs/ split into pkgs/standard/ and pkgs/optional/ ?

Because that would be less convenient.

I don't see how maintaining explicit lists of optional things, while mixing up non-optional and optional things in the same directory is more convenient than putting optional things in optional/
Using optional/ is certainly less work and easier to maintain, once the framework to use such things is available. Because it means less places to touch, no need to worry about a list somewhere else.

@orlitzky
Copy link
Contributor

orlitzky commented Oct 2, 2024

It may be easier to do this in a few steps to ensure that no one objects to them. A few related PRs were merged into develop recently, and #38686 should go in next time. After that, I think the uncontroversial thing to do would be to add only the # needs giac tags. That changes nothing so long as giac is still standard so is less likely to draw objections. Afterwards it will be easier to focus on whatever we need to do w.r.t. sagemath-giac.

@dimpase
Copy link
Member Author

dimpase commented Oct 2, 2024

@orlitzky - I am not sure what you are proposing to be split here. I think the modifications in this branch are needed regardless.

@orlitzky
Copy link
Contributor

orlitzky commented Oct 2, 2024

@orlitzky - I am not sure what you are proposing to be split here. I think the modifications in this branch are needed regardless.

Not split per se, but I think you are getting a lot of negative comments because this branch would break some things without the prerequisite # needs tags and some way to separate the building of sage.libs.giac. If we are able to get those prerequisites merged first then the subsequent discussion will be much more focused.

@dimpase
Copy link
Member Author

dimpase commented Oct 2, 2024

I think I've already put in the equivalents of #needs tags in. There is a per file analog of these (# sage.doctest: optional - giac), so that one doesn't need per doctest tags in src/sage/interfaces/giac*.

Perhaps this tag is not needed in src/sage/features/giac*, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: packages: optional disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ s: needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for --disable-giac
6 participants