Blender Developpment. Add a new library in source code


I’m actually working on an important project for a video game. For this project, I’m developing new functions in Blender source. One of this function is to make blender game engine able to connect a Postgresql database with Py-postgresql library. So I want to compile it in Blender source code so that it would be possible to call the module in Blender Game Engine like for bge or VideoTexture modules :

import bge
import postgresql

//then the code

I started to study this part of the source code, but it is really different as just developing new function.

Py-Postgresql is fully coded in Python, except a small part of the library which is developed in C.

Is there any documentation for python library integration in Blender 2.5 source code ?

You don’t have to include it in Blender Source. If you already have it as a stand-alone package you simply have to include it in one of the folders/files accessible from your blend files.

In some cases you can simply add it to the that comes with the Blender Binary.

Note: In order to use Blender 2.5 you need a Python Library compatible with Python 3.1.

When I put postgresql lib into blender2.53-beta/2.53/python/lib/python3.1 , there is an error in Blender. In the console editor, I enter

>>> import postgresql as pg

It works.
But then, if I do

>>> db ="pq://gangs:[email protected]/gangs_main")

Error :

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "/opt/blender2.53-beta/2.53/python/lib/python3.1/postgresql/", line 57, in open
    from . import driver as _pg_driver
  File "/opt/blender2.53-beta/2.53/python/lib/python3.1/postgresql/driver/", line 9, in <module>
    from .pq3 import Driver
  File "/opt/blender2.53-beta/2.53/python/lib/python3.1/postgresql/driver/", line 20, in <module>
    from .. import lib as pg_lib
ImportError: cannot import name lib

lib folder exists in postgresql. When I use py-postgresql directly in python (in linux), it works. It is as if something missing in Blender to use the library and I don’t know what. That’s why I want to compile the library directly in Blender source.