Patching Sage's Python's packages

46 views
Skip to first unread message

Gareth Ma

unread,
Jan 31, 2025, 6:09:14 PMJan 31
to sage-...@googlegroups.com
Not sure how to title the subject because I am not familiar with Sage's build
system at all, but hope the body explains what it means.

===========

Usually, I build Sage with `./bootstrap && ./configure && make build`, but I
believe the same problem below happens for conda install as well (the setuptools
part should be the same.) In the build log / output, there's occasionally these
lines:

[*] building 'sage.schemes.hyperelliptic_curves.hypellfrob' extension
... (The $CC ... commands)
[*] building 'sage.rings.polynomial.polynomial_modn_dense_ntl' extension
[*] building 'sage.schemes.elliptic_curves.descent_two_isogeny' extension
[*] building 'sage.schemes.elliptic_curves.mod_sym_num' extension
[*] building 'sage.schemes.hyperelliptic_curves.hypellfrob' extension
[*] building 'sage.schemes.elliptic_curves.period_lattice_region' extension
[*] building 'sage.schemes.toric.divisor_class' extension
[*] building 'sage.rings.polynomial.polynomial_modn_dense_ntl' extension

([*] is [spkg-install]) But the issue for the user / developer is that this
doesn't show what is the progress of the build, i.e. how many extensions has
been built and how many are there left. Another annoyance would be lines such as

dependency <path> won't ... included in the manifest: the path must be relative

These are annoying mainly because running `make build` from an already built
directory still prints 9054 of these, so it would be nice to mute them, or at
least have the option to mute them.

I think I can set the logging level to be > INFO (how do I do that? Is there an
environment variable? I can't find it in the Sage docs,) but then I also lose
other logging.info informations.

============

I traced down where these are printed. In two places:

https://github.com/pypa/setuptools/blob/main/setuptools/command/build_ext.py#L289-L294
https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/command/build_ext.py#L530-L535

So (from what I know) there are two options if we want to mute these lines:

- I submit a PR to setuptools directly
-> but I doubt they would think the above reasoning is sufficient for a change
- Alternatively, I believe that Sage builds a Python from source currently, or
at least that's what I believe, since I see a path
`/home/grhkm/git/sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/setuptools/...`
which contains the setuptools package used for building. Is it possible to apply
a patch to the setuptools, similar to other .patch files I see in `build/...`?
If so, where should I put the patch file?

Even if this is a bad idea, I hope someone can answer the "where should I put
the patch file" question, I think it will help me understand the Sage build
system a lot better.

Thanks in advance!

Gareth

Dima Pasechnik

unread,
Jan 31, 2025, 7:20:14 PMJan 31
to sage-...@googlegroups.com
normally speaking, Sage uses python3 it finds (assuming it's not to old etc)
And we regularly get reports from users who unwittingly trigger Sage's
build of python3,
and it breaks.
(I advocate for removing the ability to build python3 from sage, but
well, we don't have a consensus
on this it seems)

> `/home/grhkm/git/sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/setuptools/...`
> which contains the setuptools package used for building. Is it possible to apply
> a patch to the setuptools, similar to other .patch files I see in `build/...`?
> If so, where should I put the patch file?
>
> Even if this is a bad idea, I hope someone can answer the "where should I put
> the patch file" question, I think it will help me understand the Sage build
> system a lot better.
>
> Thanks in advance!
>
> Gareth
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-devel/ab451ac4-8b12-4ea0-9211-e85f5ee31a9c%40gmail.com.

John H Palmieri

unread,
Jan 31, 2025, 7:20:51 PMJan 31
to sage-devel
Does it help if you run "make V=0 build"? "V=0" sets the verbosity level to zero, and when I use that, I don't see any such message printed to the screen. They're still written to the log files, and I think that's good: the default should be to write with full verbosity to the log files.

John H Palmieri

unread,
Jan 31, 2025, 7:26:09 PMJan 31
to sage-devel
Also, you can tell whether Sage built Python by looking (a) at the output to the initial ./configure command, and (b) see if there is a python3-3.12.log file (or some file name like that) in logs/pkgs/. Similar for setuptools. I think the default is for Sage to build its own setuptools, even if it finds a suitable system version of Python, but I'm not sure. You could see if Sage built its own setuptools for you and then you could patch setuptools, although I am not sure it's a good idea.  ;)
Reply all
Reply to author
Forward
0 new messages