Packaging Python Project to Debian .deb Part 1

Source: Debian Packaging

Hi, Have you ever try to package your code/project to became .deb or in official Debian or Ubuntu Repository to share to the rest of the world?

I have been one of you, it took me about three (3) weeks to figure out how to do it, i will tell you how i have done it.

I will split this into two Tutorials because it is to large to be complete in one tutorial.


We will begging by writing a simple python script with we will be packaging it letter.

Create a project directory and go to the created directory.

$ mkdir project_name && cd project_name

Create another directory inside the project name and move to the newly directory.

$ mkdir tvb && cd tvb

Now create a for allowing the directory to be imported to python, and type our simple script.

$ cat >
from __future__ import print_function
import argparse
print(‘The Virtual Brain imported!’)
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(‘text’, help=’Text to TVB-Neuropackage’)
return parser.parse_args()
def main():
print(‘This is the main function :)’)
args = parse_args()

No go back to our main directory and creat the tvb file.

$ cd .. && cat >
#!/usr/bin/env python
import tvb

Now we have to create a python setup script for local python install.

$ cat >
from setuptools import setup
__author__ = ‘Your Full Name’
description=’Simple Package(Example) for packaging Tvb to Debian’,
author=’Your Name’,
author_email=’Your Email’,
‘console_scripts’: [

Let us see our project files if you don’t have tree install you have to install it(optional) using $ sudo apt-get install -y tree && tree

Our Complete project with with files.
Let’s install our project and test it by running: $ python install
Our project being install.
Let’s try running it by calling it name: $ tvb hello_world
Wow Our project works.

That’s it See you in the Next tutorial for Starting installing the development tools for Debian Packaging.