LuxBlend25 Debugging with eclipse - LuxRender Wiki
Luxrender GPL Physically Based Renderer

LuxBlend25 Debugging with eclipse

Personal tools

From LuxRender Wiki

Revision as of 19:26, 23 September 2011 by Homer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To make the development of LuxBlend25 easier, this is a step by step tutorial which describe the setup of Eclipse IDE with Python development and setup the luxblend25 exporter project in Eclipse to debug within Blender.

The steps are done under Windows Vista 64Bit, but it should be straight forward and also doable under Linux and Mac OSX. The Blender version 2.59 is used, which has a buildin Python 3.2 version.



ECLIPSE_INSTALL_PATH = the path where Eclipse IDE is installed/extracted (f.e. c:\eclipse)
PYTHON32_PATH = the path where Python 3.2 is installed (f.e. c:\python32)
BLENDER259_PATH = the base path of Blender 2.59 (f.e. c:\blender_259)
PYDEV_SOURCE_PATH = the path of the pydev debugger python source (this is depending on where your eclipse plugins are installed, f.e. "ECLIPSE_INSTALL_PATH/plugins/org.python.pydev.debug_2.2.2.2011090200/pysrc")

Italic Text means a menu, option, drop down or input field
Bold Text means a selected option, or typed in text

Setup Eclipse

To use a relative new build of Eclipse IDE, I downloaded the eclipse IDE from the website: Eclipse Downloads. In my case i used the Eclipse Classic 3.7 Windows 32Bit version.
After downloading, extract the archive to the harddisk to ECLIPSE_INSTALL_PATH.

First Start of Eclipse

During the 1st Start of Eclipse you where asked for a Workspace, you can use the default or select your own path with write access.


PyDev is a Eclipse plugin for Python development, which can use the official python interpreter

Install Python 3.2

Download the Python installation package from Python Download (I used the Python 3.2.2 Windows X86-64 MSI Installer). For Linux or Mac OSX look for the distribution/vendor packages for Python 3.2. Run the installation and install Python 3.2 to PYTHON32_PATH.

Install PyDev

Start your Eclipse IDE and go to Help->Install New Software...
In the upcoming dialog click on Add... to add a new installation repository for PyDev.
Enter PyDev in to the "Name" and into the "Location" fields, then click OK.
Your newly created installation repository is now selected automatically and after the Pending... you can mark PyDev for installation.
Install the Plugin with hitting Next > a few times (you have to accept the license and signature of the plugin).
At the end you have to restart your Eclipse IDE

Setup PyDev

To setup PyDev go to Window Preferences
In the Preferences dialog open PyDev and select Interpreter - Python
Click on New..., enter Python 3.2 into the Interpreter Name and Browse... to the python.exe in your PYTHON32_PATH
Click on OK 2 times which should configure the python interpreter and its paths.
Now we have a full Python IDE

The LuxBlend25 Project

I assume you have the LuxBlend25 source installed or checked out correctly under your "BLENDER259_PATH/2.59/scripts/addons/luxrender"

Create the Project

Now go to File->New->Project... to open the New Project Wizard.
Select PyDev->PyDev Project
Type in luxblend25 as the Project name
Uncheck the Use default option and Browse to the path of luxblend25 (BLENDER259_PATH/2.59/scripts/addons/luxrender)
Choose Python as the Project type
Switch Grammar Version to 3.0
Select Default Interpreter
Select Add project directory to PYTHONPATH?
Click on Finish

Additional Project properties

Now we have to setup some properties on our project:
Right click on the project in the 'PyDev PackageExplorer window and select Properties
Select PyDev - PYTHONPATH on the left side and switch to External Libraries on the right side.
Now we add several source paths for out python modules with Add source folder:

  • BLENDER259_PATH/2.59/scripts/addons
  • BLENDER259_PATH/2.59/scripts/addons/modules
  • BLENDER259_PATH/2.59/scripts/modules
  • BLENDER259_PATH/2.59/scripts/addons/startup

Click on OK

Debugging LuxBlend25

To debug the LuxBlend25 python code several things must be prepared.

Create Blender Launch configuration

Go to Run->External Tools->External Tools Configuration...
Right click on Program and select New to add a new Launch configuration
Typ in Blender for Name and select the path to blender executable under Location (f.e. BLENDER259_PATH/blender.exe)
Set the Working Directory to BLENDER259_PATH
You can add optional parameters to the blender executable under the Main tab (f.e. open a testing .blend file directly)
Now click on Apply then on Close

Test this launch configuration by click on the Run... Toolbar icon (the one with the red toolbox). If you have done it correctly then blender starts up. You can close blender for now.

Modifying the luxblend25 code

To enable debugging we have to do a little modification to luxblend25 python code. Maybe later this is in the source repositories.

Add ./

First we add a new file in the luxblend25 base directory "BLENDER259_PATH/2.59/scripts/addons/luxrender" called

# -*- coding: utf8 -*-
# --------------------------------------------------------------------------
# Blender 2.5 LuxRender Add-On
# --------------------------------------------------------------------------
# Authors:
# Doug Hammond
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <>.

	This file is for debugging
	To make the pydevd working, set the directory of pydevd source
import sys

# set the PYDEV_SOURCE_DIR correctly before using the debugger
PYDEV_SOURCE_DIR = 'X:\eclipse\plugins\org.python.pydev.debug_2.2.2.2011090200\pysrc'

def startdebug():
	if DEBUGGING == True:
		# test if PYDEV_SOURCE_DIR already in sys.path, otherwise append it
		if sys.path.count(PYDEV_SOURCE_DIR) < 1:
		# import pydevd module
		import pydevd
		# set debugging enabled
		pydevd.settrace(None, True, True, 5678, False, False)

!!! ATTENTION: watch the python indenting!!!
Setup the path in the line PYDEV_SOURCE_DIR = '...' to the PYDEV_SOURCE_PATH

Modify ./

Now add to following lines after the bl_info struct to BLENDER259_PATH/2.59/scripts/addons/luxrender/

from . import luxdebug

Modify ./core/

Because the render process itself is started from Blender in a different thread
And add some code into BLENDER259_PATH/2.59/scripts/addons/luxrender/core/
Before all other imports:


from .. import luxdebug

At the begining of the render function:

def render(self, scene): luxdebug.startdebug() .

Add Break Points

To add Breakpoints in the code simply right click on the vertical grey bar on the left side of the code editor and select Add Breakpoint'

Launch Debug Server and Blender

Now after we have setup all what we need we can start debugging

Open Debug Perspective in Eclipse

Go to Window->Open Perspective->Other... and select Debug. Now we have the Debug Perspective enabled

Start the Python Debug Server

In the tool bar there is a tool button for the Python Debug Server (little P with a Bug sign) which says: PyDev: start pydev server click on it to start the debug server. In the console you should see. Debug Server at port: 5678

Start Blender

Now its time to start Blender (see: Create Blender Launch configuration) and hope we hit our breakpoints. If a breakpoint is hit, we see the strack trace in the Debug Window and the Variables in the (x)=Variables Window.