README.rst 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. This is Python version 3.12.2
  2. =============================
  3. .. image:: https://github.com/python/cpython/workflows/Tests/badge.svg
  4. :alt: CPython build status on GitHub Actions
  5. :target: https://github.com/python/cpython/actions
  6. .. image:: https://dev.azure.com/python/cpython/_apis/build/status/Azure%20Pipelines%20CI?branchName=main
  7. :alt: CPython build status on Azure DevOps
  8. :target: https://dev.azure.com/python/cpython/_build/latest?definitionId=4&branchName=main
  9. .. image:: https://img.shields.io/badge/discourse-join_chat-brightgreen.svg
  10. :alt: Python Discourse chat
  11. :target: https://discuss.python.org/
  12. Copyright © 2001-2024 Python Software Foundation. All rights reserved.
  13. See the end of this file for further copyright and license information.
  14. .. contents::
  15. General Information
  16. -------------------
  17. - Website: https://www.python.org
  18. - Source code: https://github.com/python/cpython
  19. - Issue tracker: https://github.com/python/cpython/issues
  20. - Documentation: https://docs.python.org
  21. - Developer's Guide: https://devguide.python.org/
  22. Contributing to CPython
  23. -----------------------
  24. For more complete instructions on contributing to CPython development,
  25. see the `Developer Guide`_.
  26. .. _Developer Guide: https://devguide.python.org/
  27. Using Python
  28. ------------
  29. Installable Python kits, and information about using Python, are available at
  30. `python.org`_.
  31. .. _python.org: https://www.python.org/
  32. Build Instructions
  33. ------------------
  34. On Unix, Linux, BSD, macOS, and Cygwin::
  35. ./configure
  36. make
  37. make test
  38. sudo make install
  39. This will install Python as ``python3``.
  40. You can pass many options to the configure script; run ``./configure --help``
  41. to find out more. On macOS case-insensitive file systems and on Cygwin,
  42. the executable is called ``python.exe``; elsewhere it's just ``python``.
  43. Building a complete Python installation requires the use of various
  44. additional third-party libraries, depending on your build platform and
  45. configure options. Not all standard library modules are buildable or
  46. useable on all platforms. Refer to the
  47. `Install dependencies <https://devguide.python.org/getting-started/setup-building.html#build-dependencies>`_
  48. section of the `Developer Guide`_ for current detailed information on
  49. dependencies for various Linux distributions and macOS.
  50. On macOS, there are additional configure and build options related
  51. to macOS framework and universal builds. Refer to `Mac/README.rst
  52. <https://github.com/python/cpython/blob/main/Mac/README.rst>`_.
  53. On Windows, see `PCbuild/readme.txt
  54. <https://github.com/python/cpython/blob/main/PCbuild/readme.txt>`_.
  55. If you wish, you can create a subdirectory and invoke configure from there.
  56. For example::
  57. mkdir debug
  58. cd debug
  59. ../configure --with-pydebug
  60. make
  61. make test
  62. (This will fail if you *also* built at the top-level directory. You should do
  63. a ``make clean`` at the top-level first.)
  64. To get an optimized build of Python, ``configure --enable-optimizations``
  65. before you run ``make``. This sets the default make targets up to enable
  66. Profile Guided Optimization (PGO) and may be used to auto-enable Link Time
  67. Optimization (LTO) on some platforms. For more details, see the sections
  68. below.
  69. Profile Guided Optimization
  70. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  71. PGO takes advantage of recent versions of the GCC or Clang compilers. If used,
  72. either via ``configure --enable-optimizations`` or by manually running
  73. ``make profile-opt`` regardless of configure flags, the optimized build
  74. process will perform the following steps:
  75. The entire Python directory is cleaned of temporary files that may have
  76. resulted from a previous compilation.
  77. An instrumented version of the interpreter is built, using suitable compiler
  78. flags for each flavor. Note that this is just an intermediary step. The
  79. binary resulting from this step is not good for real-life workloads as it has
  80. profiling instructions embedded inside.
  81. After the instrumented interpreter is built, the Makefile will run a training
  82. workload. This is necessary in order to profile the interpreter's execution.
  83. Note also that any output, both stdout and stderr, that may appear at this step
  84. is suppressed.
  85. The final step is to build the actual interpreter, using the information
  86. collected from the instrumented one. The end result will be a Python binary
  87. that is optimized; suitable for distribution or production installation.
  88. Link Time Optimization
  89. ^^^^^^^^^^^^^^^^^^^^^^
  90. Enabled via configure's ``--with-lto`` flag. LTO takes advantage of the
  91. ability of recent compiler toolchains to optimize across the otherwise
  92. arbitrary ``.o`` file boundary when building final executables or shared
  93. libraries for additional performance gains.
  94. What's New
  95. ----------
  96. We have a comprehensive overview of the changes in the `What's New in Python
  97. 3.12 <https://docs.python.org/3.12/whatsnew/3.12.html>`_ document. For a more
  98. detailed change log, read `Misc/NEWS
  99. <https://github.com/python/cpython/tree/main/Misc/NEWS.d>`_, but a full
  100. accounting of changes can only be gleaned from the `commit history
  101. <https://github.com/python/cpython/commits/main>`_.
  102. If you want to install multiple versions of Python, see the section below
  103. entitled "Installing multiple versions".
  104. Documentation
  105. -------------
  106. `Documentation for Python 3.12 <https://docs.python.org/3.12/>`_ is online,
  107. updated daily.
  108. It can also be downloaded in many formats for faster access. The documentation
  109. is downloadable in HTML, PDF, and reStructuredText formats; the latter version
  110. is primarily for documentation authors, translators, and people with special
  111. formatting requirements.
  112. For information about building Python's documentation, refer to `Doc/README.rst
  113. <https://github.com/python/cpython/blob/main/Doc/README.rst>`_.
  114. Converting From Python 2.x to 3.x
  115. ---------------------------------
  116. Significant backward incompatible changes were made for the release of Python
  117. 3.0, which may cause programs written for Python 2 to fail when run with Python
  118. 3. For more information about porting your code from Python 2 to Python 3, see
  119. the `Porting HOWTO <https://docs.python.org/3/howto/pyporting.html>`_.
  120. Testing
  121. -------
  122. To test the interpreter, type ``make test`` in the top-level directory. The
  123. test set produces some output. You can generally ignore the messages about
  124. skipped tests due to optional features which can't be imported. If a message
  125. is printed about a failed test or a traceback or core dump is produced,
  126. something is wrong.
  127. By default, tests are prevented from overusing resources like disk space and
  128. memory. To enable these tests, run ``make testall``.
  129. If any tests fail, you can re-run the failing test(s) in verbose mode. For
  130. example, if ``test_os`` and ``test_gdb`` failed, you can run::
  131. make test TESTOPTS="-v test_os test_gdb"
  132. If the failure persists and appears to be a problem with Python rather than
  133. your environment, you can `file a bug report
  134. <https://github.com/python/cpython/issues>`_ and include relevant output from
  135. that command to show the issue.
  136. See `Running & Writing Tests <https://devguide.python.org/testing/run-write-tests.html>`_
  137. for more on running tests.
  138. Installing multiple versions
  139. ----------------------------
  140. On Unix and Mac systems if you intend to install multiple versions of Python
  141. using the same installation prefix (``--prefix`` argument to the configure
  142. script) you must take care that your primary python executable is not
  143. overwritten by the installation of a different version. All files and
  144. directories installed using ``make altinstall`` contain the major and minor
  145. version and can thus live side-by-side. ``make install`` also creates
  146. ``${prefix}/bin/python3`` which refers to ``${prefix}/bin/python3.X``. If you
  147. intend to install multiple versions using the same prefix you must decide which
  148. version (if any) is your "primary" version. Install that version using ``make
  149. install``. Install all other versions using ``make altinstall``.
  150. For example, if you want to install Python 2.7, 3.6, and 3.12 with 3.12 being the
  151. primary version, you would execute ``make install`` in your 3.12 build directory
  152. and ``make altinstall`` in the others.
  153. Release Schedule
  154. ----------------
  155. See :pep:`693` for Python 3.12 release details.
  156. Copyright and License Information
  157. ---------------------------------
  158. Copyright © 2001-2024 Python Software Foundation. All rights reserved.
  159. Copyright © 2000 BeOpen.com. All rights reserved.
  160. Copyright © 1995-2001 Corporation for National Research Initiatives. All
  161. rights reserved.
  162. Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
  163. See the `LICENSE <https://github.com/python/cpython/blob/main/LICENSE>`_ for
  164. information on the history of this software, terms & conditions for usage, and a
  165. DISCLAIMER OF ALL WARRANTIES.
  166. This Python distribution contains *no* GNU General Public License (GPL) code,
  167. so it may be used in proprietary projects. There are interfaces to some GNU
  168. code but these are entirely optional.
  169. All trademarks referenced herein are property of their respective holders.