326 lines
19 KiB
HTML
326 lines
19 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<title>Distributing Python Modules — Python 3.7.4 documentation</title>
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||
|
||
<script type="text/javascript" src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="Search within Python 3.7.4 documentation"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="About these documents" href="../about.html" />
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
||
<link rel="next" title="Installing Python Modules" href="../installing/index.html" />
|
||
<link rel="prev" title="API and ABI Versioning" href="../c-api/apiabiversion.html" />
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
|
||
<link rel="canonical" href="https://docs.python.org/3/distributing/index.html" />
|
||
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/switchers.js"></script>
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
|
||
|
||
</head><body>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="../installing/index.html" title="Installing Python Modules"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="../c-api/apiabiversion.html" title="API and ABI Versioning"
|
||
accesskey="P">previous</a> |</li>
|
||
<li><img src="../_static/py.png" alt=""
|
||
style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li>
|
||
<span class="language_switcher_placeholder">en</span>
|
||
<span class="version_switcher_placeholder">3.7.4</span>
|
||
<a href="../index.html">Documentation </a> »
|
||
</li>
|
||
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" style="display: none" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" type="text" name="q" />
|
||
<input type="submit" value="Go" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
<script type="text/javascript">$('.inline-search').show(0);</script>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<div class="section" id="distributing-python-modules">
|
||
<span id="distributing-index"></span><h1>Distributing Python Modules<a class="headerlink" href="#distributing-python-modules" title="Permalink to this headline">¶</a></h1>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Email</dt>
|
||
<dd class="field-odd"><p><a class="reference external" href="mailto:distutils-sig%40python.org">distutils-sig<span>@</span>python<span>.</span>org</a></p>
|
||
</dd>
|
||
</dl>
|
||
<p>As a popular open source development project, Python has an active
|
||
supporting community of contributors and users that also make their software
|
||
available for other Python developers to use under open source license terms.</p>
|
||
<p>This allows Python users to share and collaborate effectively, benefiting
|
||
from the solutions others have already created to common (and sometimes
|
||
even rare!) problems, as well as potentially contributing their own
|
||
solutions to the common pool.</p>
|
||
<p>This guide covers the distribution part of the process. For a guide to
|
||
installing other Python projects, refer to the
|
||
<a class="reference internal" href="../installing/index.html#installing-index"><span class="std std-ref">installation guide</span></a>.</p>
|
||
<div class="admonition note">
|
||
<p class="admonition-title">Note</p>
|
||
<p>For corporate and other institutional users, be aware that many
|
||
organisations have their own policies around using and contributing to
|
||
open source software. Please take such policies into account when making
|
||
use of the distribution and installation tools provided with Python.</p>
|
||
</div>
|
||
<div class="section" id="key-terms">
|
||
<h2>Key terms<a class="headerlink" href="#key-terms" title="Permalink to this headline">¶</a></h2>
|
||
<ul class="simple">
|
||
<li><p>the <a class="reference external" href="https://pypi.org">Python Packaging Index</a> is a public
|
||
repository of open source licensed packages made available for use by
|
||
other Python users</p></li>
|
||
<li><p>the <a class="reference external" href="https://www.pypa.io/">Python Packaging Authority</a> are the group of
|
||
developers and documentation authors responsible for the maintenance and
|
||
evolution of the standard packaging tools and the associated metadata and
|
||
file format standards. They maintain a variety of tools, documentation
|
||
and issue trackers on both <a class="reference external" href="https://github.com/pypa">GitHub</a> and
|
||
<a class="reference external" href="https://bitbucket.org/pypa/">BitBucket</a>.</p></li>
|
||
<li><p><a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> is the original build and distribution system first added
|
||
to the Python standard library in 1998. While direct use of <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a>
|
||
is being phased out, it still laid the foundation for the current packaging
|
||
and distribution infrastructure, and it not only remains part of the
|
||
standard library, but its name lives on in other ways (such as the name
|
||
of the mailing list used to coordinate Python packaging standards
|
||
development).</p></li>
|
||
<li><p><a class="reference external" href="https://setuptools.readthedocs.io/en/latest/">setuptools</a> is a (largely) drop-in replacement for <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> first
|
||
published in 2004. Its most notable addition over the unmodified
|
||
<a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> tools was the ability to declare dependencies on other
|
||
packages. It is currently recommended as a more regularly updated
|
||
alternative to <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> that offers consistent support for more
|
||
recent packaging standards across a wide range of Python versions.</p></li>
|
||
<li><p><a class="reference external" href="https://wheel.readthedocs.io/">wheel</a> (in this context) is a project that adds the <code class="docutils literal notranslate"><span class="pre">bdist_wheel</span></code>
|
||
command to <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a>/<a class="reference external" href="https://setuptools.readthedocs.io/en/latest/">setuptools</a>. This produces a cross platform
|
||
binary packaging format (called “wheels” or “wheel files” and defined in
|
||
<span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0427"><strong>PEP 427</strong></a>) that allows Python libraries, even those including binary
|
||
extensions, to be installed on a system without needing to be built
|
||
locally.</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="open-source-licensing-and-collaboration">
|
||
<h2>Open source licensing and collaboration<a class="headerlink" href="#open-source-licensing-and-collaboration" title="Permalink to this headline">¶</a></h2>
|
||
<p>In most parts of the world, software is automatically covered by copyright.
|
||
This means that other developers require explicit permission to copy, use,
|
||
modify and redistribute the software.</p>
|
||
<p>Open source licensing is a way of explicitly granting such permission in a
|
||
relatively consistent way, allowing developers to share and collaborate
|
||
efficiently by making common solutions to various problems freely available.
|
||
This leaves many developers free to spend more time focusing on the problems
|
||
that are relatively unique to their specific situation.</p>
|
||
<p>The distribution tools provided with Python are designed to make it
|
||
reasonably straightforward for developers to make their own contributions
|
||
back to that common pool of software if they choose to do so.</p>
|
||
<p>The same distribution tools can also be used to distribute software within
|
||
an organisation, regardless of whether that software is published as open
|
||
source software or not.</p>
|
||
</div>
|
||
<div class="section" id="installing-the-tools">
|
||
<h2>Installing the tools<a class="headerlink" href="#installing-the-tools" title="Permalink to this headline">¶</a></h2>
|
||
<p>The standard library does not include build tools that support modern
|
||
Python packaging standards, as the core development team has found that it
|
||
is important to have standard tools that work consistently, even on older
|
||
versions of Python.</p>
|
||
<p>The currently recommended build and distribution tools can be installed
|
||
by invoking the <code class="docutils literal notranslate"><span class="pre">pip</span></code> module at the command line:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">setuptools</span> <span class="n">wheel</span> <span class="n">twine</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="admonition note">
|
||
<p class="admonition-title">Note</p>
|
||
<p>For POSIX users (including Mac OS X and Linux users), these instructions
|
||
assume the use of a <a class="reference internal" href="../glossary.html#term-virtual-environment"><span class="xref std std-term">virtual environment</span></a>.</p>
|
||
<p>For Windows users, these instructions assume that the option to
|
||
adjust the system PATH environment variable was selected when installing
|
||
Python.</p>
|
||
</div>
|
||
<p>The Python Packaging User Guide includes more details on the <a class="reference external" href="https://packaging.python.org/guides/tool-recommendations/#packaging-tool-recommendations">currently
|
||
recommended tools</a>.</p>
|
||
</div>
|
||
<div class="section" id="reading-the-python-packaging-user-guide">
|
||
<span id="publishing-python-packages"></span><span id="index-1"></span><h2>Reading the Python Packaging User Guide<a class="headerlink" href="#reading-the-python-packaging-user-guide" title="Permalink to this headline">¶</a></h2>
|
||
<p>The Python Packaging User Guide covers the various key steps and elements
|
||
involved in creating and publishing a project:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/distributing-packages/">Project structure</a></p></li>
|
||
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/distributing-packages/#packaging-your-project">Building and packaging the project</a></p></li>
|
||
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi">Uploading the project to the Python Packaging Index</a></p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="how-do-i">
|
||
<h2>How do I…?<a class="headerlink" href="#how-do-i" title="Permalink to this headline">¶</a></h2>
|
||
<p>These are quick answers or links for some common tasks.</p>
|
||
<div class="section" id="choose-a-name-for-my-project">
|
||
<h3>… choose a name for my project?<a class="headerlink" href="#choose-a-name-for-my-project" title="Permalink to this headline">¶</a></h3>
|
||
<p>This isn’t an easy topic, but here are a few tips:</p>
|
||
<ul class="simple">
|
||
<li><p>check the Python Packaging Index to see if the name is already in use</p></li>
|
||
<li><p>check popular hosting sites like GitHub, BitBucket, etc to see if there
|
||
is already a project with that name</p></li>
|
||
<li><p>check what comes up in a web search for the name you’re considering</p></li>
|
||
<li><p>avoid particularly common words, especially ones with multiple meanings,
|
||
as they can make it difficult for users to find your software when
|
||
searching for it</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="create-and-distribute-binary-extensions">
|
||
<h3>… create and distribute binary extensions?<a class="headerlink" href="#create-and-distribute-binary-extensions" title="Permalink to this headline">¶</a></h3>
|
||
<p>This is actually quite a complex topic, with a variety of alternatives
|
||
available depending on exactly what you’re aiming to achieve. See the
|
||
Python Packaging User Guide for more information and recommendations.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><a class="reference external" href="https://packaging.python.org/guides/packaging-binary-extensions/">Python Packaging User Guide: Binary Extensions</a></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Distributing Python Modules</a><ul>
|
||
<li><a class="reference internal" href="#key-terms">Key terms</a></li>
|
||
<li><a class="reference internal" href="#open-source-licensing-and-collaboration">Open source licensing and collaboration</a></li>
|
||
<li><a class="reference internal" href="#installing-the-tools">Installing the tools</a></li>
|
||
<li><a class="reference internal" href="#reading-the-python-packaging-user-guide">Reading the Python Packaging User Guide</a></li>
|
||
<li><a class="reference internal" href="#how-do-i">How do I…?</a><ul>
|
||
<li><a class="reference internal" href="#choose-a-name-for-my-project">… choose a name for my project?</a></li>
|
||
<li><a class="reference internal" href="#create-and-distribute-binary-extensions">… create and distribute binary extensions?</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="../c-api/apiabiversion.html"
|
||
title="previous chapter">API and ABI Versioning</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="../installing/index.html"
|
||
title="next chapter">Installing Python Modules</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This Page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.7/Doc/distributing/index.rst"
|
||
rel="nofollow">Show Source
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="../installing/index.html" title="Installing Python Modules"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="../c-api/apiabiversion.html" title="API and ABI Versioning"
|
||
>previous</a> |</li>
|
||
<li><img src="../_static/py.png" alt=""
|
||
style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li>
|
||
<span class="language_switcher_placeholder">en</span>
|
||
<span class="version_switcher_placeholder">3.7.4</span>
|
||
<a href="../index.html">Documentation </a> »
|
||
</li>
|
||
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" style="display: none" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" type="text" name="q" />
|
||
<input type="submit" value="Go" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
<script type="text/javascript">$('.inline-search').show(0);</script>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation.
|
||
<br />
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
Last updated on Jul 13, 2019.
|
||
<a href="../bugs.html">Found a bug</a>?
|
||
<br />
|
||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.0.1.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |