< Getting Started | Build | KDE4 Revision as of 12:13, 25 October 2008 (view source)Pippin (talk | contribs) (→Short instructions: Add note about python-dbus)← Older edit Revision as of 07:30, 18 November 2008 (view source) Sedwards (talk | contribs) (updated version info)Newer edit → Line 11: Line 11: * Install Python into your kde svn install directory. * Install Python into your kde svn install directory. * Optionally install dbus-python to your kde svn install directory. * Optionally install dbus-python to your kde svn install directory. −* Install SIP. (use a [http://www.riverbankcomputing.com/software/sip/download snapshot from Riverbank])+* Install SIP. (use [http://www.riverbankcomputing.com/software/sip/download version 4.7.8 or later from Riverbank]) −* Install PyQt4. (use a [http://www.riverbankcomputing.com/software/pyqt/download snapshot from Riverbank])+* Install PyQt4. (use [http://www.riverbankcomputing.com/software/pyqt/download version 4.4.4 or later from Riverbank]) ==Longer instructions== ==Longer instructions== Revision as of 07:30, 18 November 2008 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. Contents 1 Short instructions 2 Longer instructions 3 Creating and Installing Python Plasmoids 3.1 Metadata in the .desktop File Short instructions Install and setup KDE from subversion. Build everything needed up to and including kdelibs. Install Python into your kde svn install directory. Optionally install dbus-python to your kde svn install directory. Install SIP. (use version 4.7.8 or later from Riverbank) Install PyQt4. (use version 4.4.4 or later 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. You may want to install dbus-python at this point to allow Python scripts to access D-Bus. 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 Plasmoids 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 The X-Plasma-API string specifies that the applet uses the python scriptengine. Retrieved from "https://techbase.kde.org/index.php?title=Getting_Started/Build/KDE4/Python_Support&oldid=35781" Content is available under Creative Commons License SA 4.0 unless otherwise noted.