8000 Unvendor `libmpdec` sources · Issue #115119 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Unvendor libmpdec sources #115119

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

Open
11 of 15 tasks
zware opened this issue Feb 7, 2024 · 56 comments
Open
11 of 15 tasks

Unvendor libmpdec sources #115119

zware opened this issue Feb 7, 2024 · 56 comments
Assignees
Labels
build The build process and cross-build extension-modules C modules in the Modules dir

Comments

@zware
Copy link
Member
zware commented Feb 7, 2024

To facilitate cleaner updates of the externally-maintained libmpdec required by the _decimal module, we should migrate away from the bundled copy in Modules/_decimal/libmpdec and towards an "external" in cpython-source-deps for Windows and --with-system-libmpdec by default elsewhere.

My tentative plan is as follows:

Linked PRs

@zware zware added the build The build process and cross-build label Feb 7, 2024
@zware zware self-assigned this Feb 7, 2024
@erlend-aasland erlend-aasland added the extension-modules C modules in the Modules dir label Feb 7, 2024
@erlend-aasland
Copy link
Contributor

[...] with a fallback to the bundled copy (maybe with a warning?)

+1 for an autoconf warning.

@ned-deily
Copy link
Member

Adding an external libmpdec to the macOS installer build shouldn't be a big issue. Assign it to me if you proceed with this.

@erlend-aasland
Copy link
Contributor

FTR: the source deps repo is now updated.

@erlend-aasland
Copy link
Contributor

@ned-deily: for build-installer.py, is there more to do than adding a configuration for mpdecimal? I've used the following configure options: ['--disable-cxx', 'MACHINE=universal']

@ned-deily
8000 Copy link
Member

Likely yes, I'll take care of it. Thanks.

@ned-deily
Copy link
Member

I took a quick look at this and be aware that this change proposal will likely impact everyone building Python 3.13 on macOS. macOS does not ship a copy of libmpdec so, if the bundled version is removed, anyone building Python on macOS will now need to provide a local copy, either building from source or using a version from one of the widely-used third-party package managers, like Homebrew or MacPorts. Both currently have mpdecimal packages at the 4.0.0 level. (Recall that, unlike Windows builds, we do not currently provide non-vendored third-party library binaries for macOS users, other than those built for and linked into the Pythons provided by python.org installers for macOS.) In a quick test, it appeared that with ./configure --with-system-libmpdec today, pkg-config info for libmpdec was not being used. If so, that should be corrected. And, in any case, the devguide instructions for installing dependencies will need to be updated to cover libmpdec. We should add all this and get this working before moving on to changing the installer.

@erlend-aasland
Copy link
Contributor

In a quick test, it appeared that with ./configure --with-system-libmpdec today, pkg-config info for libmpdec was not being used. If so, that should be corrected.

Last time I checked, libmpdec did not provide pkgconfig files:

$ ls $(brew --prefix libmpdec)/lib/pkgconfig
ls: /opt/homebrew/opt/mpdecimal/lib/pkgconfig: No such file or directory
$ cd mpdecimal-2.5.1; find . | grep pkg
$

@ned-deily
Copy link
Member
ned-deily commented Feb 13, 2024

With the current 4.0.0 version, it appears both Homebrew and MacPorts ship them:

$ pkg-config libmpdec --cflags
-I/opt/homebrew/Cellar/mpdecimal/4.0.0/include
$ pkg-config libmpdec --libs
-L/opt/homebrew/Cellar/mpdecimal/4.0.0/lib -lmpdec -lm

...

$ pkg-config libmpdec --libs
-L/opt/macports/lib -lmpdec -lm

@erlend-aasland
Copy link
Contributor

Yes, the 4.0.0 version does indeed provide pkg-config configuration files. I'll work on an Autoconf patch.

erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Feb 13, 2024
Only libmpdec 4.0.0 supports pkg-config.
zware added a commit that referenced this issue Mar 18, 2024
This includes adding what should be a relatively temporary
`Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h`
or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
vstinner pushed a commit to vstinner/cpython that referenced this issue Mar 20, 2024
…-115182)

This includes adding what should be a relatively temporary
`Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h`
or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…-115182)

This includes adding what should be a relatively temporary
`Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h`
or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…-115182)

This includes adding what should be a relatively temporary
`Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h`
or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
erlend-aasland added a commit that referenced this issue Apr 29, 2024
pkg-config is supported for libmpdec 4.0.0 and newer.
@erlend-aasland
Copy link
Contributor

@zware are we still aiming for 3.13 for the first batch of items?

@erlend-aasland
Copy link
Contributor

In a quick test, it appeared that with ./configure --with-system-libmpdec today, pkg-config info for libmpdec was not being used. If so, that should be corrected.

Resolved by:

@vfazio
Copy link
Contributor
vfazio commented Jan 21, 2025

I missed the decimal -> _decimal or _pydecimal so thanks for pointing that out. I'll have to update my build scripts so i don't suffer the performance penalty

@skirpichev
Copy link
Member

I don't think you can do here something. Once the CPython will not bundle libmpdec - we will have no choice but fallback to the _pydecimal if --with-system-libmpdec=no.

Someone must do real job and package back the libmpdec for Debian.

@vfazio
Copy link
Contributor
vfazio commented Jan 21, 2025

Hmm..

I'll have to look into it more. I'll was expecting to have to --with-system-libmpdec=yes and specify LIBMPDEC_CFLAGS and LIBMPDEC_LIBS to work around the calls to pkg-config. Worst case I compile and deploy the files to a custom directory and set PKG_CONFIG_LIBDIR and let the build system figure it out without the overrides.

Obviously this is not ideal, but until us Debian users get some traction on that issue, that's probably the best I can hope for.

When I get some spare time I'll test out a build with the vendored code nuked and see if the overrides work like I expect.

@skirpichev
Copy link
Member

I'll was expecting to have to --with-system-libmpdec=yes and specify LIBMPDEC_CFLAGS and LIBMPDEC_LIBS to work around the calls to pkg-config.

Ah, yes - that will work.

@tanzim
Copy link
tanzim commented Jan 31, 2025

What would be the guidance for folks building embedded distributions this case? Use relevant CFLAGS to relatively link to a copy of libmpdec shipped with the embedded distribution?

@erlend-aasland
Copy link
Contributor

Is the plan to still unvendor this if Debian doesn't reinstate the package?

Ondřej Surý has stepped up to reinstate and maintain mpdecimal in Debian:

https://salsa.debian.org/debian/mpdecimal

@vfazio
Copy link
Contributor
vfazio commented Feb 10, 2025

Is the plan to still unvendor this if Debian doesn't reinstate the package?

Ondřej Surý has stepped up to reinstate and maintain mpdecimal in Debian:

https://salsa.debian.org/debian/mpdecimal

That's great! Thanks for the update.

@skirpichev
Copy link
Member

@zware, it seems we are out of scheduled process in the 3.14 - as fallback to the bundled copy is still here. Shall we remove that in beta? Or we can skip this and just remove the mpdecimal copy in 3.15, together with the configure.ac fallback?

BTW, it seems the mpdecimal is in the Debian again. Probably there are no good reasons to not follow to schedule in 3.15. CC @erlend-aasland

@erlend-aasland
Copy link
Contributor

@tanzim:

What would be the guidance for folks building embedded distributions this case? Use relevant CFLAGS to relatively link to a copy of libmpdec shipped with the embedded distribution?

Yes, as you would do with any of the other third party dependencies.

@skirpichev:

My gut reaction would be to simply postpone everything with one release. That is, do in 3.15 what was planned for 3.14.

@skirpichev
Copy link
Member

CC @hugovk, is this too late for 3.14 to remove fallback to bundled copy? This wasn't announced in 3.13, but removal of bundled copy in 3.15 - was. Sorry for asking, just to be sure.

