Packaging Python Project to Debian .deb Part 1
Packaging Python Project to Debian .deb Part 1
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 __init__.py for allowing the directory to be imported to python, and type our simple script.
$ cat > __init__.py
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()
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/python
from 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
Let’s install our project and test it by running: $ python setup.py install
Let’s try running it by calling it name: $ tvb hello_world
That’s it See you in the Next tutorial for Starting installing the development tools for Debian Packaging.