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

spkg-configure.m4 for most external Python pkgs #36777

Merged
merged 10 commits into from
Mar 25, 2024

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Nov 26, 2023

After #36129 and #36776 we are still left with a bunch of external (non-Sage) Python packages
which need spkg-configure.m4 and distros info.

Here we add these.

πŸ“ Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

βŒ› Dependencies

@dimpase dimpase marked this pull request as draft November 26, 2023 14:40
@orlitzky
Copy link
Contributor

I don't want to install all that crap to test but the new spkg-configure.m4all look OK to me.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

@dimpase If you are doing this exercise as an approach for using the system Jupyter notebook / JupyterLab, I'd suggest to consider a different approach. The front-end does not need to run in the same Python instance as the kernel running the Sage library.

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

Is the last comment meant to derail the effort to unvendor a bunch of packages?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

the frontend certainly does not need to run on the same Python, that is by the design of Jupyter.

I don't quite know why in the 1st place it was decided to vendor the whole Jupyter in Sage, probably as a replacement of sagenb, which actually was at some point made a separate package with a separate git repo.

So we are repeating the whole Jupyter packaging effort here 😭

@orlitzky
Copy link
Contributor

SPKGs don't come with any metadata about how they're supposed to work with python, and the sage package manager doesn't do dependency resolution, so to do it right, the people interested in not using these packages would have to maintain the list by hand (like we already do with --disable-foo in configure.ac). It's untenable, but more honestly, we just don't want to do it: it's a waste of time. The people who want to avoid the sage package manager for packages also want to avoid the sage package manager as a time sink. This is a low-effort approach that works as intended for now. If someone comes along and improves it to work without --enable-system-site-packages, great?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

That's why people interested in sage-the-distro should get a separate repo where they can have their own fun with 400+ packages with built from source compilers, jupyter, whatever.

I just want sagelib as a Python package, without any toolchain or frontend, scipy-style. Such a Python package can very well be installed in sage-the-distro. Or they can vendor it...

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

the frontend certainly does not need to run on the same Python, that is by the design of Jupyter.

Glad we can agree on this!

The next step is to understand that this means that you can treat it like system packages providing executables instead of a Python site packages. The model of tox and its unique dependencies. As explained in detail in #30124.

@orlitzky
Copy link
Contributor

The model of tox and its unique dependencies. As explained in detail in #30124.

The problem with this is that there's no way to know what dependencies are unique to tox except to muck around in git grep for half an hour -- an estimate that would be generous for the much larger set of notebook dependencies.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

The model of tox and its unique dependencies. As explained in detail in #30124.

The problem with this is that there's no way to know what dependencies are unique to tox except to muck around in git grep for half an hour -- an estimate that would be generous for the much larger set of notebook dependencies.

I have a robust solution for this in #36766

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

I just want sagelib as a Python package, without any toolchain or frontend, scipy-style.

I'm surprised about this example. How would you describe scipy's approach to vendoring?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

scipy does not vendor compilers (or jupyter).

It assumes that anyone wanting to build it from source has all the needed tools installed: python, cython, fortran, C, C++, etc...
In their CI they don't build compilers from source; on macOS they install prebuilt gfortran (something Sage can just copy).

It surely provides instructions for all this.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

Is there something else about vendoring that you may be forgetting?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

Like?

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

Libraries?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

sure they e.g. ship libgfortran in their binary wheels. So?

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

Other libraries?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

we are talking about "toolchain", not maths stuff that needs to be delivered to the end user one way or another. yes, they vendor about a dozen things.
Not hundreds, and not build tools, ffs...

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

we are talking about "toolchain",

i don't think we are.

not maths stuff that needs to be delivered to the end user one way or another. yes, they vendor about a dozen things.

They do!

And in fact they even do that in the real meaning of "vendoring", namely including upstream source code in their source code distribution.

So when you were saying ....

I just want sagelib as a Python package, without any toolchain or frontend, scipy-style

... do you mean this is what you would sagelib to look like?

@orlitzky
Copy link
Contributor

There are better examples than scipy I'm sure, but now that scipy has a meson build system the bundling will get resolved eventually: scipy/scipy#17751

For obscure math subprojects there's always a chicken and egg problem trying to convince upstream to unbundle things that no distro packages it because everyone bundles it because no distro packages it...

I have a robust solution for this in #36766

Aren't you still manually curating the jupyter package list? In any case, the question isn't whether or not it can be made robust, but whether or not it's a waste of time.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

now that scipy has a meson build system the bundling will get resolved eventually: scipy/scipy#17751

Thanks for the pointer!

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

anyhow, they don't vendor python, openblas, numpy.
They vendor few obscure or semi-obscure things, such as old fortran code for solving DEs and numerical integration, qhull, ARPACK, PROPACK.

They have few header-only C++ libs as git submodules (boost/math), an LP solver Higs.

They don't have 100 packages per release to update.

Our technology for not vendoring is actually better, we can e.g. skip boost.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

Our technology for not vendoring is actually better, we can e.g. skip boost.

The Sage library does not vendor anything at all.

Edit: @dimpase replied by editing: I count shipping a tarfile along, and installing it as vendoring. It's merely a different wrapping of the same thing, we could have just as well checked that code into our git tree.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

So, Dima, once again: when you were saying ....

I just want sagelib as a Python package, without any toolchain or frontend, scipy-style

What is it that you mean?

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

I use scipy as an example as I know it a bit. I got my hands dirty fixing few things for them (a side effect is that I ended up as an official contributor, in a paper, and Scopus counts about 15000 citations to this paper. Beancounters are happy :-))

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

It's merely a different wrapping of the same thing, we could have just as well checked that code into our git tree.

now that's news to me ;)

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

How come? What's the difference between having the package X untarred in advance, or untarred on the fly, if your building process builds/installs X?
No difference.

@dimpase
Copy link
Member Author

dimpase commented Nov 29, 2023

Matthias, years before you started actively contributing to Sage, we referred to creating spkg-configure.m4 file for an spkg X as unvendoring of X.

@mkoeppe
Copy link
Member

mkoeppe commented Nov 29, 2023

Not that this matters, but no, Dima, the historical record does not agree with this: https://github.com/sagemath/sage/issues?q=unvendor

@mkoeppe
Copy link
Member

mkoeppe commented Dec 11, 2023

No, that's a false claim.

That's perhaps a bit harsh for this discussion?

@mkoeppe
Copy link
Member

mkoeppe commented Dec 11, 2023

When a project is making changes, it is important to take the developer community with you. One such route from monolithic Sage to multirepo Sage (if the community decides to do this) would go like this:

  1. monolithic Sagelib in src/
  2. pkgs/ subdirectories with symlinks into monolithic src/
  3. pkgs/ subdirectories where source code has been moved
  4. separate repositories

I have been working since 2020 on step 1 in #35095. This is where the real work of modularization is happening; and there's still nontrivial work to be done; and during this time, I do not have to bother other developers with the added complexity of changing source code locations. The other steps are trivial.

@dimpase
Copy link
Member Author

dimpase commented Dec 11, 2023

This is largely orthogonal to the need to spin off Sage the distro into a number of separate repos, one or more.

@mkoeppe
Copy link
Member

mkoeppe commented Dec 11, 2023

Sage the distro does not even consist of much code at all; but it provides the package metadata (versions in install-requires) that are needed for bootstrapping the pkgs/ subdirectories.

@dimpase
Copy link
Member Author

dimpase commented Dec 11, 2023

If you count the code which ends up installed by the spkg-install and similar scripts, it is a lot of code (e.g. gcc/gfortran are a lot of code)

@mkoeppe
Copy link
Member

mkoeppe commented Dec 11, 2023

Would build/pkgs still bother you if everything except for the patches was just one big yaml file?

@dimpase
Copy link
Member Author

