Packaging Python Project to Debian .deb Part 1

Umar Haruna Abdullahi
3 min readFeb 11, 2018
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.

Soure: http://www.xappsoftware.com

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 __init__.py for allowing the directory to be imported to python, and type our simple script.

$ cat > __init__.pyfrom __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()
print(args.text)

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

$ cd .. && cat > tvb-neurodebian.py#!/usr/bin/env python
import tvb
tvb.main()

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

$ cat > setup.py#!/usr/bin/pythonfrom setuptools import setup__author__ = ‘Your Full Name’setup(
name=’tvb-neurodebian’,
version=’0.0.1',
description=’Simple Package(Example) for packaging Tvb to Debian’,
author=’Your Name’,
author_email=’Your Email’,
license=’GNU’,
url=’https://github.com/umarbrowser/Neuropackage',
packages=[‘tvb’],
entry_points={
‘console_scripts’: [
‘tvb=tvb:main’,
]
},
)

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 setup.py 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.

--

--

Umar Haruna Abdullahi

GSoC 2018 Student of The Virtual Brain under INCF organisation