Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As of January 2017, all of the other answers to this question are at least two years out-of-date. When you come across advice on Python packaging issues, remember to look at the date of publication, and don't trust out-of-date information.</p> <p>The <a href="https://packaging.python.org/" rel="noreferrer">Python Packaging User Guide</a> is worth a read. Every page has a "last reviewed" date displayed, so you can check the recency of the manual, and it's quite comprehensive. The fact that it's hosted on a subdomain of python.org of the Python Software Foundation just adds credence to it. The <a href="https://packaging.python.org/key_projects/" rel="noreferrer">Project Summaries</a> page is especially relevant here.</p> <h2>Summary of tools:</h2> <p>Here's a summary of the Python packaging landscape in January 2017:</p> <h3>Supported tools:</h3> <ul> <li><p><strong>Distutils</strong> is still the standard tool for packaging in Python. It is included in the standard library (Python 2 and Python 3.0 to 3.6). It is useful for simple Python distributions, but lacks features. It introduces the <code>distutils</code> Python package that can be imported in your <code>setup.py</code> script.</p> <ul> <li><sub><a href="https://docs.python.org/3/library/distutils.html" rel="noreferrer">Official docs</a> | <a href="https://packaging.python.org/key_projects/#distutils" rel="noreferrer"><code>distutils</code> section of Python Package User Guide</a></sub></li> </ul></li> <li><p><strong>Setuptools</strong> was developed to overcome Distutils' limitations, and is not included in the standard library. It introduced a command-line utility called <code>easy_install</code>. It also introduced the <code>setuptools</code> Python package that can be imported in your <code>setup.py</code> script, and the <code>pkg_resources</code> Python package that can be imported in your code to locate data files installed with a distribution. One of its gotchas is that it monkey-patches the <code>distutils</code> Python package. It should work well with <code>pip</code>. <a href="https://github.com/pypa/setuptools/releases" rel="noreferrer">It sees regular releases.</a></p> <ul> <li><sub><a href="https://setuptools.readthedocs.io/en/latest/" rel="noreferrer">Official docs</a> | <a href="https://pypi.python.org/pypi/setuptools" rel="noreferrer">Pypi page</a> | <a href="https://github.com/pypa/setuptools" rel="noreferrer">GitHub repo</a> | <a href="https://packaging.python.org/key_projects/#setuptools" rel="noreferrer"><code>setuptools</code> section of Python Package User Guide</a></sub></li> </ul></li> <li><p><strong>scikit-build</strong> is an improved build system generator that internally uses CMake to build compiled Python extensions. Because scikit-build isn't based on distutils, it doesn't really have any of its limitations. When ninja-build is present, scikit-build can compile large projects over three times faster than the alternatives. It should work well with <code>pip</code>. <a href="https://github.com/scikit-build/scikit-build/releases" rel="noreferrer">It sees regular releases.</a></p> <ul> <li><sub><a href="http://scikit-build.readthedocs.io/en/latest/" rel="noreferrer">Official docs</a> | <a href="https://pypi.org/project/scikit-build/" rel="noreferrer">Pypi page</a> | <a href="https://github.com/scikit-build/scikit-build" rel="noreferrer">GitHub repo</a></sub></li> </ul></li> </ul> <h3>Deprecated/abandoned tools:</h3> <ul> <li><p><strong>Distribute</strong> was a fork of Setuptools. It shared the same namespace, so if you had Distribute installed, <code>import setuptools</code> would actually import the package distributed with Distribute. <strong><em>Distribute was merged back into Setuptools 0.7</em></strong>, so you don't need to use Distribute any more. In fact, the version on Pypi is just a compatibility layer that installs Setuptools.</p></li> <li><p><strong>Distutils2</strong> was an attempt to take the best of Distutils, Setuptools and Distribute and become the standard tool included in Python's standard library. The idea was that Distutils2 would be distributed for old Python versions, and that Distutils2 would be renamed to <code>packaging</code> for Python 3.3, which would include it in its standard library. These plans did not go as intended, however, and currently, <strong><em>Distutils2 is an abandoned project</em></strong>. The latest release was in March 2012, and its Pypi home page has finally been updated to reflect its death.</p></li> </ul> <h3>Alpha software:</h3> <ul> <li><p><strong>Distlib</strong> is a tool that aims to implement a subset of the previous tools' functionality, but only functionality that is very well-defined in accepted PEPs. It is one of the tools of the PyPA (Python Package Authority), and it should hopefully be included eventually in the Python standard library someday. <strong><em>It is still considered alpha software, so end-users beware.</em></strong></p> <ul> <li><sub><a href="http://pythonhosted.org/distlib/" rel="noreferrer">Official docs</a> | <a href="https://pypi.python.org/pypi/distlib" rel="noreferrer">Pypi page</a> | <a href="https://bitbucket.org/vinay.sajip/distlib" rel="noreferrer">Bitbucket repo</a> | <a href="https://packaging.python.org/key_projects/#distlib" rel="noreferrer"><code>distlib</code> section of Python Package User Guide</a></sub></li> </ul></li> <li><p>There are <a href="https://packaging.python.org/key_projects/" rel="noreferrer">a couple more tools</a> (eg: Bento), but I won't mention them as they are too obscure or niche or early or undeveloped for this answer post, or else they're not direct alternatives.</p></li> </ul> <h2>Recommendation:</h2> <p>So in conclusion, out of all these options, <strong>I would recommend Setuptools</strong>, unless your requirements are very basic and you only need Distutils. Setuptools works very well with Virtualenv and Pip, tools that I highly recommend. Virtualenv and Pip could both be considered official, as they're part of PyPA, and Python 3 now ships <a href="https://docs.python.org/3/library/ensurepip.html" rel="noreferrer"><code>ensurepip</code></a> (which helps you install <code>pip</code> on some systems).</p> <p>If you're looking into Virtualenv, you might be interested in this question: <a href="https://stackoverflow.com/q/41573587/247696">What is the difference between <code>venv</code>, <code>pyvenv</code>, <code>pyenv</code>, <code>virtualenv</code>, <code>virtualenvwrapper</code>, etc?</a>. (Yes, I know, I groan with you.)</p> <p>As a side-note, I recommend using Virtualenv 1.10 or higher, as it is the first release that recognises the Setuptools/Distribute merger, for both Python 2 and 3.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload