apt - debianzing a python program to get a .deb -


aim

to create installable .deb file(or package). when clicked install software on linux machine , icon put on gnome panel. launch application there.

what have referred to

i referred 2 debianizing guides.

guide 1

guide 2

the first 1 had video impossible understand, partly because of accent , partly because hopelessly outdated.(it uploaded in 2007)

and second 1 text. got till 4th step, builds package. when did got output did not match given in guide.

what require

i have simple python program. takes age , prints out if age below, equal to, or above 18 years. there 1 file , no other dependency program. , wanna build .deb.

specs

-python 2.7

-linux mint

edit

i followed exact directory structure instructed you. , replaced myscript cowsandbulls. build completed , got debian. when installed , ran command cowsandbulls terminal got following error:

traceback (most recent call last):   file "/usr/bin/cowsandbulls", line 9, in <module>     load_entry_point('cowsandbulls==1.0', 'gui_scripts', 'cowsandbulls')()   file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point     return get_distribution(dist).load_entry_point(group, name)   file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2311, in load_entry_point     return ep.load()   file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2017, in load     entry = __import__(self.module_name, globals(),globals(), ['__name__']) importerror: no module named cowsandbulls 

i tested stdeb (see https://pypi.python.org/pypi/stdeb ) python package turning other python package debian package.

first installed stdeb:

apt-get install python-stdeb 

then made simple script called myscript.py following contents:

def main():     print "hello world, says myscript!"     # wait input user     raw_input()  if __name__ == '__main__':     main() 

importantly, directory structure should be:

somewhere/myscript/     setup.py     myscript/         __init__.py         myscript.py 

in setup.py file, like:

import os setuptools import setup nvpy import nvpy  setup(     name = "myscript",     version = "1.0",     author = "charl p. botha",     author_email = "cpbotha@vxlabs.com",     description = "demo of packaging python script deb",     license = "bsd",     url = "https://github.com/cpbotha/nvpy",     packages=['myscript'],     entry_points = {         'console_scripts' : ['myscript = myscript.myscript:main']     },     data_files = [         ('share/applications/', ['vxlabs-myscript.desktop'])     ],     classifiers=[         "license :: osi approved :: bsd license",     ], ) 

the console_scripts directive important, it'll create executable script called my_script, available system-wide after install resultant deb. if script uses tkinter or wxpython , has graphical user interface, should use gui_scripts instead of console_scripts.

the data_files directive install suitable desktop file /usr/share/applications, can start myscript desktop environment. vxlabs-myscript.desktop looks this:

[desktop entry] version=1.0 type=application name=myscript comment=minimal stdeb example # myscript should wait user input @ end, else terminal # window disappear immediately. exec=myscript icon=/usr/share/icons/gnome/48x48/apps/file-manager.png categories=utility; # desktop should run in terminal application terminal=true startupnotify=true startupwmclass=myscript 

to build deb, following in top-level myscript:

python setup.py --command-packages=stdeb.command bdist_deb 

which create .deb in deb_dist directory.

after having installed deb created this, run myscript command-line, , invoke desktop environment.

here's github repo example code above: https://github.com/cpbotha/stdeb-minimal-example


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -