Packaging python script to Debian follows strict instructions, using the following instructions, most of the steps can be skipped hence making it easy and fast.
If you like video go to https://www.youtube.com/watch?v=a9GzDZB5VeU. This video doesn't show setup.py file creating which is required, but excluding that portion everything is same as below.
Lets convert this mymood.py into deb package.
Dont create the above structure, it will be created as you go through below steps.
1. Creating mymood and its sub directories:
2. Setting up mymood/mymood directory:
Goto mymood/mymood directory and paste mymood.py script as shown in project structure.
Within mymood/mymood create __init__.py
Within mymood/mymood directory create command_line.py. setup.py needs this to run script from bash just by typing mymood.
copy the following into command_line.py
3. Python's setup.py file creation:
Create a setup.py file in mymood directory as shown in project structure above.
The below code is simple and minimal setup.py for mymood, copy and change as you require.
Console scripts is used to run the script from terminal. So from bash you can just type mymood and run the script.
4.Setting up debian directory
Devscripts package is needed to create changelog file.
Now edit the file as follows:
5. Create copyright, compat, control and rules files in debian directory.
the control file looks like:
So this file lists dependencies, package description. The description is of two types, short and long.
Short is "simple mood checker' and the long 'mymood is a simple mood checker. It analyze the mood by simple questions'.
In the long description it should not exceed 80characters per line.
The rules file:
Note that you have python2 or python3 based on your script, dont just put python.
Also not that you use tab before dh, not spaces
The other files can be left empty.
6. Finally lets create a deb package.
Goto mymood top level direcotry and build package.
$fakeroot dpkg-buildpackage -b
This should create the following structure:
As you can see we get mymood_1.0_all.deb package wich can be installed by "ubuntu software center".
Ubuntu Software Center is recomended as it automatically installs dependencies
Most of the above steps are from http://fosshelp.blogspot.in/2014/04/how-to-create-debian-package-for-python.html
Video for the above fosshelp blog post: https://www.youtube.com/watch?v=a9GzDZB5VeU.