Ejemplo n.º 1
0
    def get(self):
        self.source_dir = os.path.join(
                config.WRAPITK_SOURCE_DIR, 
                'ExternalProjects', 'PyBuffer')
        
        if not os.path.exists(self.source_dir):
            utils.error("itkPyBuffer source not available.  Have you executed "
                        "the WrapITK InstallPackage?")

        else:
            pass

            if False:
                # make sure that ENABLE_TESTING() in the CMakeLists.txt has been
                # deactivated
                repls = [('ENABLE_TESTING\(\)', '')]
                utils.re_sub_filter_file(
                    repls,
                    os.path.join(self.source_dir,'CMakeLists.txt'))

                # and also disable inclusing of Wrapping/Python/Testing dir
                # this will probably change in future versions of itkPyBuffer
                repls = [('SUBDIRS\(Tests\)', '')]
                utils.re_sub_filter_file(
                    repls,
                    os.path.join(self.source_dir,
                                 'Wrapping/Python/CMakeLists.txt'))
Ejemplo n.º 2
0
    def configure_posix(self):
        os.chdir(self.build_dir)

        if os.path.exists("dcmdata/config.log"):
            utils.output("DCMTK already configured.  Not redoing.")
        else:
            # we need to configure this without zlib, otherwise dcmtk
            # complains (at least on this system) about the symbol
            # inflateEnd not being available.
            ret = os.system('./configure --without-zlib '
                            '--prefix=%s' % \
                            (self.inst_dir,))
            if ret != 0:
                utils.error('Could not configure dcmtk.  Fix and try again.')

            # now modify the generated config/Makefile.def to enable
            # building shared libraries as per
            # http://forum.dcmtk.org/viewtopic.php?t=19
            repls = [('(^CFLAGS\s*=\s*)-O', '\\1-fPIC -O2'),
                     ('(^CXXFLAGS\s*=\s*)-O', '\\1-fPIC -O2'),
                     ('(^AR\s*=\s*)ar', '\\1gcc'),
                     ('(^ARFLAGS\s*=\s*)cruv', '\\1-shared -o'),
                     ('(^LIBEXT\s*=\s*)a', '\\1so'),
                     ('(^RANLIB\s*=\s*)ranlib', '\\1:')]

            utils.re_sub_filter_file(repls, 'config/Makefile.def')
Ejemplo n.º 3
0
    def configure_posix(self):
        os.chdir(self.build_dir)

        if os.path.exists("dcmdata/config.log"):
            utils.output("DCMTK already configured.  Not redoing.")
        else:
            # we need to configure this without zlib, otherwise dcmtk
            # complains (at least on this system) about the symbol
            # inflateEnd not being available.
            ret = os.system("./configure --without-zlib " "--prefix=%s" % (self.inst_dir,))
            if ret != 0:
                utils.error("Could not configure dcmtk.  Fix and try again.")

            # now modify the generated config/Makefile.def to enable
            # building shared libraries as per
            # http://forum.dcmtk.org/viewtopic.php?t=19
            repls = [
                ("(^CFLAGS\s*=\s*)-O", "\\1-fPIC -O2"),
                ("(^CXXFLAGS\s*=\s*)-O", "\\1-fPIC -O2"),
                ("(^AR\s*=\s*)ar", "\\1gcc"),
                ("(^ARFLAGS\s*=\s*)cruv", "\\1-shared -o"),
                ("(^LIBEXT\s*=\s*)a", "\\1so"),
                ("(^RANLIB\s*=\s*)ranlib", "\\1:"),
            ]

            utils.re_sub_filter_file(repls, "config/Makefile.def")
Ejemplo n.º 4
0
    def install(self):
        # to test for install, just do python -c "import matplotlib"
        # and test the result (we could just import directly, but that would
        # only work once our invoking python has been stopped and started
        # again)
        os.chdir(config.archive_dir) # we need to be elsewhere!
        ret = os.system('%s -c "import matplotlib"' % (sys.executable,))
        if ret == 0:
            utils.output('matplotlib already installed.  Skipping step.')

        else:
            utils.output('ImportError test shows that matplotlib is not '
                         'installed.  Installing...')

            if os.name == 'nt':
                self.install_nt()
            else:
                self.install_posix()

            # make sure the backend is set to WXAgg
            # and that interactive is set to True
            rcfn = os.path.join(
                    config.PYTHON_SITE_PACKAGES,
                    'matplotlib', 'mpl-data', 'matplotlibrc')
            utils.re_sub_filter_file(
                    [("(\s*backend\s*\:).*", "\\1 WXAgg"),
                     ("#*(\s*interactive\s:).*","\\1 True")], rcfn)
Ejemplo n.º 5
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!

            # just tested with VTK 5.8.0 and Python 2.7.2
            # it indeed installs VTK_PYTHON/VTK-5.8.0-py2.7.egg
            # but due to the site.py and easy-install.pth magic in there,
            # adding VTK_PYTHON to the PYTHONPATH still works. We can keep
            # pip, yay!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")

            # now do some surgery on VTKConfig.cmake and
            # VTKLibraryDepends.cmake so builds of VTK-dependent libraries
            # with only the DRE to link with Just Work(tm)

            # on windows, we need to replace backslash with forward slash
            # as that's the style used by the config files. On *ix mostly
            # harmless
            idp = re.sub(r'\\', '/', config.inst_dir)
            for fn in [
                    os.path.join(config.VTK_DIR, 'VTKConfig.cmake'),
                    os.path.join(config.VTK_DIR, 'VTKLibraryDepends.cmake'),
                    os.path.join(config.VTK_DIR,
                                 'VTKTargets-relwithdebinfo.cmake')
            ]:
                if os.path.exists(fn):
                    utils.re_sub_filter_file(
                        [(idp, '${VTK_INSTALL_PREFIX}/..')], fn)
Ejemplo n.º 6
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!
            
            # just tested with VTK 5.8.0 and Python 2.7.2
            # it indeed installs VTK_PYTHON/VTK-5.8.0-py2.7.egg
            # but due to the site.py and easy-install.pth magic in there,
            # adding VTK_PYTHON to the PYTHONPATH still works. We can keep
            # pip, yay!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")

            # now do some surgery on VTKConfig.cmake and
            # VTKLibraryDepends.cmake so builds of VTK-dependent libraries
            # with only the DRE to link with Just Work(tm)

            # on windows, we need to replace backslash with forward slash
            # as that's the style used by the config files. On *ix mostly
            # harmless
            idp = re.sub(r'\\','/', config.inst_dir)
            for fn in [os.path.join(config.VTK_DIR, 'VTKConfig.cmake'),
                    os.path.join(config.VTK_DIR, 'VTKLibraryDepends.cmake'),
                    os.path.join(config.VTK_DIR, 'VTKTargets-relwithdebinfo.cmake')]:
                if os.path.exists(fn):
                    utils.re_sub_filter_file(
                            [(idp,  '${VTK_INSTALL_PREFIX}/..')], 
                            fn)
Ejemplo n.º 7
0
    def build_posix_part(self):
        os.chdir(os.path.join('source', 'linux'))

        ret = os.system('%s Make.py' % (sys.executable,))
        if ret != 0:
            utils.error('Error creating make file.  Fix and try again.')

        # on GCCs with ProPolice, the stupid thing thinks that the
        # McMillan installer is trying to smash the stack.
        utils.re_sub_filter_file([("^CFLAGS=(.*)$","CFLAGS=\\1 "
                                   "-fno-stack-protector")],
                                 'Makefile')

        ret = os.system('make')
        if ret != 0:
            utils.error('Could not build stub.  Fix and try again.')
