python-peps/pep-3149/index.html

426 lines
33 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 3149 ABI version tagged .so files | peps.python.org</title>
<link rel="shortcut icon" href="../_static/py.png">
<link rel="canonical" href="https://peps.python.org/pep-3149/">
<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 3149 ABI version tagged .so files | peps.python.org'>
<meta property="og:description" content="PEP 3147 described an extension to Pythons import machinery that improved the sharing of Python source code, by allowing more than one byte compilation file (.pyc) to be co-located with each source file.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://peps.python.org/pep-3149/">
<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="PEP 3147 described an extension to Pythons import machinery that improved the sharing of Python source code, by allowing more than one byte compilation file (.pyc) to be co-located with each source file.">
<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> &raquo; </li>
<li><a href="../pep-0000/">PEP Index</a> &raquo; </li>
<li>PEP 3149</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 3149 ABI version tagged .so files</h1>
<dl class="rfc2822 field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd">Barry Warsaw &lt;barry&#32;&#97;t&#32;python.org&gt;</dd>
<dt class="field-even">Status<span class="colon">:</span></dt>
<dd class="field-even"><abbr title="Accepted and implementation complete, or no longer active">Final</abbr></dd>
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><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-even">Created<span class="colon">:</span></dt>
<dd class="field-even">09-Jul-2010</dd>
<dt class="field-odd">Python-Version<span class="colon">:</span></dt>
<dd class="field-odd">3.2</dd>
<dt class="field-even">Post-History<span class="colon">:</span></dt>
<dd class="field-even">14-Jul-2010, 22-Jul-2010</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/2010-September/103408.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="#background">Background</a></li>
<li><a class="reference internal" href="#rationale">Rationale</a></li>
<li><a class="reference internal" href="#proposal">Proposal</a></li>
<li><a class="reference internal" href="#proven-approach">Proven approach</a></li>
<li><a class="reference internal" href="#windows">Windows</a></li>
<li><a class="reference internal" href="#pep-384">PEP 384</a></li>
<li><a class="reference internal" href="#alternatives">Alternatives</a><ul>
<li><a class="reference internal" href="#independent-directories-or-symlinks">Independent directories or symlinks</a></li>
<li><a class="reference internal" href="#don-t-share-packages-with-extension-modules">Dont share packages with extension modules</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reference-implementation">Reference implementation</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><a class="pep reference internal" href="../pep-3147/" title="PEP 3147 PYC Repository Directories">PEP 3147</a> described an extension to Pythons import machinery that
improved the sharing of Python source code, by allowing more than one
byte compilation file (.pyc) to be co-located with each source file.</p>
<p>This PEP defines an adjunct feature which allows the co-location of
extension module files (.so) in a similar manner. This optional,
build-time feature will enable downstream distributions of Python to
more easily provide more than one Python major version at a time.</p>
</section>
<section id="background">
<h2><a class="toc-backref" href="#background" role="doc-backlink">Background</a></h2>
<p><a class="pep reference internal" href="../pep-3147/" title="PEP 3147 PYC Repository Directories">PEP 3147</a> defined the file system layout for a pure-Python package,
where multiple versions of Python are available on the system. For
example, where the <code class="docutils literal notranslate"><span class="pre">alpha</span></code> package containing source modules <code class="docutils literal notranslate"><span class="pre">one.py</span></code>
and <code class="docutils literal notranslate"><span class="pre">two.py</span></code> exist on a system with Python 3.2 and 3.3, the post-byte
compilation file system layout would be:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">alpha</span><span class="o">/</span>
<span class="n">__pycache__</span><span class="o">/</span>
<span class="fm">__init__</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">32.</span><span class="n">pyc</span>
<span class="fm">__init__</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">33.</span><span class="n">pyc</span>
<span class="n">one</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">32.</span><span class="n">pyc</span>
<span class="n">one</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">33.</span><span class="n">pyc</span>
<span class="n">two</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">32.</span><span class="n">pyc</span>
<span class="n">two</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mf">33.</span><span class="n">pyc</span>
<span class="fm">__init__</span><span class="o">.</span><span class="n">py</span>
<span class="n">one</span><span class="o">.</span><span class="n">py</span>
<span class="n">two</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>For packages with extension modules, a similar differentiation is
needed for the modules .so files. Extension modules compiled for
different Python major versions are incompatible with each other due
to changes in the ABI. Different configuration/compilation options
for the same Python version can result in different ABIs
(e.g. with-wide-unicode).</p>
<p>While <a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a> defines a stable ABI, it will minimize, but not
eliminate extension module incompatibilities between Python builds or
major versions. Thus a mechanism for discriminating extension module
file names is proposed.</p>
</section>
<section id="rationale">
<h2><a class="toc-backref" href="#rationale" role="doc-backlink">Rationale</a></h2>
<p>Linux distributions such as Ubuntu <a class="footnote-reference brackets" href="#id9" id="id1">[3]</a> and Debian <a class="footnote-reference brackets" href="#id10" id="id2">[4]</a> provide more
than one Python version at the same time to their users. For example,
Ubuntu 9.10 Karmic Koala users can install Python 2.5, 2.6, and 3.1,
with Python 2.6 being the default.</p>
<p>In order to share as much as possible between the available Python
versions, these distributions install third party package modules
(<code class="docutils literal notranslate"><span class="pre">.pyc</span></code> and <code class="docutils literal notranslate"><span class="pre">.so</span></code> files) into <code class="docutils literal notranslate"><span class="pre">/usr/share/pyshared</span></code> and symlink to
them from <code class="docutils literal notranslate"><span class="pre">/usr/lib/pythonX.Y/dist-packages</span></code>. The symlinks exist
because in a pre-<a class="pep reference internal" href="../pep-3147/" title="PEP 3147 PYC Repository Directories">PEP 3147</a> world (i.e &lt; Python 3.2), the <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files
resulting from byte compilation by the various installed Pythons will
name collide with each other. For Python versions &gt;= 3.2, all
pure-Python packages can be shared, because the <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files will no
longer cause file system naming conflicts. Eliminating these symlinks
makes for a simpler, more robust Python distribution.</p>
<p>A similar situation arises with shared library extensions. Because
extension modules are typically named <code class="docutils literal notranslate"><span class="pre">foo.so</span></code> for a <code class="docutils literal notranslate"><span class="pre">foo</span></code> extension
module, these would also name collide if <code class="docutils literal notranslate"><span class="pre">foo</span></code> was provided for more
than one Python version.</p>
<p>In addition, because different configuration/compilation options for
the same Python version can cause different ABIs to be presented to
extension modules. On POSIX systems for example, the configure
options <code class="docutils literal notranslate"><span class="pre">--with-pydebug</span></code>, <code class="docutils literal notranslate"><span class="pre">--with-pymalloc</span></code>, and
<code class="docutils literal notranslate"><span class="pre">--with-wide-unicode</span></code> all change the ABI. This PEP proposes to
encode build-time options in the file name of the <code class="docutils literal notranslate"><span class="pre">.so</span></code> extension
module files.</p>
<p>PyPy <a class="footnote-reference brackets" href="#id11" id="id3">[5]</a> can also benefit from this PEP, allowing it to avoid name
collisions in extension modules built for its API, but with a
different <code class="docutils literal notranslate"><span class="pre">.so</span></code> tag.</p>
</section>
<section id="proposal">
<h2><a class="toc-backref" href="#proposal" role="doc-backlink">Proposal</a></h2>
<p>The configure/compilation options chosen at Python interpreter
build-time will be encoded in the shared library file name for
extension modules. This “tag” will appear between the module base
name and the operation file system extension for shared libraries.</p>
<p>The following information <em>MUST</em> be included in the shared library
file name:</p>
<ul class="simple">
<li>The Python implementation (e.g. cpython, pypy, jython, etc.)</li>
<li>The interpreters major and minor version numbers</li>
</ul>
<p>These two fields are separated by a hyphen and no dots are to appear
between the major and minor version numbers. E.g. <code class="docutils literal notranslate"><span class="pre">cpython-32</span></code>.</p>
<p>Python implementations <em>MAY</em> include additional flags in the file name
tag as appropriate. For example, on POSIX systems these flags will
also contribute to the file name:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">--with-pydebug</span></code> (flag: <code class="docutils literal notranslate"><span class="pre">d</span></code>)</li>
<li><code class="docutils literal notranslate"><span class="pre">--with-pymalloc</span></code> (flag: <code class="docutils literal notranslate"><span class="pre">m</span></code>)</li>
<li><code class="docutils literal notranslate"><span class="pre">--with-wide-unicode</span></code> (flag: <code class="docutils literal notranslate"><span class="pre">u</span></code>)</li>
</ul>
<p>By default in Python 3.2, <code class="docutils literal notranslate"><span class="pre">configure</span></code> enables <code class="docutils literal notranslate"><span class="pre">--with-pymalloc</span></code> so
shared library file names would appear as <code class="docutils literal notranslate"><span class="pre">foo.cpython-32m.so</span></code>.
When the other two flags are also enabled, the file names would be
<code class="docutils literal notranslate"><span class="pre">foo.cpython-32dmu.so</span></code>.</p>
<p>The shared library file name tag is used unconditionally; it cannot be
changed. The tag and extension module suffix are available through
the <code class="docutils literal notranslate"><span class="pre">sysconfig</span></code> modules via the following variables:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sysconfig</span><span class="o">.</span><span class="n">get_config_var</span><span class="p">(</span><span class="s1">&#39;EXT_SUFFIX&#39;</span><span class="p">)</span>
<span class="go">&#39;.cpython-32mu.so&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sysconfig</span><span class="o">.</span><span class="n">get_config_var</span><span class="p">(</span><span class="s1">&#39;SOABI&#39;</span><span class="p">)</span>
<span class="go">&#39;cpython-32mu&#39;</span>
</pre></div>
</div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">$SOABI</span></code> contains just the tag, while <code class="docutils literal notranslate"><span class="pre">$EXT_SUFFIX</span></code> includes the
platform extension for shared library files, and is the exact suffix
added to the extension module name.</p>
<p>For an arbitrary package <code class="docutils literal notranslate"><span class="pre">foo</span></code>, you might see these files when the
distribution package was installed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">python</span><span class="o">/</span><span class="n">foo</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mi">32</span><span class="n">m</span><span class="o">.</span><span class="n">so</span>
<span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">python</span><span class="o">/</span><span class="n">foo</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="mi">33</span><span class="n">m</span><span class="o">.</span><span class="n">so</span>
</pre></div>
</div>
<p>(These paths are for example purposes only. Distributions are free to
use whatever filesystem layout they choose, and nothing in this PEP
changes the locations where from-source builds of Python are
installed.)</p>
<p>Pythons dynamic module loader will recognize and import shared
library extension modules with a tag that matches its build-time
options. For backward compatibility, Python will also continue to
import untagged extension modules, e.g. <code class="docutils literal notranslate"><span class="pre">foo.so</span></code>.</p>
<p>This shared library tag would be used globally for all distutils-based
extension modules, regardless of where on the file system they are
built. Extension modules built by means other than distutils would
either have to calculate the tag manually, or fallback to the
non-tagged <code class="docutils literal notranslate"><span class="pre">.so</span></code> file name.</p>
</section>
<section id="proven-approach">
<h2><a class="toc-backref" href="#proven-approach" role="doc-backlink">Proven approach</a></h2>
<p>The approach described here is already proven, in a sense, on Debian
and Ubuntu system where different extensions are used for debug builds
of Python and extension modules. Debug builds on Windows also already
use a different file extension for dynamic libraries, and in fact
encoded (in a different way than proposed in this PEP) the Python
major and minor version in the <code class="docutils literal notranslate"><span class="pre">.dll</span></code> file name.</p>
</section>
<section id="windows">
<h2><a class="toc-backref" href="#windows" role="doc-backlink">Windows</a></h2>
<p>This PEP only addresses build issues on POSIX systems that use the
<code class="docutils literal notranslate"><span class="pre">configure</span></code> script. While Windows or other platform support is not
explicitly disallowed under this PEP, platform expertise is needed in
order to evaluate, describe, and implement support on such platforms.
It is not currently clear that the facilities in this PEP are even
useful for Windows.</p>
</section>
<section id="pep-384">
<h2><a class="toc-backref" href="#pep-384" role="doc-backlink">PEP 384</a></h2>
<p><a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a> defines a stable ABI for extension modules. In theory,
universal adoption of <a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a> would eliminate the need for this PEP
because all extension modules could be compatible with any Python
version. In practice of course, it will be impossible to achieve
universal adoption, and as described above, different build-time flags
still affect the ABI. Thus even with a stable ABI, this PEP may still
be necessary. While a complete specification is reserved for <a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a>,
here is a discussion of the relevant issues.</p>
<p><a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a> describes a change to <code class="docutils literal notranslate"><span class="pre">PyModule_Create()</span></code> where <code class="docutils literal notranslate"><span class="pre">3</span></code> is
passed as the API version if the extension was compiled with
<code class="docutils literal notranslate"><span class="pre">Py_LIMITED_API</span></code>. This should be formalized into an official macro
called <code class="docutils literal notranslate"><span class="pre">PYTHON_ABI_VERSION</span></code> to mirror <code class="docutils literal notranslate"><span class="pre">PYTHON_API_VERSION</span></code>. If
and when the ABI changes in an incompatible way, this version number
would be bumped. To facilitate sharing, Python would be extended to
search for extension modules with the <code class="docutils literal notranslate"><span class="pre">PYTHON_ABI_VERSION</span></code> number in
its name. The prefix <code class="docutils literal notranslate"><span class="pre">abi</span></code> is reserved for Pythons use.</p>
<p>Thus, an initial implementation of <a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a>, when Python is configured
with the default set of flags, would search for the following file
names when extension module <code class="docutils literal notranslate"><span class="pre">foo</span></code> is imported (in this order):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">foo</span><span class="o">.</span><span class="n">cpython</span><span class="o">-</span><span class="n">XYm</span><span class="o">.</span><span class="n">so</span>
<span class="n">foo</span><span class="o">.</span><span class="n">abi3</span><span class="o">.</span><span class="n">so</span>
<span class="n">foo</span><span class="o">.</span><span class="n">so</span>
</pre></div>
</div>
<p>The distutils <a class="footnote-reference brackets" href="#id12" id="id4">[6]</a> <code class="docutils literal notranslate"><span class="pre">build_ext</span></code> command would also have to be
extended to compile to shared library files with the <code class="docutils literal notranslate"><span class="pre">abi3</span></code> tag,
when the module author indicates that their extension supports that
version of the ABI. This could be done in a backward compatible way
by adding a keyword argument to the <code class="docutils literal notranslate"><span class="pre">Extension</span></code> class, such as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Extension</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;foo.c&#39;</span><span class="p">],</span> <span class="n">abi</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>Martin v. Löwis describes his thoughts <a class="footnote-reference brackets" href="#id13" id="id5">[7]</a> about the applicability of this
PEP to <a class="pep reference internal" href="../pep-0384/" title="PEP 384 Defining a Stable ABI">PEP 384</a>. In summary:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">--with-pydebug</span></code> would not be supported by the stable ABI because
this changes the layout of <code class="docutils literal notranslate"><span class="pre">PyObject</span></code>, which is an exposed
structure.</li>
<li><code class="docutils literal notranslate"><span class="pre">--with-pymalloc</span></code> has no bearing on the issue.</li>
<li><code class="docutils literal notranslate"><span class="pre">--with-wide-unicode</span></code> is trickier, though Martins inclination is
to force the stable ABI to use a <code class="docutils literal notranslate"><span class="pre">Py_UNICODE</span></code> that matches the
platforms <code class="docutils literal notranslate"><span class="pre">wchar_t</span></code>.</li>
</ul>
</section>
<section id="alternatives">
<h2><a class="toc-backref" href="#alternatives" role="doc-backlink">Alternatives</a></h2>
<p>In the initial python-dev thread <a class="footnote-reference brackets" href="#id14" id="id6">[8]</a> where this idea was first
introduced, several alternatives were suggested. For completeness
they are listed here, along with the reasons for not adopting them.</p>
<section id="independent-directories-or-symlinks">
<h3><a class="toc-backref" href="#independent-directories-or-symlinks" role="doc-backlink">Independent directories or symlinks</a></h3>
<p>Debian and Ubuntu could simply add a version-specific directory to
<code class="docutils literal notranslate"><span class="pre">sys.path</span></code> that would contain just the extension modules for that
version of Python. Or the symlink trick eliminated in <a class="pep reference internal" href="../pep-3147/" title="PEP 3147 PYC Repository Directories">PEP 3147</a> could
be retained for just shared libraries. This approach is rejected
because it propagates the essential complexity that <a class="pep reference internal" href="../pep-3147/" title="PEP 3147 PYC Repository Directories">PEP 3147</a> tries to
avoid, and adds potentially several additional directories to search
for all modules, even when the number of extension modules is much
fewer than the total number of Python packages. For example, builds
were made available both with and without wide unicode, with and
without pydebug, and with and without pymalloc, the total number of
directories search increases substantially.</p>
</section>
<section id="don-t-share-packages-with-extension-modules">
<h3><a class="toc-backref" href="#don-t-share-packages-with-extension-modules" role="doc-backlink">Dont share packages with extension modules</a></h3>
<p>It has been suggested that Python packages with extension modules not
be shared among all supported Python versions on a distribution. Even
with adoption of <a class="pep reference internal" href="../pep-3149/" title="PEP 3149 ABI version tagged .so files">PEP 3149</a>, extension modules will have to be compiled
for every supported Python version, so perhaps sharing of such
packages isnt useful anyway. Not sharing packages with extensions
though is infeasible for several reasons.</p>
<p>If a pure-Python package is shared in one version, should it suddenly
be not-shared if the next release adds an extension module for speed?
Also, even though all extension shared libraries will be compiled and
distributed once for every supported Python, theres a big difference
between duplicating the <code class="docutils literal notranslate"><span class="pre">.so</span></code> files and duplicating all <code class="docutils literal notranslate"><span class="pre">.py</span></code> files.
The extra size increases the download time for such packages, and more
immediately, increases the space pressures on already constrained
distribution CD-ROMs.</p>
</section>
</section>
<section id="reference-implementation">
<h2><a class="toc-backref" href="#reference-implementation" role="doc-backlink">Reference implementation</a></h2>
<p>Work on this code is tracked in a Bazaar branch on Launchpad <a class="footnote-reference brackets" href="#id15" id="id7">[9]</a>
until its ready for merge into Python 3.2. The work-in-progress diff
can also be viewed <a class="footnote-reference brackets" href="#id16" id="id8">[10]</a> and is updated automatically as new changes
are uploaded.</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="id9" role="doc-footnote">
<dt class="label" id="id9">[<a href="#id1">3</a>]</dt>
<dd>Ubuntu: &lt;<a class="reference external" href="http://www.ubuntu.com">http://www.ubuntu.com</a>&gt;</aside>
<aside class="footnote brackets" id="id10" role="doc-footnote">
<dt class="label" id="id10">[<a href="#id2">4</a>]</dt>
<dd>Debian: &lt;<a class="reference external" href="http://www.debian.org">http://www.debian.org</a>&gt;</aside>
<aside class="footnote brackets" id="id11" role="doc-footnote">
<dt class="label" id="id11">[<a href="#id3">5</a>]</dt>
<dd><a class="reference external" href="http://codespeak.net/pypy/dist/pypy/doc/">http://codespeak.net/pypy/dist/pypy/doc/</a></aside>
<aside class="footnote brackets" id="id12" role="doc-footnote">
<dt class="label" id="id12">[<a href="#id4">6</a>]</dt>
<dd><a class="reference external" href="http://docs.python.org/py3k/distutils/index.html">http://docs.python.org/py3k/distutils/index.html</a></aside>
<aside class="footnote brackets" id="id13" role="doc-footnote">
<dt class="label" id="id13">[<a href="#id5">7</a>]</dt>
<dd><a class="reference external" href="https://mail.python.org/pipermail/python-dev/2010-August/103330.html">https://mail.python.org/pipermail/python-dev/2010-August/103330.html</a></aside>
<aside class="footnote brackets" id="id14" role="doc-footnote">
<dt class="label" id="id14">[<a href="#id6">8</a>]</dt>
<dd><a class="reference external" href="https://mail.python.org/pipermail/python-dev/2010-June/100998.html">https://mail.python.org/pipermail/python-dev/2010-June/100998.html</a></aside>
<aside class="footnote brackets" id="id15" role="doc-footnote">
<dt class="label" id="id15">[<a href="#id7">9</a>]</dt>
<dd><a class="reference external" href="https://code.edge.launchpad.net/~barry/python/sovers">https://code.edge.launchpad.net/~barry/python/sovers</a></aside>
<aside class="footnote brackets" id="id16" role="doc-footnote">
<dt class="label" id="id16">[<a href="#id8">10</a>]</dt>
<dd><a class="reference external" href="https://code.edge.launchpad.net/~barry/python/sovers/+merge/29411">https://code.edge.launchpad.net/~barry/python/sovers/+merge/29411</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-3149.rst">https://github.com/python/peps/blob/main/peps/pep-3149.rst</a></p>
<p>Last modified: <a class="reference external" href="https://github.com/python/peps/commits/main/peps/pep-3149.rst">2023-09-09 17:39:29 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="#background">Background</a></li>
<li><a class="reference internal" href="#rationale">Rationale</a></li>
<li><a class="reference internal" href="#proposal">Proposal</a></li>
<li><a class="reference internal" href="#proven-approach">Proven approach</a></li>
<li><a class="reference internal" href="#windows">Windows</a></li>
<li><a class="reference internal" href="#pep-384">PEP 384</a></li>
<li><a class="reference internal" href="#alternatives">Alternatives</a><ul>
<li><a class="reference internal" href="#independent-directories-or-symlinks">Independent directories or symlinks</a></li>
<li><a class="reference internal" href="#don-t-share-packages-with-extension-modules">Dont share packages with extension modules</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reference-implementation">Reference implementation</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-3149.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>