Archive for the ‘Python’ Category

Building Boost.Python 1.42 for QNX 6.4.1

June 8, 2010

Building the Boost C++ libraries (http://boost.org/) for QNX is pretty straight forward. The build can be executed as described in the Boost documentation. I have performed the build of Boost 1.42 using QNX 6.4.1 installed in a virtual machine.

But there was a little tweak required to build the Boost.Python library. The problem is that python is located in /usr/qnx641/host/qnx6/x86/usr/bin/python but the required Python include files like Python.h are located in /usr/qnx641/target/qnx6/usr/include/python2.5. This setup is confusing the automatic detection of the include files used in the build process.

This can be fixed by providing the right include path, e.g by adding the following line to the file <boost_src_dir>/project-config.jam:

using python : 2.5 : /usr/qnx641/host/qnx6/x86/usr/bin/python : /usr/qnx641/target/qnx6/usr/include/python2.5 ;

Advertisements

Loading a Python module fails with the message “unknown symbol”

August 28, 2008

Using the import statement of Python to load a self build module sometimes fails. In my personal experience most of the time the problem was due to unresolved symbols in my .so modules. For QNX and many other POSIX compatible systems like GNU/Linux Python uses dlopen to load the dynamic libraries aka modules.

(more…)

PyDev – One of my favorite plugins for Eclipse

August 28, 2008

While programming in Python I use most of the time the Python perspective provided by the PyDev plug in for Eclipse. PyDev is the abbreviation of Python Development Environment and available from http://pydev.sourceforge.net/index.html. This post outlines the steps installing PyDev and the Python lint pylint.

(more…)

Debugger is failing to start with a time out

August 28, 2008

In case you get only this information in the view of Eclipse or Momentics IDE named Debug:

Thread[0] 1 <symbol is not available>

The corresponding source is displayed as:

No source available for “”

[View Disassembly …]

The launch of the target is terminated by a time out.

(more…)

Often used pkgsrc commands

August 14, 2008

This my memo where I store the commands I’m using when building packages with pkgsrc (http://www.netbsd.org/docs/software/packages.html).

Determining the package dependencies:
$ bmake show-depends-pkgpath

Finding build references to a given package, e.g. libdrm:
$ egrep ‘libdrm|xf86driproto’ */*/buildlink3.mk

All the available targets are documented in The pkgsrc make target reference – NetBSD Wiki.

This is used to rebuild a patched package:
bmake distinfo && bmake clean && bmake build

The following builds and install the package:
bmake distinfo && bmake clean && bmake package

QNX specific issues are discussed in the forum http://community.qnx.com/sf/discussion/do/listTopics/projects.pkgsrc/discussion.general.

Generating the Python docs on a Ubuntu GNU/Linux box

December 4, 2007

The first thing is to checkout the Python and doctools directories from the subversion repositories:

$ svn co http://svn.python.org/projects/python/trunk python
$ svn co http://svn.python.org/projects/doctools/trunk doctools

To install the required tools, as suggested from the doctools/README, I added the following packages:

# apt-get install python-pygments python-docutils

These are the steps really generating the documentation:

$ cd doctools
$ mkdir build-html
$ python sphinx-build.py -b html ../python/Doc build-html

Open the files generated in build-html, e.g. build-html/index.html, using file->open using your favorite web browser.

Everything works pretty straight forward as described in the doctools/README file.

Technorati Tags: , , , ,

Modify a read only tuple

December 4, 2007

Using tuples is very handy because of their flexibility and speed. But there is a drawback. Assigning a single item to a tuple does not work and results in a

 TypeError: object doesn't support item assignment

Appending to the tuple does not work, too. The reason is that tuples are immutable (read only) data structures (http://docs.python.org/lib/typesseq-mutable.html). The trick was provided at http://ada.rg16.asn-wien.ac.at/~python/ how2think/english/chap09.htm: replace the old read-only tuple with the new one where two tuples are concatenated:


>>> tuple = ('a', 'b', 'c', 'd', 'e')
>>> tuple[0]
'a'
>>> tuple[0] = 'A'
TypeError: 'tuple' object does not support item assignment
>>> tuple.append('A')
AttributeError: 'tuple' object has no attribute 'append'
>>> tuple = ('A',) + tuple[1:]
>>> tuple
('A', 'b', 'c', 'd', 'e')

Technorati Tags:

Example for creating a compressed file using Python

November 30, 2007

This example shows that the same methods can be used to writing a normal text file and a compressed file. Corresponding reading functions are provided, too.

(more…)