How to use the virtualenv.create_bootstrap_script function in virtualenv

To help you get started, we’ve selected a few virtualenv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paver / paver / paver / virtual.py View on Github external
extra_text = """def adjust_options(options, args):
    args[:] = ['%s']
%s
def after_install(options, home_dir):
    if sys.platform == 'win32':
        bin_dir = join(home_dir, 'Scripts')
    else:
        bin_dir = join(home_dir, 'bin')
%s""" % (dest_dir, options, install_cmd)
    if paver_command_line:
        command_list = list(paver_command_line.split())
        extra_text += "    subprocess.call([join(bin_dir, 'paver'),%s)" % repr(command_list)[1:]

    extra_text += more_text
    if has_virtualenv:
        bootstrap_contents = venv.create_bootstrap_script(extra_text)
    else:
        raise BuildFailure(VIRTUALENV_MISSING_ERROR)
    fn = script_name

    debug("Bootstrap script extra text: " + extra_text)
    def write_script():
        open(fn, "w").write(bootstrap_contents)
    dry("Write bootstrap script %s" % fn, write_script)
github dagster-io / dagster / bin / publish.py View on Github external
os.path.join(home_dir, 'bin', 'pip'), 'install', '{{module}}=={version}'.format(
                module=module_name
            )
        ])

'''.format(
        module_names=', '.join(
            [
                '\'{module_name}\''.format(module_name=module_name)
                for module_name in MODULE_NAMES + LIBRARY_MODULES
            ]
        ),
        version=version,
    )

    bootstrap_script = virtualenv.create_bootstrap_script(bootstrap_text)

    with tempfile.TemporaryDirectory() as venv_dir:
        with tempfile.NamedTemporaryFile('w') as bootstrap_script_file:
            bootstrap_script_file.write(bootstrap_script)

            args = ['python', bootstrap_script_file.name, venv_dir]

            click.echo(subprocess.check_output(args).decode('utf-8'))
github saga-project / BigJob / bootstrap / generate_bigjob_bootstrap_script.py View on Github external
def create_bigjob_bootstrap_script():
    output = virtualenv.create_bootstrap_script(textwrap.dedent("""
    import os, subprocess
    def after_install(options, home_dir):
        etc = join(home_dir, 'etc')
        if not os.path.exists(etc):
            os.makedirs(etc)         
        subprocess.call([join(home_dir, 'bin', 'easy_install'),
                     'bigjob'])    
    """))
    return output
github jedie / PyLucid / scripts / create_bootstrap_script.py View on Github external
def create_bootstrap_script():
    info = "source bootstrap script: %r" % BOOTSTRAP_SOURCE
    print "read", info
    content = "# %s\n" % info
    f = file(BOOTSTRAP_SOURCE, "r")
    content += f.read()
    f.close()

    print "Create/Update %r" % BOOTSTRAP_SCRIPT

    output = virtualenv.create_bootstrap_script(content)

    # Add info lines
    output_lines = output.splitlines()
    output_lines.insert(2, "## Generate with %r" % __file__)
    output_lines.insert(2, "## using: %r" % virtualenv.__file__)
    output = "\n".join(output_lines)
    #print output

    f = file(BOOTSTRAP_SCRIPT, 'w')
    f.write(output)
    f.close()
github sightmachine / SimpleCV / scripts / mkvirt.py View on Github external
import os
import virtualenv, textwrap

here = os.path.dirname(os.path.abspath(__file__))
base_dir = os.path.dirname(here)

print "Creating SimpleCV Bootstrap Install Script: simplecv-bootstrap.py"

output = virtualenv.create_bootstrap_script(textwrap.dedent("""
import os, subprocess

def after_install(options, home_dir):
    base_dir = os.path.dirname(home_dir)
    logger.notify('Installing SimpleCV into Virtual Environment')
    
    os.chdir(home_dir)
    print 'Current Directory:', os.getcwd()
    print 'dir list:', os.listdir(os.getcwd())
    print 'Symlinking OpenCV'
    os.symlink('/usr/local/lib/python2.7/dist-packages/cv2.so', os.path.join(os.getcwd(),'lib/python2.7/site-packages/cv2.so'))
    os.symlink('/usr/local/lib/python2.7/dist-packages/cv.py', os.path.join(os.getcwd(),'lib/python2.7/site-packages/cv.py'))
    subprocess.call(['pwd'])
    os.mkdir('src')
    os.chdir('src')
    subprocess.call(['wget','-O','pygame.tar.gz','http://github.com/xamox/pygame/tarball/master'])
github OpenMDAO / OpenMDAO-Framework / scripts / mkdevinstaller.py View on Github external
cmds = []
    reqs = set()
    dists = working_set.resolve([Requirement.parse(r) for r in openmdao_pkgs])
    excludes = set(['setuptools', 'distribute', 'numpy', 'scipy'])
    for dist in dists:
        if dist.project_name == 'openmdao.main':
            version = dist.version
        if not dist.project_name.startswith('openmdao.') and dist.project_name not in excludes:
            reqs.add('%s' % dist.as_requirement())  
            
    reqs = ['numpy', 'scipy'] + list(reqs)
    
    optdict = { 'reqs': reqs, 'cmds':cmds }
    
    with open('go-openmdao-dev.py', 'wb') as f:
        f.write(virtualenv.create_bootstrap_script(script_str % optdict))
    os.chmod('go-openmdao-dev.py', 0755)
github PolicyStat / terrarium / terrarium.py View on Github external
def create_bootstrap(self, dest):
        extra_text = (
            TERRARIUM_BOOTSTRAP_EXTRA_TEXT %
                {'REQUIREMENTS': self.requirements}
        )
        output = create_bootstrap_script(extra_text)
        with open(dest, 'w') as f:
            f.write(output)
github quattor / aquilon / build / bootstrap_env.py View on Github external
def adjust_options(options, args):
        pass
    def after_install(options, home_dir):
        easy_install = join(home_dir, 'bin', 'easy_install')
    """)
    for package in sorted(dependencies.keys()):
        if package == 'protobuf':
            continue
        extra += "    if subprocess.call([easy_install, '%s==%s']) != 0:\n" % (
            package, dependencies[package])
        extra += "        subprocess.call([easy_install, '%s'])\n" % package
    extra += "    subprocess.call([easy_install, '.'], cwd='%s')\n" % (
        os.path.join(dir, 'bootstrap_ms'))
    extra += "    subprocess.call([easy_install, '.'], cwd='%s')\n" % (
        os.path.join(dir, 'bootstrap_Sybase'))
    print virtualenv.create_bootstrap_script(extra)