< Getting Started | Build | KDE4Revision as of 21:25, 24 October 2008 by 184.108.40.206 (talk | contribs) (Some clues on building and packaging python applets)(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff) Note: This page refers to building and installing KDE Python support from KDE subversion trunk during the KDE 4.2 development cycle and may not apply to other versions of KDE. (Situation from 23 October 2008) Installing Python bindings and support directly from KDE trunk in subversion is a little bit tricky, mainly due to the stack of dependencies which need to be built up first. Please note that most of the time there is little reason to install and run the Python bindings and support directly from subversion. If you are an application developer then just use the packages from your distribution. Running from subversion generally doesn't get you early access to new functionality in kdelibs etc because the bindings are only updated around the end of KDE's development cycle. That being said, running from subversion will get you access to the new Python support in Plasma and also the new bindings for Marble. Short instructions: Install and setup KDE from subversion. Build everything needed up to and including kdelibs. Install Python into your kde svn install directory. Install SIP. (use a snapshot from Riverbank) Install PyQt4. (use a snapshot from Riverbank) Longer instructions: First step, get your KDE subversion install / environment setup and build and install kdelibs. The standard Python interpreter has a site-packages directory inside its installation directory which is where system wide Python modules are installed. This is how Python finds modules when you import them in your program. Unfortunately Python traditionally does not have a per-user site-packages directory where private copies of modules can be installed, although I believe support for this has been added in the new 2.6 release. This means to we need our own Python installation into which we can install PyQt, PyKDE and friends. Download and install a new Python 2.5 ("Other platforms" -> "bzip2-compressed source") into the same install prefix as your KDE trunk install. After building and installation, the new python should be the first one on your $PATH. Make sure you build Python with shared libraries enabled. "./configure --prefix=/home/kde-devel/kde --enable-shared" seems to be sufficient, although you might want more options and do not forget to change your install prefix. A couple of important bugs have been fixed in SIP. Grab the SIP snapshot from Riverbank Computing and unpack the archive somewhere. Running "python configure.py", answering 'yes' or something and then letting run, and then running "make" and "make install" should be enough to get it installed. Grab a PyQt4 snapshot from Riverbank Computing and do the same things a SIP to build and install it. A snapshot is needed to fix at least one bug which affects Plasma. With those dependencies in place building kdebindings is a matter of checking out the code and running your 'cmakekde' command. It should then find Python, build and install. Now you have a working PyKDE4 install which supports kdelibs and a whole bunch of other related libraries like soprano, nepomuk etc. Now you can check out and build kdebase. It should detect the KDE Python support and automatically build the Python script engine. Creating and Installing Python Applets In order to create and install an applet written using the Python scriptengine, you package it into a specially crafted zip file and install it using the "plasmapkg" tool, which should come with your plasma from kdebase. The directorystructure looks as follows py-applet/metadata.desktop py-applet/contents/code/main.py py-applet/contents/code/morecode.py To create the package zip the directory recursively. $ cd py-applet/ $ zip -r ../py-applet.zip . (Don't create the zip file inside the directory you're zipping.) Then install the created plasma package with $ plasmapkg -i py-applet.zip You can remove it using $ plasmapkg -r py-applet Metadata in the .desktop File The metadata for your applet is specified in the .desktop File. Here's an example of the python clock applet. [Desktop Entry] Encoding=UTF-8 Name=Python Clock Type=Service ServiceTypes=Plasma/Applet X-Plasma-API=python Icon=chronometer X-KDE-PluginInfo-Author=Simon Edwards [email protected] X-KDE-PluginInfo-Name=plasma-pyclock X-KDE-PluginInfo-Version=1.0 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-Category=Examples X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true Retrieved from "https://techbase.kde.org/index.php?title=Getting_Started/Build/KDE4/Python_Support&oldid=34733" Category: Pages with syntax highlighting errors Content is available under Creative Commons License SA 4.0 unless otherwise noted.