import os
import sys


def findFileInPaths(filename, searchPaths):
    for path in searchPaths:
        if os.path.isfile(os.path.join(path, filename)):
            return path


def _updateSysPath():

    libraries = [
                'vtkPCLFiltersPython.so',
                'vtkCommonPython.so',
                'vtk/__init__.py'
                ]

    buildDir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))

    searchPaths = []
    searchPaths.append(os.path.join(buildDir, 'PointCloudLibraryPlugin/lib'))
    searchPaths.append(os.path.join(buildDir, 'vtk/Wrapping/Python'))
    searchPaths.append(os.path.join(buildDir, 'vtk/bin'))

    for library in libraries:
        path = findFileInPaths(library, searchPaths)
        if path and path not in sys.path:
            sys.path.insert(0, path)
            continue


_updateSysPath()

@@ -351,20 +351,19 @@
 %5D%0A%0A    b
-uild
+ase
 Dir = os
@@ -428,16 +428,23 @@
 ../../..
+/../src
 '))%0A%0A   
@@ -494,28 +494,27 @@
 .path.join(b
-uild
+ase
 Dir, 'PointC
@@ -530,16 +530,22 @@
 ryPlugin
+-build
 /lib'))%0A
@@ -573,36 +573,35 @@
 d(os.path.join(b
-uild
+ase
 Dir, 'vtk/Wrappi
@@ -593,16 +593,22 @@
 ir, 'vtk
+-build
 /Wrappin
@@ -656,20 +656,19 @@
 h.join(b
-uild
+ase
 Dir, 'vt
@@ -668,16 +668,22 @@
 ir, 'vtk
+-build
 /bin'))%0A

update path to python extension dirs after change to superbuild locations