dimpase commented Dec 11, 2023

do you want to replace the tarballs in upstream/ with one big yaml ? These tarballs are the code we vendor (and in the worst case it's gigabytes, and hundreds of files). Even if I squint very hard, this code is still there, as a part of sage the distro.

@dimpase dimpase added the disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ label Dec 22, 2023
@mkoeppe
Copy link
Member

mkoeppe commented Dec 23, 2023

OK, those headers themselves, definitely not on right now. I thought we were just talking about headers interfacing with...

there is an issue on gmpy2 github where the author says (said today) that they're going to package headers.

Update: they are not going to be in 2.2.0a2 - aleaxit/gmpy#462 (comment)

but there is an interesting development regarding an openblas wheel - aleaxit/gmpy#462 (comment)

@dimpase
Copy link
Member Author

dimpase commented Dec 23, 2023

incidentally we can also reuse the related

A project using the tarball, for Manylinux or macOS, will need the gfortran-install submodule used here, from https://github.com/MacPython/gfortran-install

to get rid of gcc/gfortran

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 13, 2024
…sions of the Sage distribution

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Discussions of the complexity of the Sage distribution pop up
unexpectedly, as seen in

sagemath#36982 (comment),
sagemath#36982 (comment),
sagemath#36982 (comment),
sagemath#36982 (comment),
sagemath#36982 (comment),
sagemath#36982 (comment),
sagemath#36982 (comment)

sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment),
sagemath#36726 (comment)

sagemath#36777 (comment),
sagemath#36777 (comment),
sagemath#36777 (comment),
sagemath#36777 (comment),
sagemath#36777 (comment),
sagemath#36777 (comment)

To help put such discussions on a solid factual basis, we introduce the
command `sage --package metrics`.

```
$ ./sage -package metrics :standard:
has_file_distros_arch_txt=131
has_file_distros_conda_txt=216
has_file_distros_debian_txt=125
has_file_distros_fedora_txt=138
has_file_distros_gentoo_txt=181
has_file_distros_homebrew_txt=61
has_file_distros_macports_txt=129
has_file_distros_nix_txt=51
has_file_distros_opensuse_txt=146
has_file_distros_slackware_txt=25
has_file_distros_void_txt=184
has_file_patches=35
has_file_spkg_check=59
has_file_spkg_configure_m4=222
has_file_spkg_install=198
has_tarball_upstream_url=231
line_count_file_patches=22561
line_count_file_spkg_check=402
line_count_file_spkg_configure_m4=2792
line_count_file_spkg_install=2960
packages=272
type_standard=272
```

Use `PATH=build/bin:$PATH SAGE_ROOT=some-other-worktree build/bin/sage-
package metrics :standard:` to obtain the metrics of another version of
Sage in some other worktree.

We add computation and before/after comparison of the metrics to the CI
Linux Incremental workflow.
As an illustration, we change one Python package from "normal" to
"wheel", removing an `spkg-install.in` file in the process. See https://
github.com/sagemath/sage/actions/runs/7342841283/job/19992606617?pr=3697
7#step:6:12

More metrics can be added after
- sagemath#36740

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### πŸ“ Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

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

### βŒ› Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36977
Reported by: Matthias KΓΆppe
Reviewer(s): Kwankyu Lee, Matthias KΓΆppe
@dimpase dimpase marked this pull request as ready for review February 22, 2024 16:21
@dimpase dimpase added s: needs review and removed s: needs info disputed PR is waiting for community vote, see https://groups.google.com/g/sage-devel/c/IgBYUJl33SQ labels Feb 28, 2024
Copy link

github-actions bot commented Mar 1, 2024

Documentation preview for this PR (built with commit 016fc0e; changes) is ready! πŸŽ‰

@saraedum saraedum mentioned this pull request Mar 21, 2024
5 tasks
@vbraun vbraun merged commit 80a2744 into sagemath:develop Mar 25, 2024
14 of 33 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants