Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 1 | **************** |
| 2 | Configure Python |
| 3 | **************** |
| 4 | |
| 5 | .. _configure-options: |
| 6 | |
| 7 | Configure Options |
| 8 | ================= |
| 9 | |
| 10 | List all ``./configure`` script options using:: |
| 11 | |
| 12 | ./configure --help |
| 13 | |
| 14 | See also the :file:`Misc/SpecialBuilds.txt` in the Python source distribution. |
| 15 | |
| 16 | General Options |
| 17 | --------------- |
| 18 | |
| 19 | .. cmdoption:: --enable-loadable-sqlite-extensions |
| 20 | |
| 21 | Support loadable extensions in the :mod:`_sqlite` extension module (default |
| 22 | is no), see the :mod:`sqlite3` module. |
| 23 | |
| 24 | .. versionadded:: 3.6 |
| 25 | |
| 26 | .. cmdoption:: --disable-ipv6 |
| 27 | |
| 28 | Disable IPv6 support (enabled by default if supported), see the |
| 29 | :mod:`socket` module. |
| 30 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 31 | .. cmdoption:: --enable-big-digits=[15|30] |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 32 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 33 | Define the size in bits of Python :class:`int` digits: 15 or 30 bits. |
| 34 | |
| 35 | By default, the number of bits is selected depending on ``sizeof(void*)``: |
| 36 | 30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise. |
| 37 | |
| 38 | Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 39 | |
| 40 | See :data:`sys.int_info.bits_per_digit <sys.int_info>`. |
| 41 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 42 | .. cmdoption:: --with-cxx-main |
| 43 | .. cmdoption:: --with-cxx-main=COMPILER |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 44 | |
| 45 | Compile the Python ``main()`` function and link Python executable with C++ |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 46 | compiler: ``$CXX``, or *COMPILER* if specified. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 47 | |
| 48 | .. cmdoption:: --with-suffix=SUFFIX |
| 49 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 50 | Set the Python executable suffix to *SUFFIX*. |
| 51 | |
| 52 | The default suffix is ``.exe`` on Windows and macOS (``python.exe`` |
| 53 | executable), and an empty string on other platforms (``python`` executable). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 54 | |
| 55 | .. cmdoption:: --with-tzpath=<list of absolute paths separated by pathsep> |
| 56 | |
| 57 | Select the default time zone search path for :data:`zoneinfo.TZPATH`, |
| 58 | see the :mod:`zoneinfo` module. |
| 59 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 60 | Default: ``/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo``. |
| 61 | |
| 62 | See :data:`os.pathsep` path separator. |
| 63 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 64 | .. versionadded:: 3.9 |
| 65 | |
| 66 | .. cmdoption:: --without-decimal-contextvar |
| 67 | |
| 68 | Build the ``_decimal`` extension module using a thread-local context rather |
| 69 | than a coroutine-local context (default), see the :mod:`decimal` module. |
| 70 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 71 | See :data:`decimal.HAVE_CONTEXTVAR` and the :mod:`contextvars` module. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 72 | |
| 73 | .. versionadded:: 3.9 |
| 74 | |
| 75 | .. cmdoption:: --with-dbmliborder=db1:db2:... |
| 76 | |
| 77 | Override order to check db backends for the :mod:`dbm` module |
| 78 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 79 | A valid value is a colon (``:``) separated string with the backend names: |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 80 | |
| 81 | * ``ndbm``; |
| 82 | * ``gdbm``; |
| 83 | * ``bdb``. |
| 84 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 85 | .. cmdoption:: --without-c-locale-coercion |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 86 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 87 | Disable C locale coercion to a UTF-8 based locale (enabled by default). |
| 88 | |
| 89 | Don't define the ``PY_COERCE_C_LOCALE`` macro. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 90 | |
| 91 | See :envvar:`PYTHONCOERCECLOCALE` and the :pep:`538`. |
| 92 | |
| 93 | .. cmdoption:: --with-platlibdir=DIRNAME |
| 94 | |
| 95 | Python library directory name (default is ``lib``). |
| 96 | |
| 97 | Fedora and SuSE use ``lib64`` on 64-bit platforms. |
| 98 | |
| 99 | See :data:`sys.platlibdir`. |
| 100 | |
| 101 | .. versionadded:: 3.9 |
| 102 | |
| 103 | .. cmdoption:: --with-wheel-pkg-dir=PATH |
| 104 | |
| 105 | Directory of wheel packages used by the :mod:`ensurepip` module |
| 106 | (none by default). |
| 107 | |
| 108 | Some Linux distribution packaging policies recommend against bundling |
| 109 | dependencies. For example, Fedora installs wheel packages in the |
| 110 | ``/usr/share/python-wheels/`` directory and don't install the |
| 111 | :mod:`ensurepip._bundled` package. |
| 112 | |
| 113 | .. versionadded:: 3.10 |
| 114 | |
| 115 | |
| 116 | Install Options |
| 117 | --------------- |
| 118 | |
| 119 | .. cmdoption:: --disable-test-modules |
| 120 | |
| 121 | Don't build nor install test modules, like the :mod:`test` package or the |
| 122 | :mod:`_testcapi` extension module (built and installed by default). |
| 123 | |
| 124 | .. versionadded:: 3.10 |
| 125 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 126 | .. cmdoption:: --with-ensurepip=[upgrade|install|no] |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 127 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 128 | Select the :mod:`ensurepip` command run on Python installation: |
| 129 | |
| 130 | * ``upgrade`` (default): run ``python -m ensurepip --altinstall --upgrade`` |
| 131 | command. |
| 132 | * ``install``: run ``python -m ensurepip --altinstall`` command; |
| 133 | * ``no``: don't run ensurepip; |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 134 | |
| 135 | .. versionadded:: 3.6 |
| 136 | |
| 137 | |
| 138 | Performance options |
| 139 | ------------------- |
| 140 | |
| 141 | Configuring Python using ``--enable-optimizations --with-lto`` (PGO + LTO) is |
| 142 | recommended for best performance. |
| 143 | |
| 144 | .. cmdoption:: --enable-optimizations |
| 145 | |
| 146 | Enable Profile Guided Optimization (PGO) using :envvar:`PROFILE_TASK` |
| 147 | (disabled by default). |
| 148 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 149 | The C compiler Clang requires ``llvm-profdata`` program for PGO. On |
| 150 | macOS, GCC also requires it: GCC is just an alias to Clang on macOS. |
| 151 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 152 | Disable also semantic interposition in libpython if ``--enable-shared`` and |
| 153 | GCC is used: add ``-fno-semantic-interposition`` to the compiler and linker |
| 154 | flags. |
| 155 | |
| 156 | .. versionadded:: 3.6 |
| 157 | |
| 158 | .. versionchanged:: 3.10 |
| 159 | Use ``-fno-semantic-interposition`` on GCC. |
| 160 | |
| 161 | .. envvar:: PROFILE_TASK |
| 162 | |
| 163 | Environment variable used in the Makefile: Python command line arguments for |
| 164 | the PGO generation task. |
| 165 | |
| 166 | Default: ``-m test --pgo --timeout=$(TESTTIMEOUT)``. |
| 167 | |
| 168 | .. versionadded:: 3.8 |
| 169 | |
| 170 | .. cmdoption:: --with-lto |
| 171 | |
| 172 | Enable Link Time Optimization (LTO) in any build (disabled by default). |
| 173 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 174 | The C compiler Clang requires ``llvm-ar`` for LTO, as well as an LTO-aware |
| 175 | linker (``ld.gold`` or ``lld``). |
| 176 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 177 | .. versionadded:: 3.6 |
| 178 | |
| 179 | .. cmdoption:: --with-computed-gotos |
| 180 | |
| 181 | Enable computed gotos in evaluation loop (enabled by default on supported |
| 182 | compilers). |
| 183 | |
| 184 | .. cmdoption:: --without-pymalloc |
| 185 | |
| 186 | Disable the specialized Python memory allocator :ref:`pymalloc <pymalloc>` |
| 187 | (enabled by default). |
| 188 | |
| 189 | See also :envvar:`PYTHONMALLOC` environment variable. |
| 190 | |
| 191 | .. cmdoption:: --without-doc-strings |
| 192 | |
| 193 | Disable static documentation strings to reduce the memory footprint (enabled |
| 194 | by default). Documentation strings defined in Python are not affected. |
| 195 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 196 | Don't define the ``WITH_DOC_STRINGS`` macro. |
| 197 | |
| 198 | See the ``PyDoc_STRVAR()`` macro. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 199 | |
| 200 | .. cmdoption:: --enable-profiling |
| 201 | |
| 202 | Enable C-level code profiling with ``gprof`` (disabled by default). |
| 203 | |
| 204 | |
| 205 | .. _debug-build: |
| 206 | |
| 207 | Debug build |
| 208 | ----------- |
| 209 | |
| 210 | A debug build is Python built with the :option:`--with-pydebug` configure |
| 211 | option. |
| 212 | |
| 213 | Effects of a debug build: |
| 214 | |
| 215 | * Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros. |
| 216 | * Add ``d`` to :data:`sys.abiflags`. |
| 217 | * Add :func:`sys.gettotalrefcount` function. |
| 218 | * Add :option:`-X showrefcount <-X>` command line option. |
| 219 | * Add :envvar:`PYTHONTHREADDEBUG` environment variable. |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 220 | * Add support for the ``__ltrace__`` variable: enable low-level tracing in the |
| 221 | bytecode evaluation loop if the variable is defined. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 222 | * The list of default warning filters is empty in the :mod:`warnings` module. |
| 223 | * Install debug hooks on memory allocators to detect buffer overflow and other |
| 224 | memory errors: see :c:func:`PyMem_SetupDebugHooks`. |
| 225 | * Build Python with assertions (don't set ``NDEBUG`` macro): |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 226 | ``assert(...);`` and ``_PyObject_ASSERT(...);``. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 227 | See also the :option:`--with-assertions` configure option. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 228 | * Unicode and int objects are created with their memory filled with a pattern |
| 229 | to help detecting uninitialized bytes. |
| 230 | * Many functions ensure that are not called with an exception raised, since |
| 231 | they can clear or replace the current exception. |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 232 | * The garbage collector (:func:`gc.collect` function) runs some basic checks on |
| 233 | objects consistency. |
| 234 | * More generally, add runtime checks, code surroundeded by ``#ifdef Py_DEBUG`` |
| 235 | and ``#endif``. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 236 | |
| 237 | See also the :ref:`Python Development Mode <devmode>` and the |
| 238 | :option:`--with-trace-refs` configure option. |
| 239 | |
| 240 | .. versionchanged:: 3.8 |
| 241 | Release builds and debug builds are now ABI compatible: defining the |
| 242 | ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro, which |
| 243 | introduces the only ABI incompatibility. |
| 244 | |
| 245 | |
| 246 | Debug options |
| 247 | ------------- |
| 248 | |
| 249 | .. cmdoption:: --with-pydebug |
| 250 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 251 | :ref:`Build Python in debug mode <debug-build>`: define the ``Py_DEBUG`` |
| 252 | macro (disabled by default). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 253 | |
| 254 | .. cmdoption:: --with-trace-refs |
| 255 | |
| 256 | Enable tracing references for debugging purpose (disabled by default). |
| 257 | |
| 258 | Effects: |
| 259 | |
| 260 | * Define the ``Py_TRACE_REFS`` macro. |
| 261 | * Add :func:`sys.getobjects` function. |
| 262 | * Add :envvar:`PYTHONDUMPREFS` environment variable. |
| 263 | |
| 264 | This build is not ABI compatible with release build (default build) or debug |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 265 | build (``Py_DEBUG`` and ``Py_REF_DEBUG`` macros). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 266 | |
| 267 | .. versionadded:: 3.8 |
| 268 | |
| 269 | .. cmdoption:: --with-assertions |
| 270 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 271 | Build with C assertions enabled (default is no): ``assert(...);`` and |
| 272 | ``_PyObject_ASSERT(...);``. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 273 | |
| 274 | If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler |
| 275 | variable. |
| 276 | |
| 277 | See also the :option:`--with-pydebug` option (:ref:`debug build |
| 278 | <debug-build>`) which also enables assertions. |
| 279 | |
| 280 | .. versionadded:: 3.6 |
| 281 | |
| 282 | .. cmdoption:: --with-valgrind |
| 283 | |
| 284 | Enable Valgrind support (default is no). |
| 285 | |
| 286 | .. cmdoption:: --with-dtrace |
| 287 | |
| 288 | Enable DTrace support (default is no). |
| 289 | |
| 290 | .. versionadded:: 3.6 |
| 291 | |
| 292 | .. cmdoption:: --with-address-sanitizer |
| 293 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 294 | Enable AddressSanitizer memory error detector, ``asan`` (default is no). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 295 | |
| 296 | .. versionadded:: 3.6 |
| 297 | |
| 298 | .. cmdoption:: --with-memory-sanitizer |
| 299 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 300 | Enable MemorySanitizer allocation error detector, ``msan`` (default is no). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 301 | |
| 302 | .. versionadded:: 3.6 |
| 303 | |
| 304 | .. cmdoption:: --with-undefined-behavior-sanitizer |
| 305 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 306 | Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan`` |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 307 | (default is no). |
| 308 | |
| 309 | .. versionadded:: 3.6 |
| 310 | |
| 311 | |
| 312 | Linker options |
| 313 | -------------- |
| 314 | |
| 315 | .. cmdoption:: --enable-shared |
| 316 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 317 | Enable building a shared Python library: ``libpython`` (default is no). |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 318 | |
| 319 | .. cmdoption:: --without-static-libpython |
| 320 | |
| 321 | Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o`` |
| 322 | (built and enabled by default). |
| 323 | |
| 324 | .. versionadded:: 3.10 |
| 325 | |
| 326 | |
| 327 | Libraries options |
| 328 | ----------------- |
| 329 | |
| 330 | .. cmdoption:: --with-libs='lib1 ...' |
| 331 | |
| 332 | Link against additional libraries (default is no). |
| 333 | |
| 334 | .. cmdoption:: --with-system-expat |
| 335 | |
| 336 | Build the :mod:`pyexpat` module using an installed ``expat`` library |
| 337 | (default is no). |
| 338 | |
| 339 | .. cmdoption:: --with-system-ffi |
| 340 | |
| 341 | Build the :mod:`_ctypes` extension module using an installed ``ffi`` |
| 342 | library, see the :mod:`ctypes` module (default is system-dependent). |
| 343 | |
| 344 | .. cmdoption:: --with-system-libmpdec |
| 345 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 346 | Build the ``_decimal`` extension module using an installed ``mpdec`` |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 347 | library, see the :mod:`decimal` module (default is no). |
| 348 | |
| 349 | .. versionadded:: 3.3 |
| 350 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 351 | .. cmdoption:: --with-readline=editline |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 352 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 353 | Use ``editline`` library for backend of the :mod:`readline` module. |
| 354 | |
| 355 | Define the ``WITH_EDITLINE`` macro. |
| 356 | |
| 357 | .. versionadded:: 3.10 |
| 358 | |
| 359 | .. cmdoption:: --without-readline |
| 360 | |
| 361 | Don't build the :mod:`readline` module (built by default). |
| 362 | |
| 363 | Don't define the ``HAVE_LIBREADLINE`` macro. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 364 | |
| 365 | .. versionadded:: 3.10 |
| 366 | |
| 367 | .. cmdoption:: --with-tcltk-includes='-I...' |
| 368 | |
| 369 | Override search for Tcl and Tk include files. |
| 370 | |
| 371 | .. cmdoption:: --with-tcltk-libs='-L...' |
| 372 | |
| 373 | Override search for Tcl and Tk libraries. |
| 374 | |
| 375 | .. cmdoption:: --with-libm=STRING |
| 376 | |
| 377 | Override ``libm`` math library to *STRING* (default is system-dependent). |
| 378 | |
| 379 | .. cmdoption:: --with-libc=STRING |
| 380 | |
| 381 | Override ``libc`` C library to *STRING* (default is system-dependent). |
| 382 | |
| 383 | .. cmdoption:: --with-openssl=DIR |
| 384 | |
| 385 | Root of the OpenSSL directory. |
| 386 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 387 | .. versionadded:: 3.7 |
| 388 | |
| 389 | .. cmdoption:: --with-openssl-rpath=[no|auto|DIR] |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 390 | |
| 391 | Set runtime library directory (rpath) for OpenSSL libraries: |
| 392 | |
| 393 | * ``no`` (default): don't set rpath; |
| 394 | * ``auto``: auto-detect rpath from :option:`--with-openssl` and |
| 395 | ``pkg-config``; |
| 396 | * *DIR*: set an explicit rpath. |
| 397 | |
| 398 | .. versionadded:: 3.10 |
| 399 | |
| 400 | |
| 401 | Security Options |
| 402 | ---------------- |
| 403 | |
| 404 | .. cmdoption:: --with-hash-algorithm=[fnv|siphash24] |
| 405 | |
| 406 | Select hash algorithm for use in ``Python/pyhash.c``: |
| 407 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 408 | * ``siphash24`` (default). |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 409 | * ``fnv``; |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 410 | |
| 411 | .. versionadded:: 3.4 |
| 412 | |
| 413 | .. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2 |
| 414 | |
| 415 | Built-in hash modules: |
| 416 | |
| 417 | * ``md5``; |
| 418 | * ``sha1``; |
| 419 | * ``sha256``; |
| 420 | * ``sha512``; |
| 421 | * ``sha3`` (with shake); |
| 422 | * ``blake2``. |
| 423 | |
| 424 | .. versionadded:: 3.9 |
| 425 | |
| 426 | .. cmdoption:: --with-ssl-default-suites=[python|openssl|STRING] |
| 427 | |
| 428 | Override the OpenSSL default cipher suites string: |
| 429 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 430 | * ``python`` (default): use Python's preferred selection; |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 431 | * ``openssl``: leave OpenSSL's defaults untouched; |
| 432 | * *STRING*: use a custom string, PROTOCOL_SSLv2 ignores the setting. |
| 433 | |
| 434 | See the :mod:`ssl` module. |
| 435 | |
| 436 | .. versionadded:: 3.7 |
| 437 | |
| 438 | |
| 439 | macOS Options |
| 440 | ------------- |
| 441 | |
| 442 | See ``Mac/README.rst``. |
| 443 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 444 | .. cmdoption:: --enable-universalsdk |
| 445 | .. cmdoption:: --enable-universalsdk=SDKDIR |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 446 | |
| 447 | Create a universal binary build. *SDKDIR* specifies which macOS SDK should |
| 448 | be used to perform the build (default is no). |
| 449 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 450 | .. cmdoption:: --enable-framework |
| 451 | .. cmdoption:: --enable-framework=INSTALLDIR |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 452 | |
| 453 | Create a Python.framework rather than a traditional Unix install. Optional |
| 454 | *INSTALLDIR* specifies the installation path (default is no). |
| 455 | |
| 456 | .. cmdoption:: --with-universal-archs=ARCH |
| 457 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 458 | Specify the kind of universal binary that should be created. This option is |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 459 | only valid when :option:`--enable-universalsdk` is set. |
| 460 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 461 | Options: |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 462 | |
| 463 | * ``universal2``; |
| 464 | * ``32-bit``; |
| 465 | * ``64-bit``; |
| 466 | * ``3-way``; |
| 467 | * ``intel``; |
| 468 | * ``intel-32``; |
| 469 | * ``intel-64``; |
| 470 | * ``all``. |
| 471 | |
| 472 | .. cmdoption:: --with-framework-name=FRAMEWORK |
| 473 | |
| 474 | Specify the name for the python framework on macOS only valid when |
| 475 | :option:`--enable-framework` is set (default: ``Python``). |
| 476 | |
| 477 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 478 | Python Build System |
| 479 | =================== |
| 480 | |
| 481 | Main files of the build system |
| 482 | ------------------------------ |
| 483 | |
| 484 | * :file:`configure.ac` => :file:`configure`; |
| 485 | * :file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`); |
| 486 | * :file:`pyconfig.h` (created by :file:`configure`); |
| 487 | * :file:`Modules/Setup`: C extensions built by the Makefile using |
| 488 | :file:`Module/makesetup` shell script; |
| 489 | * :file:`setup.py`: C extensions built using the :mod:`distutils` module. |
| 490 | |
| 491 | Main build steps |
| 492 | ---------------- |
| 493 | |
| 494 | * C files (``.c``) are built as object files (``.o``). |
| 495 | * A static ``libpython`` library (``.a``) is created from objects files. |
| 496 | * ``python.o`` and the static ``libpython`` library are linked into the |
| 497 | final ``python`` program. |
| 498 | * C extensions are built by the Makefile (see :file:`Modules/Setup`) |
| 499 | and ``python setup.py build``. |
| 500 | |
| 501 | Main Makefile targets |
| 502 | --------------------- |
| 503 | |
| 504 | * ``make``: Build Python with the standard library. |
| 505 | * ``make platform:``: build the ``python`` program, but don't build the |
| 506 | standard library extension modules. |
| 507 | * ``make profile-opt``: build Python using Profile Guided Optimization (PGO). |
| 508 | You can use the configure :option:`--enable-optimizations` option to make |
| 509 | this the default target of the ``make`` command (``make all`` or just |
| 510 | ``make``). |
| 511 | * ``make buildbottest``: Build Python and run the Python test suite, the same |
| 512 | way than buildbots test Python. Set ``TESTTIMEOUT`` variable (in seconds) |
| 513 | to change the test timeout (1200 by default: 20 minutes). |
| 514 | * ``make install``: Build and install Python. |
| 515 | * ``make regen-all``: Regenerate (almost) all generated files; |
| 516 | ``make regen-stdlib-module-names`` and ``autoconf`` must be run separately |
| 517 | for the remaining generated files. |
| 518 | * ``make clean``: Remove built files. |
| 519 | * ``make distclean``: Same than ``make clean``, but remove also files created |
| 520 | by the configure script. |
| 521 | |
| 522 | C extensions |
| 523 | ------------ |
| 524 | |
| 525 | Some C extensions are built as built-in modules, like the ``sys`` module. |
| 526 | They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined. |
| 527 | Built-in modules have no ``__file__`` attribute:: |
| 528 | |
| 529 | >>> import sys |
| 530 | >>> sys |
| 531 | <module 'sys' (built-in)> |
| 532 | >>> sys.__file__ |
| 533 | Traceback (most recent call last): |
| 534 | File "<stdin>", line 1, in <module> |
| 535 | AttributeError: module 'sys' has no attribute '__file__' |
| 536 | |
| 537 | Other C extensins are built as dynamic libraires, like the ``_asyncio`` module. |
| 538 | They are built with the ``Py_BUILD_CORE_MODULE`` macro defined. |
| 539 | Example on Linux x86-64:: |
| 540 | |
| 541 | >>> import _asyncio |
| 542 | >>> _asyncio |
| 543 | <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'> |
| 544 | >>> _asyncio.__file__ |
| 545 | '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so' |
| 546 | |
| 547 | :file:`Modules/Setup` is used to generate Makefile targets to build C extensions. |
| 548 | At the beginning of the files, C extensions are built as built-in modules. |
| 549 | Extensions defined after the ``*shared*`` marker are built as dynamic libraries. |
| 550 | |
| 551 | The :file:`setup.py` script only builds C extensions as shared libraries using |
| 552 | the :mod:`distutils` module. |
| 553 | |
| 554 | The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and |
| 555 | :c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined |
| 556 | differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined: |
| 557 | |
| 558 | * Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined |
| 559 | * Use ``Py_IMPORTED_SYMBOL`` otherwise. |
| 560 | |
| 561 | If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension |
| 562 | built as a shared library, its ``PyInit_xxx()`` function is not exported, |
| 563 | causing an :exc:`ImportError` on import. |
| 564 | |
| 565 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 566 | Compiler and linker flags |
| 567 | ========================= |
| 568 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 569 | Options set by the ``./configure`` script and environment variables and used by |
| 570 | ``Makefile``. |
| 571 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 572 | Preprocessor flags |
| 573 | ------------------ |
| 574 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 575 | .. envvar:: CONFIGURE_CPPFLAGS |
| 576 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 577 | Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script. |
| 578 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 579 | .. versionadded:: 3.6 |
| 580 | |
| 581 | .. envvar:: CPPFLAGS |
| 582 | |
| 583 | (Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have |
| 584 | headers in a nonstandard directory ``<include dir>``. |
| 585 | |
| 586 | Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's |
| 587 | value for setup.py to be able to build extension modules using the |
| 588 | directories specified in the environment variables. |
| 589 | |
| 590 | .. envvar:: BASECPPFLAGS |
| 591 | |
| 592 | .. versionadded:: 3.4 |
| 593 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 594 | .. envvar:: PY_CPPFLAGS |
| 595 | |
| 596 | Extra preprocessor flags added for building the interpreter object files. |
| 597 | |
| 598 | Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)``. |
| 599 | |
| 600 | .. versionadded:: 3.2 |
| 601 | |
| 602 | Compiler flags |
| 603 | -------------- |
| 604 | |
| 605 | .. envvar:: CC |
| 606 | |
| 607 | C compiler command. |
| 608 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 609 | Example: ``gcc -pthread``. |
| 610 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 611 | .. envvar:: MAINCC |
| 612 | |
| 613 | C compiler command used to build the ``main()`` function of programs like |
| 614 | ``python``. |
| 615 | |
| 616 | Variable set by the :option:`--with-cxx-main` option of the configure |
| 617 | script. |
| 618 | |
| 619 | Default: ``$(CC)``. |
| 620 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 621 | .. envvar:: CXX |
| 622 | |
| 623 | C++ compiler command. |
| 624 | |
| 625 | Used if the :option:`--with-cxx-main` option is used. |
| 626 | |
| 627 | Example: ``g++ -pthread``. |
| 628 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 629 | .. envvar:: CFLAGS |
| 630 | |
| 631 | C compiler flags. |
| 632 | |
| 633 | .. envvar:: CFLAGS_NODIST |
| 634 | |
| 635 | :envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C |
| 636 | extensions. Use it when a compiler flag should *not* be part of the |
| 637 | distutils :envvar:`CFLAGS` once Python is installed (:issue:`21121`). |
| 638 | |
| 639 | .. versionadded:: 3.5 |
| 640 | |
| 641 | .. envvar:: EXTRA_CFLAGS |
| 642 | |
| 643 | Extra C compiler flags. |
| 644 | |
| 645 | .. envvar:: CONFIGURE_CFLAGS |
| 646 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 647 | Value of :envvar:`CFLAGS` variable passed to the ``./configure`` |
| 648 | script. |
| 649 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 650 | .. versionadded:: 3.2 |
| 651 | |
| 652 | .. envvar:: CONFIGURE_CFLAGS_NODIST |
| 653 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 654 | Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure`` |
| 655 | script. |
| 656 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 657 | .. versionadded:: 3.5 |
| 658 | |
| 659 | .. envvar:: BASECFLAGS |
| 660 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 661 | Base compiler flags. |
| 662 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 663 | .. envvar:: OPT |
| 664 | |
| 665 | Optimization flags. |
| 666 | |
| 667 | .. envvar:: CFLAGS_ALIASING |
| 668 | |
| 669 | Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``. |
| 670 | |
| 671 | .. versionadded:: 3.7 |
| 672 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 673 | .. envvar:: CCSHARED |
| 674 | |
| 675 | Compiler flags used to build a shared library. |
| 676 | |
| 677 | For example, ``-fPIC`` is used on Linux and on BSD. |
| 678 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 679 | .. envvar:: CFLAGSFORSHARED |
| 680 | |
| 681 | Extra C flags added for building the interpreter object files. |
| 682 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 683 | Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty |
| 684 | string otherwise. |
| 685 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 686 | .. envvar:: PY_CFLAGS |
| 687 | |
| 688 | Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)``. |
| 689 | |
| 690 | .. envvar:: PY_CFLAGS_NODIST |
| 691 | |
| 692 | Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal``. |
| 693 | |
| 694 | .. versionadded:: 3.5 |
| 695 | |
| 696 | .. envvar:: PY_STDMODULE_CFLAGS |
| 697 | |
| 698 | C flags used for building the interpreter object files. |
| 699 | |
| 700 | Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)``. |
| 701 | |
| 702 | .. versionadded:: 3.7 |
| 703 | |
| 704 | .. envvar:: PY_CORE_CFLAGS |
| 705 | |
| 706 | Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``. |
| 707 | |
| 708 | .. versionadded:: 3.2 |
| 709 | |
| 710 | .. envvar:: PY_BUILTIN_MODULE_CFLAGS |
| 711 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 712 | Compiler flags to build a standard library extension module as a built-in |
| 713 | module, like the :mod:`posix` module. |
| 714 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 715 | Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``. |
| 716 | |
| 717 | .. versionadded:: 3.8 |
| 718 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 719 | .. envvar:: PURIFY |
| 720 | |
| 721 | Purify command. Purify is a memory debugger program. |
| 722 | |
| 723 | Default: empty string (not used). |
| 724 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 725 | |
| 726 | Linker flags |
| 727 | ------------ |
| 728 | |
Victor Stinner | bd88ccb | 2021-04-09 14:35:10 +0200 | [diff] [blame^] | 729 | .. envvar:: LINKCC |
| 730 | |
| 731 | Linker command used to build programs like ``python`` and ``_testembed``. |
| 732 | |
| 733 | Default: ``$(PURIFY) $(MAINCC)``. |
| 734 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 735 | .. envvar:: CONFIGURE_LDFLAGS |
| 736 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 737 | Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script. |
| 738 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 739 | Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use |
| 740 | them on the command line to append to these values without stomping the |
| 741 | pre-set values. |
| 742 | |
| 743 | .. versionadded:: 3.2 |
| 744 | |
| 745 | .. envvar:: LDFLAGS_NODIST |
| 746 | |
| 747 | :envvar:`LDFLAGS_NODIST` is used in the same manner as |
| 748 | :envvar:`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of |
| 749 | the distutils :envvar:`LDFLAGS` once Python is installed (:issue:`35257`). |
| 750 | |
| 751 | .. envvar:: CONFIGURE_LDFLAGS_NODIST |
| 752 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 753 | Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure`` |
| 754 | script. |
| 755 | |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 756 | .. versionadded:: 3.8 |
| 757 | |
| 758 | .. envvar:: LDFLAGS |
| 759 | |
| 760 | Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard |
| 761 | directory ``<lib dir>``. |
| 762 | |
| 763 | Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's |
| 764 | value for setup.py to be able to build extension modules using the |
| 765 | directories specified in the environment variables. |
| 766 | |
| 767 | .. envvar:: LIBS |
| 768 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 769 | Linker flags to pass libraries to the linker when linking the Python |
| 770 | executable. |
| 771 | |
| 772 | Example: ``-lrt``. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 773 | |
| 774 | .. envvar:: LDSHARED |
| 775 | |
| 776 | Command to build a shared library. |
| 777 | |
| 778 | Default: ``@LDSHARED@ $(PY_LDFLAGS)``. |
| 779 | |
| 780 | .. envvar:: BLDSHARED |
| 781 | |
Victor Stinner | 5436695 | 2021-04-09 01:58:20 +0200 | [diff] [blame] | 782 | Command to build ``libpython`` shared library. |
Victor Stinner | a41782c | 2021-04-08 22:32:21 +0200 | [diff] [blame] | 783 | |
| 784 | Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``. |
| 785 | |
| 786 | .. envvar:: PY_LDFLAGS |
| 787 | |
| 788 | Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``. |
| 789 | |
| 790 | .. envvar:: PY_LDFLAGS_NODIST |
| 791 | |
| 792 | Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``. |
| 793 | |
| 794 | .. versionadded:: 3.8 |
| 795 | |
| 796 | .. envvar:: PY_CORE_LDFLAGS |
| 797 | |
| 798 | Linker flags used for building the interpreter object files. |
| 799 | |
| 800 | .. versionadded:: 3.8 |