Skip to content

Commit 1a79ec7

Browse files
committed
Intro paras for Freezing and Packaging Your Code
I've tried to describe why you would choose one method over another, and what the relative advantages and disadvantages are of each method. I'm painfully aware that I haven't covered the combo of freezing an application *then* creating a Linux distro package of it, but maybe that's a battle for another day. My intent is to add more content on the Freezing page once this commit is accepted, so I can hear your feedback before doing any further work. Thanks.
1 parent da2f75b commit 1a79ec7

File tree

2 files changed

+90
-9
lines changed

2 files changed

+90
-9
lines changed

docs/shipping/freezing.rst

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
1+
.. _freezing-your-code-ref:
2+
3+
==================
14
Freezing Your Code
25
==================
36

4-
An alternative to shipping your code is freezing it — shipping it as an
5-
executable with a bundled Python interpreter.
7+
To 'Freeze' your code is to distribute to end-users as an executable which
8+
includes a bundled Python interpreter.
69

7-
Many applications you use every day do this:
10+
Applications such as 'Dropbox', BitTorrent clients, 'Eve Online' and
11+
'Civilisation IV' do this.
812

9-
- Dropbox
10-
- BitTorrent
11-
- ...
13+
The advantage of distributing this way is that your application will work even
14+
if the user doesn't already have the required version of Python installed. On
15+
Windows, and even on many Linux distributions and OSX versions, the right
16+
version of Python will not already be installed.
1217

13-
.. todo:: Fill in "Freezing Your Code" stub
18+
One disadvantage is that it will bloat your distribution by about 2Mb.
19+
Another problem is that your application, once downloaded by a user, will
20+
not receive any security updates to the version of Python it uses.
21+
22+
Alternatives to Freezing
23+
------------------------
1424

25+
:ref:`Packaging your code <packaging-your-code-ref>` is for distributing
26+
libraries or tools to other developers.
27+
28+
On Linux, an alternative to freezing is to
29+
:ref:`create a Linux distro package <packaging-for-linux-distributions-ref>`
30+
(e.g. a .deb file for Debian or Ubuntu.)
31+
32+
.. todo:: Fill in "Freezing Your Code" stub
1533

1634

1735
Comparison

docs/shipping/packaging.rst

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
1+
.. _packaging-your-code-ref:
2+
3+
===================
14
Packaging Your Code
25
===================
36

4-
Packaging your code is important.
7+
Package your code to share it with other developers. For example
8+
to share a library for other developers to use in their application,
9+
or for development tools like 'py.test'.
10+
11+
An advantage of this method of distribution is its well established ecosystem
12+
of tools such as PyPI and pip, which make it easy for other developers to
13+
download and install your package either for casual experiments, or as part of
14+
large, professional systems.
515

6-
You'll need to package your code first before sharing it with other developers.
16+
It is a well-established convention for Python code to be shared this way.
17+
If your code isn't packaged on PyPI, then it will be harder
18+
for other developers to find it, and to use it as part of their existing
19+
process. They will regard such projects with substantial suspicion of being
20+
either badly managed or abandoned.
21+
22+
The downside of distributing code like this is that it relies on the
23+
recipient understanding how to install the required version of Python,
24+
and being able and willing to use tools such as pip to install your code's
25+
other dependencies. This is fine when distributing to other developers, but
26+
makes this method unsuitable for distributing applications to end-uers.
727

828
The `Python Packaging Guide <https://python-packaging-user-guide.readthedocs.org/en/latest/>`_
929
provides an extensive guide on creating and maintaining Python packages.
1030

31+
Alternatives to Packaging
32+
:::::::::::::::::::::::::
33+
34+
To distribute applications to end-users, you should
35+
:ref:`freeze your application <freezing-your-code-ref>`.
36+
37+
On Linux, you may also want to consider
38+
:ref:`creating a Linux distro package <packaging-for-linux-distributions-ref>`
39+
(e.g. a .deb file for Debian or Ubuntu.)
40+
1141
For Python Developers
1242
:::::::::::::::::::::
1343

@@ -106,9 +136,42 @@ prerequisite for this is that you have an Amazon AWS account with an S3 bucket.
106136

107137
* You can now install your package with :code:`pip install --index-url=http://your-s3-bucket/packages/simple/ YourPackage`
108138

139+
.. _packaging-for-linux-distributions-ref:
140+
109141
For Linux Distributions
110142
::::::::::::::::::::::::
111143

144+
Creating a Linux distro package is arguably the "right way" to distribute code
145+
on Linux.
146+
147+
Because a distribution package doesn't include the Python interpreter, it
148+
makes the download and install about 2Mb smaller than
149+
:ref:`freezing your application <freezing-your-code-ref>`.
150+
151+
Also, if a distribution releases a new security update for Python, then your
152+
application will automatically start using that new version of Python.
153+
154+
However, creating and maintaining the different configurations required for
155+
each distribution's format (e.g. .deb for Debian/Ubuntu, .rpm for Red
156+
Hat/Fedora, etc) is a fair amount of work. If your code is an application that
157+
you plan to distribute on other platforms, then you'll also have to create and
158+
maintain the separate config required to freeze your application for Windows
159+
and OSX. It would be much less work to simply create and maintain a single
160+
config for one of the cross platform :ref:`freezing tools
161+
<freezing-your-code-ref>`, which will produce stand-alone executables for all
162+
distributions of Linux, as well as Windows and OSX.
163+
164+
Creating a distribution package is also problematic if your code is for a
165+
version of Python that isn't currently supported by a distribution.
166+
Having to tell *some versions* of Ubuntu end-users that they need to add `the
167+
'dead-snakes' PPA <https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes>`_
168+
using `sudo apt-repository` commands before they can install your .deb file
169+
makes for an extremely hostile user experience. Not only that, but you'd have
170+
to maintain a custom equivalent of these instructions for every distribution,
171+
and worse, have your users read, understand, and act on them.
172+
173+
Having said all that, here's how to do it:
174+
112175
* `Fedora <https://fedoraproject.org/wiki/Packaging:Python>`_
113176
* `Debian and Ubuntu <http://www.debian.org/doc/packaging-manuals/python-policy/>`_
114177
* `Arch <https://wiki.archlinux.org/index.php/Python_Package_Guidelines>`_

0 commit comments

Comments
 (0)