Skip to content

Python 3.15.2, built with the configure flags the Dockerfile asks for - #256

Open
rongxin-liu wants to merge 3 commits into
mainfrom
python-3.15
Open

rongxin-liu wants to merge 3 commits into
mainfrom
python-3.15

Conversation

@rongxin-liu

@rongxin-liu rongxin-liu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The image's python3 moves to 3.15.2, and for the first time it is actually the build the Dockerfile asks for: optimized, LTO, and shared. The shipped 3.14 python3 reports an empty CONFIG_ARGS and Py_ENABLE_SHARED=0, because a bare second ./configure, there since 2020, regenerated the Makefile with default flags.

Second half of the Python 3.15 move. cs50/check#53 already took TensorFlow off this image's python3 and onto a runtime of its own, which is what unblocks this; it should be merged first, since pushing this branch publishes cs50/cli:canary, the base for cs50/check branch builds.

What changes beyond the version number

  • The stray ./configure is gone. Removing it makes --enable-shared take effect, so libpython3.15.so is now a real shared library in /usr/local/lib. Both stages run ldconfig after that directory gains it; without it the builder's own pip3 install fails to load libpython3.15.so.1.0, which is how this surfaced.
  • Two flags configure never recognized are gone. --disable-static and --without-tests are not CPython options; configure has warned unrecognized options on every build since they were added. The first did nothing. The second quietly shipped Lib/test and the _test* extension modules, 176 MB in the 3.15 image; --disable-test-modules is the real flag, PGO training still runs from the source tree, and lib/python3.15 drops from ~400 MB to 225 MB. (Spotted by @rongxin-liu reviewing Run checks that import TensorFlow on a Python 3.14 runtime check#53.)
  • libmpdec. 3.15 removed the implicit fallback to the bundled copy. The builder installs libmpdec-dev and the final stage libmpdec4. Without the runtime package import decimal succeeds but quietly loads the pure-Python _pydecimal.
  • Smoke test asserts the configure flags are in CONFIG_ARGS, Py_ENABLE_SHARED is 1 and python3 resolves libpython from /usr/local/lib, _decimal (not the fallback) is what import decimal loads, and Lib/test and _testcapi are absent. Any future bare ./configure or missing runtime library fails the build instead of shipping.

Verification

Built the Python block for arm64 against ubuntu:26.04 with these exact Dockerfile lines, then copied /usr/local into a fresh stage the way the final stage does. Result: no unrecognized options warning, CONFIG_ARGS: '--disable-test-modules' '--enable-optimizations' '--enable-shared' '--with-lto' 'CFLAGS=-Os', no test suite installed, Py_ENABLE_SHARED: 1, libpython3.15.so.1.0 => /usr/local/lib/..., and bz2 ctypes curses decimal lzma readline sqlite3 ssl zlib all import with _decimal loaded. The full image and tests/smoke.sh run in CI, and canary is only published if it passes.

Not verified here: the CS50 Python tools on 3.15 (compare50/style50 broke at runtime on 3.14, which is why the smoke test exercises them for real) and the pip3 install block. The workflow's smoke test covers both.

Downstream

cs50/check#53 already moved cs50/check's shared pins to versions with cp315 wheels and its CI passes against this canary. Not in scope here: compare50 1.2.15 pins attrs<21, which is satisfiable in this image (pip resolves attrs 20.3.0, pip check is clean) but conflicts with check50's 4.0.0-dev branch in cs50/check; the fix belongs in cs50/compare50. cs50/server and the apps built on it need the per-app audit from the tracking issue.

Related: #254

Moves the image's python3 from 3.14.10 to 3.15.2, now that cs50/check runs
its TensorFlow checks on a runtime of its own (cs50/check#53) and no longer
needs this image to stay on a Python that TensorFlow supports.

The bare second ./configure, there since 2020, regenerated the Makefile with
default flags: the shipped python3 reports an empty CONFIG_ARGS and
Py_ENABLE_SHARED=0, so --enable-optimizations, --with-lto, and --enable-shared
never took effect. With it gone, libpython is a shared library for the first
time, so both stages run ldconfig after /usr/local/lib gains it.

3.15 no longer falls back to the bundled libmpdec, so the builder installs
libmpdec-dev and the final stage its runtime package, libmpdec4; without the
latter `import decimal` silently loads the pure-Python fallback.

The smoke test now asserts the configure flags are in CONFIG_ARGS, the build
is shared and python3 resolves libpython from /usr/local/lib, and _decimal is
the C module. The workflow's setup-python moves to 3.15 to match.
rongxin-liu added a commit to cs50/check that referenced this pull request Nov 25, 2026
…eels

requirements.txt is installed into both runtimes, and cs50/cli:canary is now
Python 3.15 (cs50/cli#256), so each pin needs cp314 and cp315 wheels. These
are the first versions of each that have both; no pandas 2.x has cp315.

Pillow's JPEG output decides whether a CS50P shirt submission passes (the check
byte-hashes the saved image), so the reference solution was run against the
check's six muppet inputs under Pillow 11.3.0, 12.3.0, and 13.0.0: all six
hashes match on every version.

Verified by building the Python layers FROM cs50/cli:latest (3.14) and
cs50/cli:canary (3.15) and running the smoke test's Python sections on each.
…test suite

configure has been warning "unrecognized options: --disable-static,
--without-tests" on every build. Neither is a CPython option. --disable-static
did nothing (a shared build installs no libpython.a), and --without-tests
quietly shipped Lib/test plus the _test* extension modules, 176 MB in the
3.15 image. --disable-test-modules is the real flag; PGO training still runs
from the source tree, and lib/python3.15 drops to 225 MB.

The smoke test asserts Lib/test and _testcapi are absent so a return to the
no-op flag cannot pass. (Spotted by rongxin-liu while reviewing cs50/check#53.)
canary is whichever branch pushed last, so a dependent that wants to build
on one branch's image for a while (cs50/check trialing Python 3.15 in
production from this branch) has nothing stable to point at. Every branch
other than main and ubuntu-* now also publishes <branch>-amd64, <branch>-arm64,
and a <branch> manifest, with / in the branch name replaced by -.
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.

1 participant