Skip to content

Conversation

@orlitzky
Copy link
Contributor

@orlitzky orlitzky commented Oct 8, 2025

A third attempt at supporting mpmath 1.4.x. Previous PRs:

mpmath 1.4.x is still in alpha, so we can't require it yet, but we can try to support it. This isn't too difficult given that mpmath.__version__ is available to python, but there are some major cython changes that are better hidden behind a conditional compile.

The new PR makes things compatible where possible, copy/pastes an entire function in one case, and even uses a separate file utils13.pyx in another. A new feature is added to hide the 1.3.x doctests on 1.4.

@kiwifb
Copy link
Member

kiwifb commented Oct 28, 2025

I will give that branch a spin with a sage-on-gentoo ebuild later today.

@kiwifb
Copy link
Member

kiwifb commented Oct 29, 2025

Needs rebasing.

Tweak some expected output to work with both versions of mpmath.
Certain types that used to be implemented in sage are now a part
of mpmath itself, so the class names have changed. Fortunately
it looks like we can match both with enough "..."
This file needs an update to support mpmath-1.4.x, and the changes
can't easily be conditionalized (cimports are involved). Instead
we make a copy, with the intention of using meson to conditionally
compile one or the other based on the value of mpmath.__version__
at build-time.
To support both versions of mpmath, we create an internal copy of the
existing py_scalar_parent() function, and update the original to
support mpmath-1.4.x. If mpmath.__version__ indicates that v1.3 is in
use, we punt to the old copy of the function.

The copy/paste is ugly, but considering that it's only temporary,
emphasis is placed on how easy it will be to undo eventually.
mpmath v1.3 and v1.4 build very differently. Rather than try to
support both simultaneously with the same set of files, we
conditionalize the build to check mpmath.__version__ via python,
and respond accordingly.
To support mpmath v1.3 and v1.4 simultaneously, we have some sage
library files that are only used mpmath-1.3.x is installed. The
tests in these files will fail with mpmath-1.4, however, so we
add a new feature to detect mpmath-1.3.x.
Most of these files are only used (and can only be tested) under
mpmath-1.3.x. We now have a "feature" for that version, and just
need to add the appropriate file-level tags.
Now that we have a feature for "mpmath13", the doctests for the
mpmath-1.3.x copy of py_scalar_parent() are put back in place.
It isn't smart enough to handle an if/else statement that doesn't
apply.
@orlitzky
Copy link
Contributor Author

orlitzky commented Nov 2, 2025

I force-pushed an update, sorry for the delay, it's been chaos.

The first few CI failures are because mpmath isn't being installed before sage, but I don't see any obvious reason for that because it was always a dependency.

@kiwifb
Copy link
Member

kiwifb commented Nov 2, 2025

I'll try to give it a spin again in the next 12hours.

@kiwifb
Copy link
Member

kiwifb commented Nov 3, 2025

Build and install in sage-on-gentoo.

@orlitzky
Copy link
Contributor Author

orlitzky commented Nov 3, 2025

Build and install in sage-on-gentoo.

That's the easy part :)

I was hoping to use the CI to test it with mpmath-1.3, but it's failing for reasons I don't understand. I doubt I'll get time, but I may just resurrect the last mpmath-1.3 ebuild and see what happens. Though we would need to fix the CI before merging anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants