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

Unvendor libmpdec sources #115119

Open
10 of 15 tasks
zware opened this issue Feb 7, 2024 · 43 comments
Open
10 of 15 tasks

Unvendor libmpdec sources #115119

zware opened this issue Feb 7, 2024 · 43 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
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:

erlend-aasland added a commit that referenced this issue May 6, 2024
Ubuntu 22.04 ships with mpdecimal 2.5.1, installable using 'apt install libmpdec-dev'.
erlend-aasland added a commit that referenced this issue May 6, 2024
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
SonicField pushed a commit to SonicField/cpython that referenced this issue May 8, 2024
SonicField pushed a commit to SonicField/cpython that referenced this issue May 8, 2024
Ubuntu 22.04 ships with mpdecimal 2.5.1, installable using 'apt install libmpdec-dev'.
SonicField pushed a commit to SonicField/cpython that referenced this issue May 8, 2024
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue May 20, 2024
@skirpichev
Copy link
Member

It seems, that due to https://bugs.debian.org/1056785 - more projects now use _pydecimal implementation, that gets battle-tested. Here is an example of a failure: https://github.com/aleaxit/gmpy/actions/runs/9153743194/job/25163188162 due to difference in the tp_name: "decimal.Decimal" vs "Decimal".

@we-are-all-individuals
Copy link

Reaching out to the Debian CPython maintainer @doko42. It would be very nice to make mpdecimal available again in Debian. According to https://www.bytereef.org/mpdecimal/changelog.html the Sphinx issues no longer exist in version 4.0.0.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 20, 2024
…not found (pythonGH-119196)

(cherry picked from commit 642b25b)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit that referenced this issue May 20, 2024
… not found (GH-119196) (#119217)

(cherry picked from commit 642b25b)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
@vfazio
Copy link
Contributor

vfazio commented Jan 21, 2025

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

@skirpichev
Copy link
Member

Why Debian should be a special snowflake for CPython? Referenced bug thread ignores any feedback, including comments from CPython core dev. I think it's a Debian problem, not ours.

@vfazio
Copy link
Contributor

vfazio commented Jan 21, 2025

Well, Debian is a major distro and the root of other distros like Ubuntu. But i guess they'll figure it out once Python fails to build

@skirpichev
Copy link
Member

Well, Debian is a major distro and the root of other distros like Ubuntu.

Say also thanks to people, who aren't part of the Debian maintainers now.

But i guess they'll figure it out once Python fails to build

It will not fail. IIUC, with --with-system-libmpdec=no & without bundled sources it will use the pure-Python decimal module, see above: #115119 (comment).

Apparently they don't notice this.

@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?

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

10 participants