Packaging


Python’s first mainstream package was the .egg file. Now there’s a new format in town called the Wheel (*.whl). A wheel “is designed to contain all the files for a PEP 376 compatible install in a way that is very close to the on-disk format”. In this article, we will learn how to create a wheel and then install our wheel in a virtualenv. (more…)

Today we’re going to learn about one of wxPython’s newer features: wx.lib.softwareupdate. It was actually added a couple of years ago. What this allows you to do is add update abilities to your software. As far as I can tell, this mixin only allows prompted updates, not silent updates.

Getting Started

It’s built into wxPython 2.9, so you’ll need that if you want to follow along. The software update feature actually uses the Esky project. If you’re on Windows, you’ll also need py2exe. If you’re on Mac, then you’ll need py2app. We’ll be using the code from one of my previous articles for this demonstration. I created two versions of an Image Viewer, so you’ll want to grab that code as well. Note that we’ll be showing how to do this on Windows only! (more…)

Pip Installs Python or pip is a tool for installing and managing Python packages, many of which are on the Python Package Index (PyPI). It is a replacement of easy_install. In this article, we’ll spend a little time trying out pip to see how it works and how it might help us in our Python endeavors. (more…)

Today we’re going to take a look at the controversial easy_install method of installing Python modules and packages. We will also learn how to create our own *.egg files. You will need to go get the SetupTools package to follow along. This package doesn’t support Python 3.x so if you need that, see pip or distribute. There will be articles on each of those projects in the future. For now, we’ll be starting with SetupTools and easy_install.

Why is it controversial? I’m not completely certain, but people were not happy with the way it would partially install packages because it doesn’t wait for the download to finish. Also I’ve heard that the author wasn’t very interested in updating it but wouldn’t allow anyone else to update it either. See the Ziade article at the end of this post.

SetupTools is the original mainstream method of downloading and installing Python packages from PyPI and other sources via the command line, kind of like apt-get for Python. When you install SetupTools, it installs a script or exe called easy_install that you can invoke on the command line to install or upgrade packages. It also provides a way to create Python eggs. Let’s spend a little time getting to know this utility. (more…)

Last time we learned how to create modules and packages. Today we’re going to take the package we created and use Python’s distutils to create a couple different ways to distribute our code. In this tutorial, we’ll be learning the following:

  • How to create a setup.py file
  • How to create a source distribution
  • How to create a Windows distribution

Let’s get started! (more…)

This is the last article of my “Build a Binary Series”. If you haven’t done so already, be sure to check out the others. For our finale, we are to look at Andrea Gavana’s wxPython-based GUI2Exe, a nice graphical user interface to py2exe, bbfreeze, cx_Freeze, PyInstaller and py2app. The latest release of GUI2Exe is 0.5.0, although the source may be slightly newer. Feel free to run from the tip as well. We’ll be using the example scripts that we used for several of the previous articles: one console and one GUI script, neither of which do much of anything. (more…)

The bbfreeze package also allows us to create binaries, but only on Linux and Windows. It’s just an easy_install away, so if you plan on following along with the examples in the article, you should go get it. The bbfreeze package includes egg support, so it can include egg dependencies in your binary, unlike py2exe. You can also freeze multiple scripts at once, include the Python interpreter and more. According to bbfreeze’s PyPI entry, it’s only been tested with Python 2.4-2.5, so keep that in mind. However, I was able to use it with Python 2.6 with no obvious problems. (more…)

In this article, we will be learning about cx_Freeze, a cross-platform set of scripts designed to “freeze” Python scripts into executables in a manner similar to py2exe, PyInstaller, etc. We will freeze one console script and one window (i.e GUI) script, using the examples from the previous article in this series. If you haven’t done so already, you can get cx_Freeze here. Let’s get this party started, shall we? (more…)

In our previous article on building binaries, we learned a little about py2exe. This time around, we will be focusing our collective attention on the ins and outs of PyInstaller. We’ll use the same lame wxPython script from the last article for one of our examples, but we’ll also try a normal console script to see what the differences are, if any. In case you didn’t know, PyInstaller works on Linux, Windows and Mac (experimental) and works with Python 1.5-2.6 (except on Windows, where there’s a caveat for 2.6 – see below). PyInstaller supports code-signing (Windows), eggs, hidden imports, single executable, single directory, and lots more! (more…)

I received a request to create an article on how to use py2exe and wxPython to create an executable. I decided to do a series on packaging instead. It is my intention to go over the major Windows binary building utilities and show you, dear reader, how to use them to create a binary that you can distribute. Once those articles are done, I’ll show how to use Inno and NSIS. To kick things off, we’ll go over how to use py2exe, probably the most popular of the Windows executable packages. (more…)