summaryrefslogtreecommitdiffstats
path: root/Doc/distributing/index.rst
blob: 9949553dde33f86aaf5ff4a31c7c3eb0aacc1b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
.. _distributing-index:

###############################
  Distributing Python Modules
###############################

:Email: distutils-sig@python.org


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.

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.

This guide covers the distribution part of the process. For a guide to
installing other Python projects, refer to the
:ref:`installation guide <installing-index>`.

.. note::

   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.


Key terms
=========

* the `Python Package Index <https://pypi.python.org/pypi>`__ is a public
  repository of open source licensed packages made available for use by
  other Python users
* the `Python Packaging Authority
  <http://packaging.python.org/en/latest/future.html>`__ 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 `GitHub <https://github.com/pypa>`__ and
  `BitBucket <https://bitbucket.org/pypa/>`__.
* ``distutils`` is the original build and distribution system first added to
  the Python standard library in 1998. While direct use of ``distutils`` 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).
* ``setuptools`` is a (largely) drop-in replacement for ``distutils`` first
  published in 2004. Its most notable addition over the unmodified
  ``distutils`` tools was the ability to declare dependencies on other
  packages. It is currently recommended as a more regularly updated
  alternative to ``distutils`` that offers consistent support for more
  recent packaging standards across a wide range of Python versions.
* ``wheel`` (in this context) is a project that adds the ``bdist_wheel``
  command to ``distutils``/``setuptools``. This produces a cross platform
  binary packaging format (called "wheels" or "wheel files" and defined in
  :pep:`427`) that allows Python libraries, even those including binary
  extensions, to be installed on a system without needing to be built
  locally.


Open source licensing and collaboration
=======================================

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.

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.

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.

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.


Installing the tools
====================

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.

The currently recommended build and distribution tools can be installed
by invoking the ``pip`` module at the command line::

    python -m pip install setuptools wheel twine

.. note::

   For POSIX users (including Mac OS X and Linux users), these instructions
   assume the use of a :term:`virtual environment`.

   For Windows users, these instructions assume that the option to
   adjust the system PATH environment variable was selected when installing
   Python.

The Python Packaging User Guide includes more details on the `currently
recommended tools`_.

.. _currently recommended tools: https://packaging.python.org/en/latest/current.html#packaging-tool-recommendations

Reading the guide
=================

The Python Packaging User Guide covers the various key steps and elements
involved in creating a project:

* `Project structure`_
* `Building and packaging the project`_
* `Uploading the project to the Python Package Index`_

.. _Project structure: \
   http://packaging.python.org/en/latest/tutorial.html#creating-your-own-project
.. _Building and packaging the project: \
   http://packaging.python.org/en/latest/tutorial.html#building-packaging-your-project
.. _Uploading the project to the Python Package Index: \
   http://packaging.python.org/en/latest/tutorial.html#uploading-your-project-to-pypi


How do I...?
============

These are quick answers or links for some common tasks.

... choose a name for my project?
---------------------------------

This isn't an easy topic, but here are a few tips:

* check the Python Package Index to see if the name is already in use
* check popular hosting sites like GitHub, BitBucket, etc to see if there
  is already a project with that name
* check what comes up in a web search for the name you're considering
* 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


... create and distribute binary extensions?
--------------------------------------------

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.

.. seealso::

   `Python Packaging User Guide: Binary Extensions
   <http://packaging.python.org/en/latest/extensions.html>`__

.. other topics:

   Once the Development & Deployment part of PPUG is fleshed out, some of
   those sections should be linked from new questions here (most notably,
   we should have a question about avoiding depending on PyPI that links to
   http://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches)