Generates a particular ui plugin for ths system and imports it.
    
    :param      widgetPath  | <str>
                buildPath   | <str> || None

def generatePlugin(sourcePath, buildPath = None):
    """
    Generates a particular ui plugin for ths system and imports it.
    
    :param      widgetPath  | <str>
                buildPath   | <str> || None
    """
    if ( buildPath is None ):
        buildPath = BUILD_PATH
        
    pkg_name = projex.packageFromPath(sourcePath)
    module = os.path.basename(sourcePath).split('.')[0]
    if module != '__init__':
        pkg_name += '.' + module
    
    try:
        __import__(pkg_name)
    except ImportError, e:
        logging.exception(e)
        return
    
    module = sys.modules.get(pkg_name)
    if not module:
        return
        
    if not hasattr(module, '__designer_plugins__'):
        logger.info('%s has no __designer_plugins__ defined.' % pkg_name)
        return
    
    if not os.path.exists(buildPath):
        os.mkdir(buildPath)
    
    for plug in module.__designer_plugins__:
        output_path = os.path.join(buildPath, 
                                   '%splugin.py' % plug.__name__.lower())
        
        # generate the options
        options = {}
        options['module'] = pkg_name
        options['class']  = plug.__name__
        
        # save the plugin
        f = open(output_path, 'w')
        f.write(PLUGIN_DEF % options)
        f.close()