Package: pypackager
PyPackager==========**Licence :** GPLv3**Source :** [GitHub Repository](https://github.com/khertan/pypackager)**Download (Maemo):** [PyPackager on Maemo Repository](http://maemo.org/packages/view/pypackager/)**Download (Meego):** [PyPackager on MeeGo Repository](http://repo.pub.meego.com/home:/khertan/Harmattan/armel/)**Bugs Tracker :** [PyPackager Bug Tracker](https://github.com/khertan/pypackager/issues)**Plateform :** Maemo Diablo, Maemo FremantlePyPackager is an onboard developpers tools which is usefull to create sourcesand binary Maemo package.![PyPackager Source screenshot](http://khertan.net/medias/pypackager.jpg)## PyPackager HowToOn the maemo platform, software is distributed using the Debian packagesystem. If you don't develop in Scratchbox, but directly on the device, youneed a tool to properly put together your software for distribution as such a.deb package. To solve this, i've created PyPackager. PyPackager 3.x.x is thesame as Py2Deb, except that with the same script you can prepare package to beuploaded to the extras maemo builder or build a debian package for maemodirectly on your device.## Install PyPackagerLast version of pypackager is available in Maemo Extras-devel, so you caninstall it with the application Manager.## PrerequisitesCreate a folder /myapp under your home folder (e.g. ”/home/user/myapp”). Thenadd the following files and folders: * A subfolder /src that contains all yoursource files in a folder structure which represents the way your app fileswill install on the device - and with the correct permissions set (so do notuse the fat partition ~/MyDocs)! * The icon for your software package (e.g.myapp.png, 48×48 pixels), the one that will be visible for your package in theapplication manager. * And the make.py file## programs and libraries with distutilsIf you want to package a python program or library that is set up correctlywith distutils, you can use$ python setup.py bdist_dumbto compile and generate a .tar.gz package in dist/ subdirectory. Just unpackthat package in the src/ folder and add the hildon desktop integration files(see below) there.## Example /src folder structureFiles needed for the Hildon desktop integration:/src/usr/share/applications/hildon/myapp.desktop/src/usr/share/dbus-1/services/myapp.service/src/usr/share/icons/hicolor/48x48/hildon/myapp.png/src/usr/share/icons/hicolor/scalable/hildon/myapp.png (64x64 pixel)## myapp.desktop file~~~~~~~~~~~~~~~~~~~~~~~~~~[Desktop Entry]Version=1.0.0Encoding=UTF-8Name=myAppComment=Clock & day/night mapExec=/opt/myApp/myApp.pyIcon=myappX-Icon-path=/usr/share/iconsX-Window-Icon=myappType=ApplicationX-Osso-Service=net.khertan.myappX-Osso-Type=application/x-executableStartupWMClass=myApp~~~~~~~~~~~~~~~~~~~~~~~~~~*Version* is version of the desktop file, NOT of the app. Keep it at 1.0.0*Name* is Name of the app as seen in Menu*Description* is Description of the app as seen as subtitle in Menu in Fingermode*Exec* is link to the app*Icon* is Name of our icon file, without the trailing .png part*X-Icon-path* is Path to the icon*X-Window-Icon* is Name of our icon file, without the trailing .png part*StartupWMClass* is only needed because if it programs use direct screenrendering librairy like PyGame, XLib or OpenGL.Note that you need the X-Osso-Service line only if you actually use ossoservices. Including that line in the .desktop file without proper handling ofosso events in the application will result in the application being terminatedshortly after startup.##myapp.service~~~~~~~~~~~~~~~~~~~~~~~~~~[D-BUS Service]Name=net.khertan.myappExec=/opt/myApp/myApp.py Link to the app~~~~~~~~~~~~~~~~~~~~~~~~~~## Files of the application itself~~~~~~~~~~~~~~~~~~~~~~~~~~/src/opt/myApp/src/opt/myApp/myApp.py/src/opt/myApp/myApp_other_class.py/src/opt/myApp/datas/myApp_image.png~~~~~~~~~~~~~~~~~~~~~~~~~~myApp.py should begin with:~~~~~~~~~~~~~~~~~~~~~~~~~~#!/usr/bin/env python~~~~~~~~~~~~~~~~~~~~~~~~~~and be executable## Setup the build_myapp.py codeCopy the following code to create your own build_myapp.py, then edit accordingto your needs:~~~~~~~~~~~~~~~~~~~~~~~~~~#!/usr/bin/python# -*- coding: utf-8 -*-## This program is free software; you can redistribute it and/or modify## it under the terms of the GNU General Public License as published## by the Free Software Foundation; version 2 only.#### This program is distributed in the hope that it will be useful,## but WITHOUT ANY WARRANTY; without even the implied warranty of## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the## GNU General Public License for more details.##import pypackagerimport osif __name__ == "__main__":try:os.chdir(os.path.dirname(sys.argv[0]))except:passp=pypackager.PyPackager("khteditor")p.version='0.0.1'p.buildversion='1'p.display_name='KhtEditor'p.description="KhtEditor is a source code editor specially designed for devices running Maemo and Meego Handset."p.author="Benoît HERVIER"p.maintainer="Khertan"p.email="khertan@khertan.net"p.depends = "python2.5-qt4-gui,python2.5-qt4-core, python2.5-qt4-maemo5"p.suggests = "pylint"p.section="user/development"p.arch="armel"p.urgency="low"p.bugtracker='http://khertan.net/flyspray/index.php?project=7'p.distribution="fremantle"p.repository="extras-devel"p.icon='khteditor.png'p["/usr/bin"] = ["khteditor_launch.py",]p["/usr/share/dbus-1/services"] = ["khteditor.service",]p["/usr/share/pixmaps"] = ["khteditor.png",]p["/usr/share/applications/hildon"] = ["khteditor.desktop",]#Specific flags for meegop.maemo_flags = 'visible'p.meego_desktop_entry_filename = ''p.createDigsigsums = Truep.aegisManifest = '''<aegis name="..."><provide></provide><constraint></constraint><account></account><request></request><domain></domain><docstring></docstring></aegis>'''files = []#Srcfor root, dirs, fs in os.walk('/home/user/MyDocs/Projects/khteditor/khteditor'):for f in fs:#print os.path.basename(root),dirs,fprefix = 'khteditor/'if os.path.basename(root) != 'khteditor':prefix = prefix + os.path.basename(root) + '/'files.append(prefix+os.path.basename(f))print filesp["/usr/lib/python2.5/site-packages"] = filesp.postinst = """#!/bin/shchmod +x /usr/bin/khteditor_launch.pypython -m compileall /usr/lib/python2.5/site-packages/khteditor"""p.changelog="""First Release"""print p.generate(build_binary=False,build_src=True)#print p.generate(build_binary=True,build_src=True)~~~~~~~~~~~~~~~~~~~~~~~~~~## Run your make.py codeOpen “X Terminal” on your device and change directory into your folder (e.g.“cd /home/user/myapp”). Then run your code using “python2.5 make.py” in Xterm.PyPackager will now package your files. Once this is done successfully,depending on build option your ~/myapp folder will contain new files ready tobe uploaded to Maemo Auto Builder or ready to be upload to your own repository* myapp_0.5.6-1.changes (the changelog)* myapp_0.5.6-1.dsc (the packagedescription)* myapp_0.5.6-1.tar.gz (the packed source files)This article is derivate from the [http://wiki.maemo.org/Py2Deb](http://wiki.maemo.org/Py2Deb) page.