This will be mostly a self-note for the future, and from someone who packaged an application for the first time today. I did get it working though, so here’s how I did it. I will try to use the correct terms to refer to stuff, but please excuse any mistakes. This works in Linux, I didn’t test anything on Windows and Mac OS X.
The method I’ll present should work for any simple package with no obscure requirements. It will allow you to package an app in PyPI with some data files bundled, required dependencies and a script file so your users can run your code. It’ll also create a tarball with everything bundled inside. Your users will be a “pip install” away from running your code.
Let’s start with the directory structure and go over each file.
LICENSE - You should have a license. You can use WTFPL if you don’t care about such issues, or use something more restrictive like GPL or whatever, but license it. People won’t use your code if they don’t know that they can use it.
README - Write a description about your application, what it does, how to use it, how to contribute. Stuff.
MANIFEST.in - This file is used to auto generate another called MANIFEST (without the .in). You can use it for more things, I just use it to include extra files in the tarball. Example:
setup.py - This is the main configuration file. Example:
bin/appname - An executable file which will be placed in
/usr/local/bin so your users can call your application from anywhere. Example:
appname/\_\_init\_\_.py - This file is necessary so Python recognizes this directory as containing a package. You can leave it empty.
appname.py - Where your code lives. Make sure you have a
main() or equivalent, as called by the
data/ - Additional files. These can be images, config files, databases or whatever your application needs to function properly. There’s no requirement here, just make sure you add them correctly on
setup.py and on
Now that you have everything set up go over to PyPI, register yourself and run this in your command line:
Hopefully, if you typed everything correctly and I haven’t missed anything, your application will be packaged and uploaded to PyPI. Make sure you choose a name that’s available for your package!
I don’t claim this will work for more than my environment but it worked for me (Linux Ubuntu 11.04).
More information about packaging: