On this page
  1. sysconfig
  2. Import
  3. Overview
  4. Quick Start
  5. Implementation Walkthrough
  6. 1. Querying Installation Paths & Build Flags Portably
  7. Gotchas & Boundaries
  8. Common Functions

sysconfig

Prev: sys | Up: stdlib_module | Next: syslog
Rel: sys, builtins, warnings, dataclasses, contextlib
Ref: docs.python.org — sysconfig
Tags: #public #python3 #stdlib


Import

import sysconfig

Overview

Exposes CPython's build-time and installation-layout configuration (get_paths, get_path, get_platform, get_config_var, get_python_version). Essential for packaging tools, virtual environment builders, and C-extension compilers that need portable purelib, platlib, scripts, and include directory locations.

Quick Start

import sysconfig

paths = sysconfig.get_paths()
assert "purelib" in paths and "scripts" in paths
assert isinstance(sysconfig.get_platform(), str)

Implementation Walkthrough

1. Querying Installation Paths & Build Flags Portably

import sysconfig

site_packages = sysconfig.get_path("purelib")
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
is_free_threaded = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
assert isinstance(site_packages, str)

Gotchas & Boundaries

Common Functions

Linked from

Related notes