Open-Source Wikis

/

CPython

/

Reference

/

Dependencies

python/cpython

Dependencies

CPython is unusually self-contained for a project of its size, but it does depend on a handful of system and vendored libraries. This page lists them and where they live in the source tree.

System (linked dynamically)

These are required at build time and at runtime; missing ones make the corresponding stdlib module unbuildable. The detailed per-distro list is in the devguide build-setup page.

Library Used by
libc + pthreads The interpreter itself.
OpenSSL 1.1.1+ ssl, hashlib (digests when available). Modules/_ssl.c, Modules/_hashopenssl.c.
zlib zlib, gzip. Modules/zlibmodule.c.
bzip2 bz2. Modules/_bz2module.c.
xz / liblzma lzma, tarfile. Modules/_lzmamodule.c.
zstd _zstd accelerator. Modules/_zstd/.
libffi ctypes. Modules/_ctypes/.
Tcl/Tk tkinter, IDLE. Modules/_tkinter.c.
ncurses curses. Modules/_cursesmodule.c, Modules/_curses_panel.c.
readline (or editline) Interactive REPL. Modules/readline.c.
sqlite3 sqlite3. Modules/_sqlite/.
gdbm, ndbm dbm.gnu, dbm.ndbm. Modules/_gdbmmodule.c, Modules/_dbmmodule.c.
uuid uuid. Modules/_uuidmodule.c.

A missing optional library is not fatal. The build records which modules failed in setup.py-style logs and prints a "modules that failed to build" summary at the end of make.

Vendored

Some libraries are kept in-tree to guarantee a known good version regardless of the OS:

Library In-tree path Why vendored
expat Modules/expat/ XML parser; CPython is a major upstream user.
libmpdec + _decimal Modules/_decimal/ The arbitrary-precision decimal library is co-maintained with CPython.
HACL* (formally verified crypto) Modules/_hacl/ Provides hash digests when OpenSSL isn't available; kept verified-via-F*.
mimalloc Objects/mimalloc/ Used by free-threaded builds. Pinned for ABI stability.
libb2 (BLAKE2) Modules/blake2module.c (when not using OpenSSL) Fallback BLAKE2 implementation.
Unicode Character Database Generated tables under Modules/unicodedata_db.h, Modules/unicodename_db.h, Objects/unicodetype_db.h Built from the UCD via Tools/unicode/.

./configure --with-system-<name> opts back to the system copy when one is available.

Build-time dependencies

These are needed to build CPython but not to run it:

Tool Used by
C compiler (GCC/Clang/MSVC) Everything.
make (GNU make on Unix) Top-level build.
autoconf 2.71+ Regenerating configure from configure.ac.
pkg-config Optional; used to locate system OpenSSL/Tk/etc.
Python 3.10+ Required to build from a fresh checkout — used to run the regenerators (PEG, Clinic, cases generator, etc.).
LLVM (clang + llvm-readobj) Required only for --enable-experimental-jit: the Tools/jit/ build pipeline compiles uop stencils.
sphinx (and several plugins) Building Doc/ HTML/man/pdf. Pinned via Doc/requirements.txt.
ruff, mypy Lint and CI (.ruff.toml, Misc/mypy/).
blurb NEWS-entry generation. ~`pipx run blurb` is fine if you don't have one in-tree.

Test-time dependencies

The default test run uses only the stdlib. Optional helpers:

Vendored Python packages in Lib/

The pure-Python stdlib is generally completely independent of third-party packages. Two historical exceptions:

  • tomli — was vendored as the basis for Lib/tomllib/. Now inlined.
  • pip is not vendored as Python source; it ships as a pre-built wheel embedded by ensurepip (see Lib/ensurepip/_bundled/).
  • Test helpers in Lib/test/support/ implement minimal versions of common patterns rather than depending on external libraries.

Platform-specific code

Path Platform
PC/ Windows-specific build helpers (winreg.c, getpathp.c, _msi.c, pyconfig.h, …).
PCbuild/ MSBuild project files for python.exe.
Mac/ macOS framework/installer scripts.
Tools/wasm/, Modules/_wasi/-style files Emscripten/WASI cross-compile.
Lib/_apple_support.py, Lib/_ios_support.py, Lib/_android_support.py Mobile platform shims.
Programs/_freeze_module.c The freezer, run during cross-compile.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Dependencies – CPython wiki | Factory