Ejemplo n.º 8
0
    def build_and_install_wxwidgets(self):
        os.chdir(self.build_dir)

        if not os.path.isdir('bld'):
            os.mkdir('bld')

        os.chdir('bld')

        # now we have to fix the IDIOTIC wxWidgets configure; on an FC3
        # machine with openwin on (don't ask, it's amsterdam), gl.h is
        # found in /usr/openwin instead of /usr/include.  We prepend
        # /usr/include to this list, we don't care about solaris machines
        # at the moment...
        repls = [('^SEARCH_INCLUDE="\\\\',
                  'SEARCH_INCLUDE="\\\\\n    /usr/include        \\\\')]
        utils.re_sub_filter_file(repls, '../configure')

        # changed to follow wxPython 2.8.11.0 documentation better
        # we're still missing:
        # --enable-sound --with-sdl
        # and the debug thingies
        ret = os.system(
            '../configure --prefix=%s --with-gtk --with-gnomeprint '
            '--with-opengl --enable-geometry --enable-graphics_ctx '
            '--with-libtiff=builtin '
            '--enable-mediactrl --enable-display --enable-unicode' %
            (self.inst_dir, ))
        if ret != 0:
            raise RuntimeError(
                '##### Error configuring wxWidgets.  Fix and try again.')

        ret = os.system('make install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets.  Fix and try again.')

        ret = os.system('make -C contrib/src/gizmos install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets GIZMOS.  Fix and try again.')

        ret = os.system('make -C contrib/src/stc install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets STC.  Fix and try again.')
Ejemplo n.º 9
0
    def build_and_install_wxwidgets(self):
        os.chdir(self.build_dir)

        if not os.path.isdir('bld'):
            os.mkdir('bld')
        
        os.chdir('bld')

        # now we have to fix the IDIOTIC wxWidgets configure; on an FC3
        # machine with openwin on (don't ask, it's amsterdam), gl.h is
        # found in /usr/openwin instead of /usr/include.  We prepend
        # /usr/include to this list, we don't care about solaris machines
        # at the moment...
        repls = [('^SEARCH_INCLUDE="\\\\',
                  'SEARCH_INCLUDE="\\\\\n    /usr/include        \\\\')]
        utils.re_sub_filter_file(repls, '../configure')

        # changed to follow wxPython 2.8.11.0 documentation better
        # we're still missing:
        # --enable-sound --with-sdl
        # and the debug thingies
        ret = os.system('../configure --prefix=%s --with-gtk --with-gnomeprint '
                        '--with-opengl --enable-geometry --enable-graphics_ctx '
                        '--with-libtiff=builtin '
                        '--enable-mediactrl --enable-display --enable-unicode' %
                        (self.inst_dir,))
        if ret != 0:
            raise RuntimeError(
                '##### Error configuring wxWidgets.  Fix and try again.')

        ret = os.system('make install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets.  Fix and try again.')
    
        ret = os.system('make -C contrib/src/gizmos install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets GIZMOS.  Fix and try again.')

        ret = os.system('make -C contrib/src/stc install')
        if ret != 0:
            raise RuntimeError(
                '##### Error making wxWidgets STC.  Fix and try again.')
Ejemplo n.º 10
0
    def configure_nt(self):
        if os.path.exists(os.path.join(self.build_dir, "CMakeFiles/cmake.check_cache")):
            utils.output("DCMTK build already configured.")
            return

        # modify CMakeLists, changing occurrences of /MT
        # (multithreaded runtime options) into /MD (multithreaded DLL
        # runtime options) and /MTd into /MDd
        # we need to change this to match what we have in VTK
        os.chdir(self.build_dir)
        repls = [("\/MT", "/MD")]
        utils.re_sub_filter_file(repls, "CMakeLists.txt")

        # then run cmake
        cmake_params = "-DCMAKE_INSTALL_PREFIX=%s " % (self.inst_dir,)
        ret = utils.cmake_command(self.build_dir, self.source_dir, cmake_params)

        if ret != 0:
            utils.error("Could not configure DCMTK.  Fix and try again.")