Will you also suggest to shift planned stuff by one release?

@hugovk
Copy link
Member
hugovk commented May 14, 2025

I've not read through the ~90 comments here, but seems this is not a bugfix and there's no pressing need for this in 3.14, so I suggest we do as @erlend-aasland said:

My gut reaction would be to simply postpone everything with one release. That is, do in 3.15 what was planned for 3.14.

Devguide reminder:

After a first beta release is published, no new features are accepted. Only bug fixes and improvements to documentation and tests can now be committed. This is when core developers should concentrate on the task of fixing regressions and other new issues filed by users who have downloaded the alpha and beta releases.

@skirpichev
Copy link
Member

I've not read through the ~90 comments here

The evil plan is right in the description.

seems this is not a bugfix

I'm in doubts, but rather "yes".

and there's no pressing need for this in 3.14, so I suggest we do as @erlend-aasland said

Ok, then I'll prepare a documentation patch for 3.13/14 and remove fallback in 3.15.

@AA-Turner
Copy link
Member

@skirpichev I'm a little confused, we shouldn't change anything in 3.14 at this point, but the 3.15 development cycle is open. Do you intend to change anything in Python 3.15 relating to the vendored libmpdec?

I've no objections to delaying the removal of the vendored sources to 3.16, I'd just like to understand the rationale.

A

@skirpichev
Copy link
Member

we shouldn't change anything in 3.14 at this point, but the 3.15 development cycle is open.

The puzzle is the plan (see description) to:

  1. Remove the implicit fallback to the bundled copy (at 3.14), then
  2. remove bundled copy (next release, i.e. 3.15).

Only 2) was announced and doing 1) seems now impossible for the 3.14. So, we have options:

  • a) just drop 1) and remove bundled copy in the 3.15, as planned, in one shot.
  • b) shift schedule by one release (i.e. do 1) in 3.15 and 2) in 3.16).

Our bundled copy is 2.5.1 vs 4.0.1 latest. But I don't see big changes. So, probably removing is not urgent and we should prefer b), as suggested above. I prefer a), for the record.

@skirpichev
Copy link
Member

Ok, pr's are ready for review:

@skirpichev skirpichev removed their assignment May 16, 2025
@AA-Turner
Copy link
Member

remove [the] bundled copy in [Python] 3.15, as planned, in one shot

We advertised the following to users:

Pending Removal in Python 3.15

  • The bundled copy of libmpdecimal.

Build Changes:

  • The configure option --with-system-libmpdec now defaults to yes. The bundled copy of libmpdecimal will be removed in Python 3.15.

We didn't mention removing the implicit fallback, so personally I think it's OK to remove both in one go. Ubuntu 26.04 (to be released c. 1 month before Python 3.15b1) will have mpdecimal sources, which will make building easier.

However, removing the fallback in 3.15 and then removing the bundled sources in 3.16 is the more conservative position.

A

@skirpichev
Copy link
Member

Ubuntu 26.04 (to be released c. 1 month before Python 3.15b1) will have mpdecimal sources, which will make building easier.

This will be not immediately available in gh action runners.

However, removing the fallback in 3.15 and then removing the bundled sources in 3.16 is the more conservative position.

I think more core devs in the thread are for that option, thus I withdraw my pr with removal of the bundled copy. Or should we ask someone else?

@edmorley
Copy link

Ubuntu 26.04 (to be released c. 1 month before Python 3.15b1) will have mpdecimal sources, which will make building easier.

Hi! We build CPython releases for all supported Ubuntu LTS versions (so currently 22.04 + 24.04, and next year 26.04 too). By the time of Python 3.16's release, Ubunu 22.04 LTS should be out of standard support, so we won't have to support that. However, that still leaves 24.04 that from the sounds of it won't have an mpdecimal package available? Has anyone asked if Canonical would be willing to add mpdecimal to older LTSes too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build extension-modules C modules in the Modules dir
Projects
None yet
Development

No branches or pull requests

0