Renatofilho (Talk | contribs) (→Building and installing from source) |
(→Installing from Ubuntu PPA) |
||
| Line 3: | Line 3: | ||
==== Installing from Ubuntu PPA ==== | ==== Installing from Ubuntu PPA ==== | ||
| - | + | If you are using Ubuntu then you can add PySide's ppa and get ''pyside-assistant'' from there: | |
| + | |||
| + | <nowiki> | ||
| + | sudo add-apt-repository ppa:pyside | ||
| + | sudo apt-get update | ||
| + | sudo apt-get install pyside-assistant | ||
| + | </nowiki> | ||
==== Building and installing from source ==== | ==== Building and installing from source ==== | ||
Contents |
If you are using Ubuntu then you can add PySide's ppa and get pyside-assistant from there:
sudo add-apt-repository ppa:pyside sudo apt-get update sudo apt-get install pyside-assistant
To build and install pyside-assistant you will need a Debian-based Linux distribution. First, install sharutils and python-stdeb packages, that are runtime dependencies of pyside-assistant. Get the source from the Github page, then in the directory which pyside-assistant was downloaded, run:
$ dpkg-buildpackage -D -rfakeroot -us -uc
Warning: Do not install python-stdeb from the git sources, or pyside-assistant will not work properly! The version from Debian and Ubuntu (0.6.0+20100620-1) works as expected.
Now go back a directory level and install the binary package:
$ sudo dpkg -i pyside-assistant_0.1-1_all.deb
The main script for using pyside-assistant is psa.
The init command creates a project from the templates. It receives as a mandatory argument a string that identifies the entire project, called project slug. The following call will create a project in the current directory with the project slug sampleproject:
$ psa init sampleproject
All project files will be contained in a directory named after the project slug, which in this case is sampleproject. Additional parameters can be passed to psa init to set various fields from the start; these parameters are shown below:
-a APPNAME, --app-name=APPNAME
Human-readable application name, refers to the Name field of sampleproject.desktop
-s SECTION, --section=SECTION
Application section, refers to the section field of stdeb.cfg
-d DESC, --description=DESC
Application short description, refers to the description field of setup.py
-c CATEGORY, --category=CATEGORY
Application category, refers to the appname field of sampleproject.desktop
The created projects come with a file called README.assistant, which lists what each file does. The contents of this file is listed below:
=========================================
README - pyside-assistant generated files
=========================================
All files generated by psa init are described below. The sampleproject
slug used for them was 'sampleproject', with the following psa call:
$ psa init sampleproject
* MANIFEST.in: Distutils considers a list of files by default for
installation, listed at [1]. Additional files to be distributed
must be supplied in the MANIFEST.in file. The generated file includes
the .desktop file and any QML files found.
[1] http://docs.python.org/distutils/sourcedist.html#specifying-the-files-to-distribute.
* setup.py: The main file for using Distutils, contains most of the
information needed to build the package. Information about setup.py
can be found at http://docs.python.org/distutils/introduction.html.
Two fields of this file can be modified by psa update parameters:
- description: -d or --description
- long_description: the contents of sampleproject.longdesc are used
* stdeb.cfg: Configuration file for stdeb, specifying additional
parameters for the binary package. The specification for this
file can be found at https://github.com/astraw/stdeb, in the section
stdeb.cfg configuration file. One field of this file can be modified by
psa update parameters:
- Section: -s or --section
Note that the section should be a valid one,
as specified in http://wiki.maemo.org/Task:Package_categories#New_list_for_Diablo.
* sampleproject.aegis: Sample credentials file, which initially is empty.
* sampleproject.desktop: This file specifies how to run the application
from the application grid, with various fields. Information about
.desktop files can be found at http://wiki.maemo.org/Desktop_file_format.
Two fields of this file can be modified by psa update parameters:
- Name: -a or --app-name
- Category: -c or --category
Note that the category should be a valid one, as specified in
http://standards.freedesktop.org/menu-spec/latest/apa.html.
* sampleproject.png: The application icon, which is displayed in the
application grid.
* sampleproject.qml: The QML file for the application. By default
just displays the words "Hello QML!" in the center of the window.
* sampleproject: Main program. Initializes the application and provide
support for displaying the QML file contents.
* sampleproject.longdesc: Holds the contents of the long_description field of
setup.py, which as the name implies is a more detailed description of what the project is.
The build-deb command does all necessary steps for generating a binary package. It essentially calls stdeb to build the proper Debian package and then places the application icons inside it. For using this command, you just have to enter the project directory and run:
$ psa build-deb
The binary package will be found under the ./deb_dist directory.
If you want to add credentials to your project, you have to edit the .aegis file, which initially is empty and thus ignored. After you write all the necessary credentials to the file it will be injected into the binary package the next time the build-deb command is called. More information about credentials can be found here
The update command can change certain values inside the project files, minimizing the need to open and edit them directly. This command accepts the following parameters:
-a APPNAME, --app-name=APPNAME
Human-readable application name, resides in sampleproject.desktop
-s SECTION, --section=SECTION
Application section, resides in stdeb.cfg
-d DESC, --description=DESC
Application short description, resides in setup.py
-c CATEGORY, --category=CATEGORY
Application category, resides in sampleproject.desktop
These parameters can be used in any order. As an example, to change the description and section of the project, run:
$ psa update -d "Sample project" -s games
$ psa init sampleproject $ cd sampleproject (... hack ...) $ psa build-deb (... copy binary package to destination and install it ...) (... hack some more ...) $ psa update -c AudioVideo -s graphics $ psa build-deb (and so on.)
pyside-assistant was initially conceived for creating PySide applications, but in fact it can be used to build binary packages for any pure Python application that uses Python Distutils.
For that purpose, follow these steps:
psa init as usual, to create the initial project layout;
From now on, the same workflow applies: modify files, build binary package with psa build-deb, update fields with psa update, and so on.