예제 #1
0
def generate_requirements(valid_plugins,app_dest):
    '''
    generate_requirements will generate a custom setup.py from a template
    this will include the python dependencies for valid plugins
    '''
    plugin_folder = os.path.dirname(valid_plugins[0])
    v = load_plugins(valid_plugins)

    # Add plugin dependencies on other plugins, even if user has not selected
    plugin_deps = [x[0]["dependencies"]["plugins"] for x in v if "plugins" in x[0]["dependencies"]]
    for plugin_dep in plugin_deps:
        for p in plugin_dep:
            if "%s/%s" %(plugin_folder,p) not in valid_plugins:
                valid_plugins.append("%s/%s" %(plugin_folder,p))

    # Get list of python dependencies for setup.py
    python_deps = [x[0]["dependencies"]["python"] for x in v if "python" in x[0]["dependencies"]]
    dependencies = []
    for python_dep in python_deps:
        dependencies = dependencies + python_dep
    dependencies = numpy.unique(dependencies).tolist()

    # Get requirements.txt to use as a template
    requirements = get_template("%s/requirements.txt" %(app_dest)).split("\n")
    new_requirements = numpy.unique(requirements + dependencies).tolist()
    new_requirements = [x for x in new_requirements if len(x) > 0]

    # Save new requirements
    save_template("%s/requirements.txt" %(app_dest),"\n".join(new_requirements))
예제 #2
0
def init_scripts(scripts_dir,output_base):
    '''init_scripts:
    move job running scripts from template into user
    scripts directory. Template substitutions will be done at
    this step, to ensure that calling the init_scripts function
    from a different folder will produce scripts to run with correct
    analysis directory path
    '''
    installdir = get_installdir()
    scripts_to_move = glob("%s/scripts/*" %(installdir))
    for script in scripts_to_move:
        script_template = get_template(script)
        script_name = os.path.basename(script)
        script_copy = "%s/scripts/%s" %(output_base,script_name)       
        save_template(script_copy,script_template)              
예제 #3
0
def init_scripts(scripts_dir, output_base):
    '''init_scripts:
    move job running scripts from template into user
    scripts directory. Template substitutions will be done at
    this step, to ensure that calling the init_scripts function
    from a different folder will produce scripts to run with correct
    analysis directory path
    '''
    installdir = get_installdir()
    scripts_to_move = glob("%s/scripts/*" % (installdir))
    for script in scripts_to_move:
        script_template = get_template(script)
        script_name = os.path.basename(script)
        script_copy = "%s/scripts/%s" % (output_base, script_name)
        save_template(script_copy, script_template)
예제 #4
0
def generate_requirements(valid_plugins, app_dest):
    '''
    generate_requirements will generate a custom setup.py from a template
    this will include the python dependencies for valid plugins
    '''
    plugin_folder = os.path.dirname(valid_plugins[0])
    v = load_plugins(valid_plugins)

    # Add plugin dependencies on other plugins, even if user has not selected
    plugin_deps = [
        x[0]["dependencies"]["plugins"] for x in v
        if "plugins" in x[0]["dependencies"]
    ]
    for plugin_dep in plugin_deps:
        for p in plugin_dep:
            if "%s/%s" % (plugin_folder, p) not in valid_plugins:
                valid_plugins.append("%s/%s" % (plugin_folder, p))

    # Get list of python dependencies for setup.py
    python_deps = [
        x[0]["dependencies"]["python"] for x in v
        if "python" in x[0]["dependencies"]
    ]
    dependencies = []
    for python_dep in python_deps:
        dependencies = dependencies + python_dep
    dependencies = numpy.unique(dependencies).tolist()

    # Get requirements.txt to use as a template
    requirements = get_template("%s/requirements.txt" % (app_dest)).split("\n")
    new_requirements = numpy.unique(requirements + dependencies).tolist()
    new_requirements = [x for x in new_requirements if len(x) > 0]

    # Save new requirements
    save_template("%s/requirements.txt" % (app_dest),
                  "\n".join(new_requirements))