Repository navigation
Link a static libmpdec into Linux builds for Python 3.15+ - #418
austinmatherne-wk wants to merge 5 commits into
Conversation
Python 3.15 no longer falls back to its bundled libmpdec when configure can't find a system copy, and 3.16 removes the bundled copy entirely, so the Ubuntu builds silently drop the C _decimal module. Ubuntu 24.04 doesn't package mpdecimal. Build mpdecimal 4.0.1 from its release tarball, verified against the SHA-256 that CPython's macOS installer pins, and link it statically so the artifact doesn't need libmpdec on the runner. Fixes actions/setup-python#1376
Same change as the Ubuntu builder. The RHEL builder doesn't install mpdecimal-devel either, so Python 3.15+ builds there also lose _decimal.
Importing decimal succeeds even without _decimal because it falls back to _pydecimal, so the existing check didn't catch a missing C extension.
|
I checked this locally with the builder's configure flags on 3.15.0 (Ubuntu, gcc 15.2): without libmpdec Two optional notes, neither blocking:
The published 3.15.0 Linux tarballs will need a rebuild after this merges. |
The bundled libmpdec in the 3.14 builds was compiled with CPython's own flags, -O3 and -fvisibility=hidden among them. mpdecimal's configure defaults to -O2 and exports every libmpdec symbol, so _decimal from the static library exports about 240 mpd_* symbols and runs slower on large numbers. Pass the same two flags to mpdecimal's configure. Its default -O2 still comes first, so -O3 wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN
Execute-Command logs failures without stopping, so a failed mpdecimal build used to surface only later, as the missing _decimal module in the module tests. Check for libmpdec.a after installing and exit with an error instead.
|
Thanks! I cherry picked your commit. I also added added a commit which stops the build if |
|
@v-HarithaVattikuti could you review this when you have a moment? Until it ships, the Ubuntu 3.15.0 builds that 🤖 Generated with Claude Code |
Fixes actions/setup-python#1376
Python 3.15 no longer falls back to the bundled libmpdec when
configurecan't find a system copy (what's new). The Ubuntu builds of 3.15.0 ship without the C_decimalmodule as a result.decimalthen falls back to_pydecimal, which is slower and raisesValueErrorfor values over 4300 digits. The RHEL builder has the same problem.Installing
libmpdec-devdoesn't fix it. Ubuntu 24.04 has no mpdecimal package, and the tarballs would then need libmpdec installed on the runner.--without-system-libmpdecworks for 3.15, but 3.16 removes the bundled copy and the flag (what's new).For 3.15+, the Ubuntu and RHEL builders now download mpdecimal 4.0.1, check its SHA-256, build it as a static library, and pass it to
configurethroughLIBMPDEC_CFLAGSandLIBMPDEC_LIBS. It's the same tarball and hash that CPython's macOS installer uses._decimalhas no runtime dependency on libmpdec, and builds before 3.15 are unchanged.python-modules.pynow checks for_decimalas well. Importingdecimalsucceeds through_pydecimal, so the existing check didn't catch this.Testing:
test_decimalpasses during the PGO build.Configure()._decimalimports and doesn't link to libmpdec.Notes:
_decimal.BuildLibmpdec().