CINXE.COM
PEP 477 – Backport ensurepip (PEP 453) to Python 2.7 | peps.python.org
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="color-scheme" content="light dark"> <title>PEP 477 – Backport ensurepip (PEP 453) to Python 2.7 | peps.python.org</title> <link rel="shortcut icon" href="../_static/py.png"> <link rel="canonical" href="https://peps.python.org/pep-0477/"> <link rel="stylesheet" href="../_static/style.css" type="text/css"> <link rel="stylesheet" href="../_static/mq.css" type="text/css"> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" media="(prefers-color-scheme: light)" id="pyg-light"> <link rel="stylesheet" href="../_static/pygments_dark.css" type="text/css" media="(prefers-color-scheme: dark)" id="pyg-dark"> <link rel="alternate" type="application/rss+xml" title="Latest PEPs" href="https://peps.python.org/peps.rss"> <meta property="og:title" content='PEP 477 – Backport ensurepip (PEP 453) to Python 2.7 | peps.python.org'> <meta property="og:description" content="This PEP proposes that the ensurepip module, added to Python 3.4 by PEP 453, be backported to Python 2.7. It also proposes that automatic invocation of ensurepip be added to the Python 2.7 Windows and OSX installers. However it does not propose that aut..."> <meta property="og:type" content="website"> <meta property="og:url" content="https://peps.python.org/pep-0477/"> <meta property="og:site_name" content="Python Enhancement Proposals (PEPs)"> <meta property="og:image" content="https://peps.python.org/_static/og-image.png"> <meta property="og:image:alt" content="Python PEPs"> <meta property="og:image:width" content="200"> <meta property="og:image:height" content="200"> <meta name="description" content="This PEP proposes that the ensurepip module, added to Python 3.4 by PEP 453, be backported to Python 2.7. It also proposes that automatic invocation of ensurepip be added to the Python 2.7 Windows and OSX installers. However it does not propose that aut..."> <meta name="theme-color" content="#3776ab"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-sun-half" viewBox="0 0 24 24" pointer-events="all"> <title>Following system colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="9"></circle> <path d="M12 3v18m0-12l4.65-4.65M12 14.3l7.37-7.37M12 19.6l8.85-8.85"></path> </svg> </symbol> <symbol id="svg-moon" viewBox="0 0 24 24" pointer-events="all"> <title>Selected dark colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z"></path> </svg> </symbol> <symbol id="svg-sun" viewBox="0 0 24 24" pointer-events="all"> <title>Selected light colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="5"></circle> <line x1="12" y1="1" x2="12" y2="3"></line> <line x1="12" y1="21" x2="12" y2="23"></line> <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> <line x1="1" y1="12" x2="3" y2="12"></line> <line x1="21" y1="12" x2="23" y2="12"></line> <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> </svg> </symbol> </svg> <script> document.documentElement.dataset.colour_scheme = localStorage.getItem("colour_scheme") || "auto" </script> <section id="pep-page-section"> <header> <h1>Python Enhancement Proposals</h1> <ul class="breadcrumbs"> <li><a href="https://www.python.org/" title="The Python Programming Language">Python</a> » </li> <li><a href="../pep-0000/">PEP Index</a> » </li> <li>PEP 477</li> </ul> <button id="colour-scheme-cycler" onClick="setColourScheme(nextColourScheme())"> <svg aria-hidden="true" class="colour-scheme-icon-when-auto"><use href="#svg-sun-half"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-dark"><use href="#svg-moon"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-light"><use href="#svg-sun"></use></svg> <span class="visually-hidden">Toggle light / dark / auto colour theme</span> </button> </header> <article> <section id="pep-content"> <h1 class="page-title">PEP 477 – Backport ensurepip (PEP 453) to Python 2.7</h1> <dl class="rfc2822 field-list simple"> <dt class="field-odd">Author<span class="colon">:</span></dt> <dd class="field-odd">Donald Stufft <donald at stufft.io>, Alyssa Coghlan <ncoghlan at gmail.com></dd> <dt class="field-even">BDFL-Delegate<span class="colon">:</span></dt> <dd class="field-even">Benjamin Peterson <benjamin at python.org></dd> <dt class="field-odd">Status<span class="colon">:</span></dt> <dd class="field-odd"><abbr title="Accepted and implementation complete, or no longer active">Final</abbr></dd> <dt class="field-even">Type<span class="colon">:</span></dt> <dd class="field-even"><abbr title="Normative PEP with a new feature for Python, implementation change for CPython or interoperability standard for the ecosystem">Standards Track</abbr></dd> <dt class="field-odd">Created<span class="colon">:</span></dt> <dd class="field-odd">26-Aug-2014</dd> <dt class="field-even">Post-History<span class="colon">:</span></dt> <dd class="field-even">01-Sep-2014</dd> <dt class="field-odd">Resolution<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://mail.python.org/pipermail/python-dev/2014-September/136238.html">Python-Dev message</a></dd> </dl> <hr class="docutils" /> <section id="contents"> <details><summary>Table of Contents</summary><ul class="simple"> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#automatic-invocation">Automatic Invocation</a></li> <li><a class="reference internal" href="#documentation">Documentation</a></li> <li><a class="reference internal" href="#disabling-ensurepip-by-downstream-distributors">Disabling ensurepip by Downstream Distributors</a></li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> </details></section> <section id="abstract"> <h2><a class="toc-backref" href="#abstract" role="doc-backlink">Abstract</a></h2> <p>This PEP proposes that the <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> module, added to Python 3.4 by PEP 453, be backported to Python 2.7. It also proposes that automatic invocation of <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> be added to the Python 2.7 Windows and OSX installers. However it does <strong>not</strong> propose that automatic invocation be added to the <code class="docutils literal notranslate"><span class="pre">Makefile</span></code>.</p> <p>It also proposes that the documentation changes for the package distribution and installation guides be updated to match that in 3.4, which references using the <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> module to bootstrap the installer.</p> </section> <section id="rationale"> <h2><a class="toc-backref" href="#rationale" role="doc-backlink">Rationale</a></h2> <p>Python 2.7 is effectively a LTS release of Python which represents the end of the 2.x series and there is still a very large contingent of users whom are still using Python 2.7 as their primary version. These users, in order to participate in the wider Python ecosystem, must manually attempt to go out and find the correct way to bootstrap the packaging tools.</p> <p>It is the opinion of this PEP that making it as easy as possible for end users to participate in the wider Python ecosystem is important for 3 primary reasons:</p> <ol class="arabic simple"> <li>The Python 2.x to 3.x migration has a number of painpoints that are eased by a number of third party modules such as six <a class="footnote-reference brackets" href="#six" id="id1">[1]</a>, modernize <a class="footnote-reference brackets" href="#modernize" id="id2">[2]</a>, or future <a class="footnote-reference brackets" href="#future" id="id3">[3]</a>. However relying on these tools requires that everyone who uses the project have a tool to install these packages.</li> <li>In addition to tooling to aid in migration from Python 2.x to 3.x, there are also a number of modules that are <em>new</em> in Python 3 for which there are backports available on PyPI. This can also aid in the ability for people to write 2.x and 3.x compatible software as well as enable them to use some of the newer features of Python 3 on Python 2.</li> <li>Users also will need a number of tools in order to create python packages that conform to the newer standards that are being proposed. Things like setuptools <a class="footnote-reference brackets" href="#setuptools" id="id4">[4]</a>, Wheel <a class="footnote-reference brackets" href="#wheel" id="id5">[5]</a>, and twine <a class="footnote-reference brackets" href="#twine" id="id6">[6]</a> are enabling a safer, faster, and more reliable packaging tool chain. These tools can be difficult for people to use if first they must be told how to go out and install the package manager.</li> <li>One of Pythons biggest strengths is in the huge ecosystem of libraries and projects that have been built on top of it, most of which are distributed through PyPI. However, in order to benefit from this wide ecosystem meaningfully requires end users, some of which are going to be new, to make a decision on which package manager they should get, how to get it, and then finally actually installing it first.</li> </ol> <p>Furthermore, alternative implementations of Python are recognizing the benefits of <a class="pep reference internal" href="../pep-0453/" title="PEP 453 – Explicit bootstrapping of pip in Python installations">PEP 453</a> and both PyPy and Jython have plans to backport ensurepip to their 2.7 runtimes.</p> </section> <section id="automatic-invocation"> <h2><a class="toc-backref" href="#automatic-invocation" role="doc-backlink">Automatic Invocation</a></h2> <p><a class="pep reference internal" href="../pep-0453/" title="PEP 453 – Explicit bootstrapping of pip in Python installations">PEP 453</a> has <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> automatically invoked by default in the <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> and the Windows and OSX Installers. This allowed it to ensure that, by default, all users would get Python with pip already installed. This PEP however believes that while this is fine for the Python 2.7 Windows and Mac OS X installers it is <em>not</em> ok for the Python 2.7 <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> in general.</p> <p>The primary consumers of the <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> are downstream package managers which distribute Python themselves. These downstream distributors typically do not want pip to be installed via <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> and would prefer that end users install it with their own package manager. Not invoking <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> automatically from the <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> would allow these distributors to simply ignore the fact that <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> has been backported and still not end up with pip installed via it.</p> <p>The primary consumers of the OSX and Windows installers are end users who are attempting to install Python on their own machine. There is not a package manager available where these users can install pip into their Python through a more supported mechanism. For this reason it is the belief of this PEP that installing by default on OSX and Windows is the best course of action.</p> </section> <section id="documentation"> <h2><a class="toc-backref" href="#documentation" role="doc-backlink">Documentation</a></h2> <p>As part of this PEP, the updated packaging distribution and installation guides for Python 3.4 would be backported to Python 2.7.</p> </section> <section id="disabling-ensurepip-by-downstream-distributors"> <h2><a class="toc-backref" href="#disabling-ensurepip-by-downstream-distributors" role="doc-backlink">Disabling ensurepip by Downstream Distributors</a></h2> <p>Due to its use in the <code class="docutils literal notranslate"><span class="pre">venv</span></code> module, downstream distributors cannot disable the <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> module in Python 3.4. However, since Python 2.7 has no such module it is explicitly allowed for downstream distributors to patch the <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> module to prevent it from installing anything.</p> <p>If a downstream distributor wishes to disable <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code> completely in Python 2.7, they should still at least provide the module and allow <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">ensurepip</span></code> style invocation. However it should raise errors or otherwise exit with a non-zero exit code and print out an error on stderr directing users to what they can/should use instead of <code class="docutils literal notranslate"><span class="pre">ensurepip</span></code>.</p> </section> <section id="references"> <h2><a class="toc-backref" href="#references" role="doc-backlink">References</a></h2> <aside class="footnote-list brackets"> <aside class="footnote brackets" id="six" role="doc-footnote"> <dt class="label" id="six">[<a href="#id1">1</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/six">six.py</a></aside> <aside class="footnote brackets" id="modernize" role="doc-footnote"> <dt class="label" id="modernize">[<a href="#id2">2</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/modernize">modernize</a></aside> <aside class="footnote brackets" id="future" role="doc-footnote"> <dt class="label" id="future">[<a href="#id3">3</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/future">python-future</a></aside> <aside class="footnote brackets" id="setuptools" role="doc-footnote"> <dt class="label" id="setuptools">[<a href="#id4">4</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/setuptools">setuptools</a></aside> <aside class="footnote brackets" id="wheel" role="doc-footnote"> <dt class="label" id="wheel">[<a href="#id5">5</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/wheel">Wheel</a></aside> <aside class="footnote brackets" id="twine" role="doc-footnote"> <dt class="label" id="twine">[<a href="#id6">6</a>]</dt> <dd><a class="reference external" href="https://pypi.python.org/pypi/twine">twine</a></aside> </aside> </section> <section id="copyright"> <h2><a class="toc-backref" href="#copyright" role="doc-backlink">Copyright</a></h2> <p>This document has been placed in the public domain.</p> </section> </section> <hr class="docutils" /> <p>Source: <a class="reference external" href="https://github.com/python/peps/blob/main/peps/pep-0477.rst">https://github.com/python/peps/blob/main/peps/pep-0477.rst</a></p> <p>Last modified: <a class="reference external" href="https://github.com/python/peps/commits/main/peps/pep-0477.rst">2025-02-01 08:55:40 GMT</a></p> </article> <nav id="pep-sidebar"> <h2>Contents</h2> <ul> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#automatic-invocation">Automatic Invocation</a></li> <li><a class="reference internal" href="#documentation">Documentation</a></li> <li><a class="reference internal" href="#disabling-ensurepip-by-downstream-distributors">Disabling ensurepip by Downstream Distributors</a></li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> <br> <a id="source" href="https://github.com/python/peps/blob/main/peps/pep-0477.rst">Page Source (GitHub)</a> </nav> </section> <script src="../_static/colour_scheme.js"></script> <script src="../_static/wrap_tables.js"></script> <script src="../_static/sticky_banner.js"></script> </body> </html>