Ejemplo n.º 11
0
    def configure_nt(self):
        if os.path.exists(
                os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("DCMTK build already configured.")
            return

        # modify CMakeLists, changing occurrences of /MT
        # (multithreaded runtime options) into /MD (multithreaded DLL
        # runtime options) and /MTd into /MDd
        # we need to change this to match what we have in VTK
        os.chdir(self.build_dir)
        repls = [('\/MT', '/MD')]
        utils.re_sub_filter_file(repls, 'CMakeLists.txt')

        # then run cmake
        cmake_params = "-DCMAKE_INSTALL_PREFIX=%s " % (self.inst_dir, )
        ret = utils.cmake_command(self.build_dir, self.source_dir,
                                  cmake_params)

        if ret != 0:
            utils.error("Could not configure DCMTK.  Fix and try again.")
Ejemplo n.º 12
0
    def configure(self):
        if os.name == 'nt':
            utils.output("Skipping configure (WINDOWS).")
            return

        # pre-configure setup.py and setupext.py so that everything is
        # found and configured as we want it.
        os.chdir(self.build_dir)

        if os.path.exists('setup.py.new'):
            utils.output('matplotlib already configured.  Skipping step.')

        else:
            # pre-filter setup.py
            repls = [("(BUILD_GTKAGG\s*=\s*).*", "\\1 0"),
                     ("(BUILD_GTK\s*=\s*).*", "\\1 0"),
                     ("(BUILD_TKAGG\s*=\s*).*", "\\1 0"),
                     ("(BUILD_WXAGG\s*=\s*).*", "\\1 1"),
                     ("(rc\s*=\s*dict\().*",
                      "\\1 {'backend':'PS', 'numerix':'numpy'} )")]

            utils.re_sub_filter_file(repls, 'setup.py')
def package_dist():
    """4. package and timestamp distributables (nsis on win, tar on
    posix)
    """

    print S_PPF, "package_dist"

    # get devide version (we need this to stamp the executables)
    cmd = '%s -v' % (os.path.join(BDIPaths.dre_dest, 'dre devide'),)
    s,o = utils.get_status_output(cmd)
   
    # s == None if DeVIDE has executed successfully
    if s: 
        raise RuntimeError('Could not exec DeVIDE to extract version.')

    mo = re.search('^DeVIDE\s+(v.*)$', o, re.MULTILINE)
    if mo:
        devide_ver = mo.groups()[0]
    else:
        raise RuntimeError('Could not extract DeVIDE version.')

    # now get 32 or 64bit: we're going to use this in the package
    # naming.
    import platform
    if platform.architecture()[0] == '64bit':
        bits_str = '64'
    else:
        bits_str = '32'

    if os.name == 'nt':

        nsi_dir = 'archive\dre\support'
        os.chdir(os.path.join(
            config.working_dir, nsi_dir))

        if config.WINARCH_STR == 'x64':
            NSI_FILE = 'devide-re-x64.nsi'
            shutil.copy('devide-re.nsi', NSI_FILE)
            # fix redist for win64
            # also fix installation dir to "program files" and not "program
            # files (x86)
            utils.re_sub_filter_file(
                    [('vcredist_x86', 'vcredist_x64'),
                     ('\$PROGRAMFILES\\\\', '$PROGRAMFILES64\\\\')],
                    NSI_FILE)

        else:
            NSI_FILE = 'devide-re.nsi'

        # go to working dir
        os.chdir(config.working_dir)

        # /nocd tells makensis not to change to the directory
        # containing the nsi file.
        cmd = '%s /NOCD archive\dre\support\%s' \
                % (MAKE_NSIS, NSI_FILE)
        ret = os.system(cmd)
        if ret != 0:
            raise RuntimeError('Error running NSIS.')

        # nsis creates devidesetup.exe - we're going to rename to
        # devide-re-v9.8.1234-win64-setup.exe
        platform_str = 'win' + bits_str
        os.rename('devide-re-setup.exe', 
                'devide-re-%s-%s-setup.exe' % \
                        (devide_ver, platform_str))

    else:
        # go to the working dir
        os.chdir(config.working_dir)

        platform_str = 'lin' + bits_str
        # basename will be e.g. devide-re-v9.8.2341-lin64
        basename = '%s-%s-%s' % \
                (BDIPaths.dre_basename, devide_ver, platform_str)
        tarball = '%s.tar.bz2' % (basename,)

        if os.path.exists(tarball):
            print PPF, '%s exists, not repacking.' % (tarball,)
            return

        print PPF, 'Packing %s' % (tarball,)

        os.rename(BDIPaths.dre_basename, basename)

        # create tarball with juicy stuff
        tar = tarfile.open(tarball, 'w:bz2')
        # recursively add directory
        tar.add(basename)
        # finalize
        tar.close()

        # rename devide-version back to distdevide
        os.rename(basename, BDIPaths.dre_basename)

        print PPF, 'DONE.'
Ejemplo n.º 14
0
def package_dist():
    """4. package and timestamp distributables (nsis on win, tar on
    posix)
    """

    print S_PPF, "package_dist"

    # get devide version (we need this to stamp the executables)
    cmd = '%s -v' % (os.path.join(BDIPaths.dre_dest, 'dre devide'), )
    s, o = utils.get_status_output(cmd)

    # s == None if DeVIDE has executed successfully
    if s:
        raise RuntimeError('Could not exec DeVIDE to extract version.')

    mo = re.search('^DeVIDE\s+(v.*)$', o, re.MULTILINE)
    if mo:
        devide_ver = mo.groups()[0]
    else:
        raise RuntimeError('Could not extract DeVIDE version.')

    # now get 32 or 64bit: we're going to use this in the package
    # naming.
    import platform
    if platform.architecture()[0] == '64bit':
        bits_str = '64'
    else:
        bits_str = '32'

    if os.name == 'nt':

        nsi_dir = 'archive\dre\support'
        os.chdir(os.path.join(config.working_dir, nsi_dir))

        if config.WINARCH_STR == 'x64':
            NSI_FILE = 'devide-re-x64.nsi'
            shutil.copy('devide-re.nsi', NSI_FILE)
            # fix redist for win64
            # also fix installation dir to "program files" and not "program
            # files (x86)
            utils.re_sub_filter_file(
                [('vcredist_x86', 'vcredist_x64'),
                 ('\$PROGRAMFILES\\\\', '$PROGRAMFILES64\\\\')], NSI_FILE)

        else:
            NSI_FILE = 'devide-re.nsi'

        # go to working dir
        os.chdir(config.working_dir)

        # /nocd tells makensis not to change to the directory
        # containing the nsi file.
        cmd = '%s /NOCD archive\dre\support\%s' \
                % (MAKE_NSIS, NSI_FILE)
        ret = os.system(cmd)
        if ret != 0:
            raise RuntimeError('Error running NSIS.')

        # nsis creates devidesetup.exe - we're going to rename to
        # devide-re-v9.8.1234-win64-setup.exe
        platform_str = 'win' + bits_str
        os.rename('devide-re-setup.exe',
                'devide-re-%s-%s-setup.exe' % \
                        (devide_ver, platform_str))

    else:
        # go to the working dir
        os.chdir(config.working_dir)

        platform_str = 'lin' + bits_str
        # basename will be e.g. devide-re-v9.8.2341-lin64
        basename = '%s-%s-%s' % \
                (BDIPaths.dre_basename, devide_ver, platform_str)
        tarball = '%s.tar.bz2' % (basename, )

        if os.path.exists(tarball):
            print PPF, '%s exists, not repacking.' % (tarball, )
            return

        print PPF, 'Packing %s' % (tarball, )

        os.rename(BDIPaths.dre_basename, basename)

        # create tarball with juicy stuff
        tar = tarfile.open(tarball, 'w:bz2')
        # recursively add directory
        tar.add(basename)
        # finalize
        tar.close()

        # rename devide-version back to distdevide
        os.rename(basename, BDIPaths.dre_basename)

        print PPF, 'DONE.'
Ejemplo n.º 15
0
            utils.error('Python configure error.')

        # config.MAKE contains -j setting
        # I've had this break with Python 2.6.2, so I'm using straight make here...
        ret = os.system('%s install' % ('make',))
        if ret != 0:
            utils.error('Python build error.')
            
        # we want for example inst/python/lib/python2.7/config/Makefile
        pyconfig_makefile = os.path.join(
            config.inst_dir, 'python', 'lib', 
            'python%s' % (PYVER_STR2,), 'config', 'Makefile')
        # it hard-codes the absolute python home in the Makefile, we replace this
        # with something that will work when "dre shell" is active.            
        utils.re_sub_filter_file(
            [('^prefix\s*=.*$','prefix = ${DRE_TOP}/python')], 
            pyconfig_makefile)

        # this means we have to test for dependencies and then build
        # Python.
        sefn = 'jpython_setup_env.sh'

        jpcmd_fn = os.path.join(config.working_dir, sefn)
        f = open(jpcmd_fn, 'w')
        f.write(posix_python % (config.inst_dir,))
        f.close()

        # make it executable
        #os.chmod(jpcmd_fn, stat.S_IEXEC)

        ilines = """
Ejemplo n.º 16
0
    def install(self):

        # copy dreams dir and relevant driver scripts to inst dir
        if os.path.exists(self.dreams_dest_dir):
            utils.output('DREAMs already in inst_dir, not copying.')
        else:
            shutil.copytree(os.path.join(self.dre_src_dir, 'dreams'),
                            self.dreams_dest_dir)
            utils.output('Copied %s.' % (self.dreams_dest_dir, ))

        driver_paths = ((self.drepy_src, self.drepy_dest),
                        (self.dresh_src, self.dresh_dest), (self.dreshpy_src,
                                                            self.dreshpy_dest))

        for d in driver_paths:
            if os.path.exists(d[1]):
                utils.output('%s already present.' % (d[1], ))
            else:
                shutil.copy2(d[0], d[1])
                utils.output('Copied %s.' % (d[1], ))

        vardict = {
            'python_binary_path': config.python_binary_path,
            'python_library_path': config.python_library_path,
            'python_scripts_path': config.python_scripts_path,
            'devide_inst_dir': config.DEVIDE_INST_DIR,
            'wx_lib_path': config.WX_LIB_PATH,
            'vtk_sodir': config.VTK_SODIR,
            'vtk_python': config.VTK_PYTHON,
            'dcmtk_lib': config.DCMTK_LIB,
            'gdcm_lib': config.GDCM_LIB,
            'gdcm_python': config.GDCM_PYTHON,
            'vtkdevide_lib': config.VTKDEVIDE_LIB,
            'vtkdevide_python': config.VTKDEVIDE_PYTHON,
            'vtktudoss_lib': config.VTKTUDOSS_LIB,
            'vtktudoss_python': config.VTKTUDOSS_PYTHON,
            'itk_bin': config.ITK_BIN,
            'itk_lib': config.ITK_DIR,
            'wrapitk_lib': config.WRAPITK_LIB,
            'wrapitk_python': config.WRAPITK_PYTHON
        }

        # replace all instances of the installation dir with the
        # variable $MYDIR / %MYDIR%
        vardict2 = {}
        idir = config.inst_dir
        if idir.endswith(os.path.sep):
            idir = idir[:-1]

        for k, v in vardict.items():
            vardict2[k] = v.replace(idir, '%(dre_top)s')

        if os.name == 'nt':
            cfg = nt_cfg
        else:
            cfg = posix_cfg

        # let's write out the CFG file
        fname = os.path.join(config.inst_dir, 'dre.cfg')
        cf = file(fname, 'w')
        cfg2 = cfg % vardict2
        cf.write(cfg2)
        cf.close()
        utils.output('Write DRE CFG.')

        # and then we have to fix all of the shebangs that distutils sets as absolute paths!
        if os.name == 'posix':
            pyscripts = utils.find_files(
                config.python_binary_path,
                '.*',
                exclude_pats=['python$', 'python[0-9]\.[0-9]$'])[0]

            for pyscript in pyscripts:
                utils.re_sub_filter_file([('#!.*', '#!/usr/bin/env python')],
                                         pyscript)
    def install(self):

        # copy dreams dir and relevant driver scripts to inst dir
        if os.path.exists(self.dreams_dest_dir):
            utils.output('DREAMs already in inst_dir, not copying.')
        else:
            shutil.copytree(
                    os.path.join( self.dre_src_dir, 'dreams'),
                    self.dreams_dest_dir)
            utils.output('Copied %s.' % (self.dreams_dest_dir,))

        driver_paths = ((self.drepy_src, self.drepy_dest), (self.dresh_src, self.dresh_dest),
                        (self.dreshpy_src, self.dreshpy_dest))

        for d in driver_paths:
            if os.path.exists(d[1]):
                utils.output('%s already present.' % (d[1],))
            else:
                shutil.copy2(d[0], d[1])
                utils.output('Copied %s.' % (d[1],))
        
        vardict = {'python_binary_path' : config.python_binary_path,
                   'python_library_path' : config.python_library_path,
                   'python_scripts_path' : config.python_scripts_path,
                   'devide_inst_dir' : config.DEVIDE_INST_DIR,
                   'wx_lib_path' : config.WX_LIB_PATH,
                   'vtk_sodir' : config.VTK_SODIR,
                   'vtk_python' : config.VTK_PYTHON,
                   'dcmtk_lib' : config.DCMTK_LIB,
                   'gdcm_lib' : config.GDCM_LIB,
                   'gdcm_python' : config.GDCM_PYTHON,
                   'vtkdevide_lib' : config.VTKDEVIDE_LIB,
                   'vtkdevide_python' : config.VTKDEVIDE_PYTHON,
                   'vtktudoss_lib' : config.VTKTUDOSS_LIB,
                   'vtktudoss_python' : config.VTKTUDOSS_PYTHON,
                   'itk_bin' : config.ITK_BIN,
                   'itk_lib' : config.ITK_DIR,
                   'wrapitk_lib' : config.WRAPITK_LIB,
                   'wrapitk_python' : config.WRAPITK_PYTHON}

        # replace all instances of the installation dir with the
        # variable $MYDIR / %MYDIR%
        vardict2 = {}
        idir = config.inst_dir
        if idir.endswith(os.path.sep):
            idir = idir[:-1]
            
        for k,v in vardict.items():
            vardict2[k] = v.replace(idir, '%(dre_top)s')

        if os.name == 'nt':
            cfg = nt_cfg
        else:
            cfg = posix_cfg

        # let's write out the CFG file
        fname = os.path.join(config.inst_dir, 'dre.cfg')
        cf = file(fname, 'w')
        cfg2 = cfg % vardict2
        cf.write(cfg2)
        cf.close()
        utils.output('Write DRE CFG.')

        # and then we have to fix all of the shebangs that distutils sets as absolute paths!
        if os.name == 'posix':
            pyscripts = utils.find_files(config.python_binary_path, 
                    '.*', exclude_pats=['python$','python[0-9]\.[0-9]$'])[0]
            
            for pyscript in pyscripts:
                utils.re_sub_filter_file([('#!.*', '#!/usr/bin/env python')], pyscript)