blob: 4bcb63351e56b0bdf38bf17c7cc3b26bed7a2f5e [file] [log] [blame]
Larry Hastings3732ed22014-03-15 21:13:56 -07001.. _distributing-index:
2
3###############################
4 Distributing Python Modules
5###############################
6
7:Email: distutils-sig@python.org
8
9
10As a popular open source development project, Python has an active
11supporting community of contributors and users that also make their software
12available for other Python developers to use under open source license terms.
13
14This allows Python users to share and collaborate effectively, benefiting
15from the solutions others have already created to common (and sometimes
16even rare!) problems, as well as potentially contributing their own
17solutions to the common pool.
18
19This guide covers the distribution part of the process. For a guide to
20installing other Python projects, refer to the
21:ref:`installation guide <installing-index>`.
22
23.. note::
24
25 For corporate and other institutional users, be aware that many
26 organisations have their own policies around using and contributing to
27 open source software. Please take such policies into account when making
28 use of the distribution and installation tools provided with Python.
29
30
31Key terms
32=========
33
34* the `Python Package Index <https://pypi.python.org/pypi>`__ is a public
35 repository of open source licensed packages made available for use by
36 other Python users
37* the `Python Packaging Authority
38 <http://packaging.python.org/en/latest/future.html>`__ are the group of
39 developers and documentation authors responsible for the maintenance and
40 evolution of the standard packaging tools and the associated metadata and
41 file format standards. They maintain a variety of tools, documentation
42 and issue trackers on both `GitHub <https://github.com/pypa>`__ and
43 `BitBucket <https://bitbucket.org/pypa/>`__.
44* ``distutils`` is the original build and distribution system first added to
45 the Python standard library in 1998. While direct use of ``distutils`` is
46 being phased out, it still laid the foundation for the current packaging
47 and distribution infrastructure, and it not only remains part of the
48 standard library, but its name lives on in other ways (such as the name
49 of the mailing list used to coordinate Python packaging standards
50 development).
Nick Coghlane1d54e52014-05-26 00:50:11 +100051* ``setuptools`` is a (largely) drop-in replacement for ``distutils`` first
Zachary Ware66f305b2014-06-05 13:41:06 -050052 published in 2004. Its most notable addition over the unmodified
Nick Coghlane1d54e52014-05-26 00:50:11 +100053 ``distutils`` tools was the ability to declare dependencies on other
54 packages. It is currently recommended as a more regularly updated
55 alternative to ``distutils`` that offers consistent support for more
56 recent packaging standards across a wide range of Python versions.
57* ``wheel`` (in this context) is a project that adds the ``bdist_wheel``
58 command to ``distutils``/``setuptools``. This produces a cross platform
59 binary packaging format (called "wheels" or "wheel files" and defined in
60 :pep:`427`) that allows Python libraries, even those including binary
61 extensions, to be installed on a system without needing to be built
62 locally.
Larry Hastings3732ed22014-03-15 21:13:56 -070063
64
65Open source licensing and collaboration
66=======================================
67
68In most parts of the world, software is automatically covered by copyright.
69This means that other developers require explicit permission to copy, use,
70modify and redistribute the software.
71
72Open source licensing is a way of explicitly granting such permission in a
73relatively consistent way, allowing developers to share and collaborate
74efficiently by making common solutions to various problems freely available.
75This leaves many developers free to spend more time focusing on the problems
76that are relatively unique to their specific situation.
77
78The distribution tools provided with Python are designed to make it
79reasonably straightforward for developers to make their own contributions
80back to that common pool of software if they choose to do so.
81
82The same distribution tools can also be used to distribute software within
83an organisation, regardless of whether that software is published as open
84source software or not.
85
86
87Installing the tools
88====================
89
90The standard library does not include build tools that support modern
91Python packaging standards, as the core development team has found that it
92is important to have standard tools that work consistently, even on older
93versions of Python.
94
95The currently recommended build and distribution tools can be installed
96using ``pip``::
97
98 pip install setuptools wheel twine
99
Nick Coghlane1d54e52014-05-26 00:50:11 +1000100The Python Packaging User Guide includes more details on the `currently
101recommended tools`_.
102
103.. _currently recommended tools: https://packaging.python.org/en/latest/current.html#packaging-tool-recommendations
Larry Hastings3732ed22014-03-15 21:13:56 -0700104
105Reading the guide
106=================
107
108The Python Packaging User Guide covers the various key steps and elements
Nick Coghlane1d54e52014-05-26 00:50:11 +1000109involved in creating a project:
Larry Hastings3732ed22014-03-15 21:13:56 -0700110
111* `Project structure`_
112* `Building and packaging the project`_
113* `Uploading the project to the Python Package Index`_
114
115.. _Project structure: \
116 http://packaging.python.org/en/latest/tutorial.html#creating-your-own-project
117.. _Building and packaging the project: \
118 http://packaging.python.org/en/latest/tutorial.html#building-packaging-your-project
119.. _Uploading the project to the Python Package Index: \
120 http://packaging.python.org/en/latest/tutorial.html#uploading-your-project-to-pypi
121
122
123How do I...?
124============
125
126These are quick answers or links for some common tasks.
127
128... choose a name for my project?
129---------------------------------
130
131This isn't an easy topic, but here are a few tips:
132
133* check the Python Package Index to see if the name is already in use
134* check popular hosting sites like GitHub, BitBucket, etc to see if there
135 is already a project with that name
136* check what comes up in a web search for the name you're considering
137* avoid particularly common words, especially ones with multiple meanings,
138 as they can make it difficult for users to find your software when
139 searching for it
140
141
142... create and distribute binary extensions?
143--------------------------------------------
144
145This is actually quite a complex topic, with a variety of alternatives
146available depending on exactly what you're aiming to achieve. See the
147Python Packaging User Guide for more information and recommendations.
148
149.. seealso::
150
151 `Python Packaging User Guide: Binary Extensions
152 <http://packaging.python.org/en/latest/extensions.html>`__
153
154.. other topics:
155
156 Once the Development & Deployment part of PPUG is fleshed out, some of
157 those sections should be linked from new questions here (most notably,
158 we should have a question about avoiding depending on PyPI that links to
159 http://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches)