• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python virtualenv.create_bootstrap_script函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中virtualenv.create_bootstrap_script函数的典型用法代码示例。如果您正苦于以下问题:Python create_bootstrap_script函数的具体用法?Python create_bootstrap_script怎么用?Python create_bootstrap_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_bootstrap_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version='2.5')
    if os.path.exists(script_name):
        f = open(script_name)
        cur_text = f.read()
        f.close()
    else:
        cur_text = ''
    print 'Updating %s' % script_name
    if cur_text == text:
        print 'No update'
    else:
        print 'Script changed; updating...'
        f = open(script_name, 'w')
        f.write(text)
        f.close()
    text = virtualenv.create_bootstrap_script(HOMEDIR_TEXT, python_version='2.5')
    if os.path.exists(gae_script_name):
        f = open(gae_script_name)
        cur_text = f.read()
        f.close()
    else:
        cur_text = ''
    print 'Updating %s' % gae_script_name
    if cur_text == text:
        print 'No update'
    else:
        print 'Script changed; updating...'
        f = open(gae_script_name, 'w')
        f.write(text)
        f.close()
开发者ID:chapmanb,项目名称:biosqlweb,代码行数:31,代码来源:generate-bootstrap.py


示例2: make_virtualenv

def make_virtualenv(packages=[]):
    additional = textwrap.dedent("""
    import sys, os, subprocess
    def after_install(options, home_dir):
        if sys.platform == 'win32':
            bin = 'Scripts'
        else:
            bin = 'bin'    
    """)
    for package in packages:
        if hasattr(package, '__iter__'):
            additional += textwrap.dedent("""
        #
            subprocess.call([join(home_dir, bin, 'easy_install'),
                             '-f', '%s', '%s'], stdout=subprocess.PIPE)
            """ % (package[1], package[0]))
        else:
            additional += textwrap.dedent("""
        #
            subprocess.call([join(home_dir, bin, 'easy_install'),
                             '%s'], stdout=subprocess.PIPE)
            """ % package)

    output = virtualenv.create_bootstrap_script(additional)
    f = open(VENV_BOOTSTRAP_SCRIPT, 'w').write(output)    
    subprocess.call(['python', VENV_BOOTSTRAP_SCRIPT, VENV_PATH])
开发者ID:ento,项目名称:iphone-dev-tweeters-,代码行数:26,代码来源:bootstrap.py


示例3: main

def main(argv):
    with open('bootstrap.py') as f:
        output = create_bootstrap_script(f.read())
    with open(INSTALL_SCRIPT, 'w') as f:
        f.write(output)
    os.chmod(INSTALL_SCRIPT, 0755)
    return 0
开发者ID:EricSchles,项目名称:cookiecutter-simple-django,代码行数:7,代码来源:create-bootstrap.py


示例4: _create_bootstrap

def _create_bootstrap(script_name, packages_to_install, paver_command_line,
                      install_paver=True, more_text="", dest_dir='.',
                      no_site_packages=None, system_site_packages=None,
                      unzip_setuptools=False, distribute=None, index_url=None,
                      no_index=False, find_links=None, prefer_easy_install=False):
    # configure package installation template
    install_cmd_options = []
    if index_url:
        install_cmd_options.extend(['--index-url', index_url])
    if no_index:
        install_cmd_options.extend(['--no-index'])
    if find_links:
        for link in find_links:
            install_cmd_options.extend(
                ['--find-links', link])
    install_cmd_tmpl = (_easy_install_tmpl if prefer_easy_install
                        else _pip_then_easy_install_tmpl)
    confd_install_cmd_tmpl = (install_cmd_tmpl %
        {'bin_dir_var': 'bin_dir', 'cmd_options': install_cmd_options})
    # make copy to local scope to add paver to packages to install
    packages_to_install = packages_to_install[:]
    if install_paver:
        packages_to_install.insert(0, 'paver==%s' % setup_meta['version'])
    install_cmd = confd_install_cmd_tmpl % {'packages': packages_to_install}

    options = ""
    # if deprecated 'no_site_packages' was specified and 'system_site_packages'
    # wasn't, set it from that value
    if system_site_packages is None and no_site_packages is not None:
        system_site_packages = not no_site_packages
    if system_site_packages is not None:
        options += ("    options.system_site_packages = %s\n" %
                    bool(system_site_packages))
    if unzip_setuptools:
        options += "    options.unzip_setuptools = True\n"
    if distribute is not None:
        options += "    options.use_distribute = %s\n" % bool(distribute)
    options += "\n"

    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
    bootstrap_contents = venv.create_bootstrap_script(extra_text)
    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)
开发者ID:BBBSnowball,项目名称:paver,代码行数:60,代码来源:virtual.py


示例5: _create_bootstrap

def _create_bootstrap(script_name, packages_to_install, paver_command_line,
                      install_paver=True, more_text="", dest_dir='.',
                      no_site_packages=None, system_site_packages=None,
                      unzip_setuptools=False, distribute=None, index_url=None,
                      find_links=None):
    # configure easy install template
    easy_install_options = []
    if index_url:
        easy_install_options.extend(["--index-url", index_url])
    if find_links:
        easy_install_options.extend(
            ["--find-links", " ".join(find_links)])
    easy_install_options = (
        easy_install_options
        and "'%s', " % "', '".join(easy_install_options) or '')
    confd_easy_install_tmpl = (_easy_install_tmpl %
                               ('bin_dir',  easy_install_options))
    if install_paver:
        paver_install = (confd_easy_install_tmpl %
                         ('paver==%s' % setup_meta['version']))
    else:
        paver_install = ""

    options = ""
    # if deprecated 'no_site_packages' was specified and 'system_site_packages'
    # wasn't, set it from that value
    if system_site_packages is None and no_site_packages is not None:
        system_site_packages = not no_site_packages
    if system_site_packages is not None:
        options += ("    options.system_site_packages = %s\n" %
                    bool(system_site_packages))
    if unzip_setuptools:
        options += "    options.unzip_setuptools = True\n"
    if distribute is not None:
        options += "    options.use_distribute = %s\n" % bool(distribute)
    options += "\n"

    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, paver_install)
    for package in packages_to_install:
        extra_text += confd_easy_install_tmpl % package
    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
    bootstrap_contents = venv.create_bootstrap_script(extra_text)
    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)
开发者ID:drewrm,项目名称:paver,代码行数:60,代码来源:virtual.py


示例6: main

def main():
    '''runs create_boostrap_script functionality and spits out new virtualenv script'''
    bootstrap_script = virtualenv.create_bootstrap_script(
        EXTRA_TEXT,
        python_version=CONFIG.get('environment', 'python_version')
    )

    result_script = CONFIG.get('bootstrap', 'result_script_name')
    result_path = CONFIG.get('bootstrap', 'result_path')

    result_abspath = None
    if '..' in result_path:
        pb.local.cwd.chdir(CURRENT_DIR)
        result_abspath = pb.path.local.LocalPath(result_path)
    else:
        result_abspath = pb.local.path(result_path)
    result_abspath.mkdir()
    bootstrap_path = result_abspath / result_script #Plumbum maps __div__ to join()
    result_abspath = pb.path.local.LocalPath(bootstrap_path)

    current_text = ''
    if result_abspath.is_file():
        print('--PULLING EXISTING BOOTSTRAP SCRIPT--')
        with open(result_abspath, 'r') as filehandle:
            current_text = filehandle.read()
    else:
        print('--NO BOOTSTRAP FOUND--')

    if current_text == bootstrap_script:
        print('--NO UPDATE BOOTSTRAP SCRIPT--')
    else:
        print('--UPDATING BOOTSTRAP SCRIPT--')
        with open(result_abspath, 'w') as filehandle:
            filehandle.write(bootstrap_script)
开发者ID:EVEprosper,项目名称:ProsperEnvironment,代码行数:34,代码来源:venv_bootstrapper.py


示例7: create_bootstrap_script

def create_bootstrap_script():
    content = ""

    content += requirements_definitions()

    info = "source bootstrap script: %r" % BOOTSTRAP_SOURCE
    print "read", info
    content += "\n\n# %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 v%s" % (virtualenv.__file__, virtualenv.virtualenv_version))
    output_lines.insert(2, "## python v%s" % sys.version.replace("\n", " "))
    output = "\n".join(output_lines)
    #print output

    f = file(BOOTSTRAP_SCRIPT, 'w')
    f.write(output)
    f.close()
开发者ID:jedie,项目名称:PyLucid-boot,代码行数:27,代码来源:create_bootstrap_script.py


示例8: make_devkit

def make_devkit(options):
    import virtualenv
    from urlgrabber.grabber import urlgrab
    from urlgrabber.progress import text_progress_meter

    (path("package") / "devkit" / "share").makedirs()
    pip_bundle("package/devkit/share/geonode-core.pybundle -r shared/devkit.requirements")
    script = virtualenv.create_bootstrap_script("""
import os, subprocess, zipfile

def after_install(options, home_dir):
    if sys.platform == 'win32':
        bin = 'Scripts'
    else:
        bin = 'bin'

    installer_base = os.path.abspath(os.path.dirname(__file__))

    def pip(*args):
        subprocess.call([os.path.join(home_dir, bin, "pip")] + list(args))

    pip("install", os.path.join(installer_base, "share", "geonode-core.pybundle"))
    setup_jetty(source=os.path.join(installer_base, "share"), dest=os.path.join(home_dir, "share"))

def setup_jetty(source, dest):
    jetty_zip = os.path.join(source, "jetty-distribution-7.0.2.v20100331.zip")
    jetty_dir = os.path.join(dest, "jetty-distribution-7.0.2.v20100331")

    zipfile.ZipFile(jetty_zip).extractall(dest)
    shutil.rmtree(os.path.join(jetty_dir, "contexts"))
    shutil.rmtree(os.path.join(jetty_dir, "webapps"))
    os.mkdir(os.path.join(jetty_dir, "contexts"))
    os.mkdir(os.path.join(jetty_dir, "webapps"))

    deployments = [
        ('geoserver', 'geoserver-geonode-dev.war'),
        ('geonetwork', 'geonetwork.war'),
        ('media', 'geonode-client.zip')
    ]

    for context, archive in deployments:
        src = os.path.join(source, archive)
        dst = os.path.join(jetty_dir, "webapps", context)
        zipfile.ZipFile(src).extractall(dst)
""")

    open((path("package")/"devkit"/"go-geonode.py"), 'w').write(script)
    urlgrab(
        "http://download.eclipse.org/jetty/7.0.2.v20100331/dist/jetty-distribution-7.0.2.v20100331.zip",
        "package/devkit/share/jetty-distribution-7.0.2.v20100331.zip",
        progress_obj = text_progress_meter()
    )
    urlgrab(
        "http://pypi.python.org/packages/source/p/pip/pip-0.7.1.tar.gz",
        "package/devkit/share/pip-0.7.1.tar.gz",
        progress_obj = text_progress_meter()
    )
    geoserver_target.copy("package/devkit/share")
    geonetwork_target.copy("package/devkit/share")
    geonode_client_target().copy("package/devkit/share")
开发者ID:shimon,项目名称:geonode,代码行数:60,代码来源:pavement.py


示例9: main

def main():
    parser = OptionParser()
    parser.add_option('--prefix',
                      dest='prefix',
                      default=here,
                      help='prefix for the location of the resulting script')
    text   = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version='2.4')

    (options, args) = parser.parse_args()

    script_name = os.path.join(options.prefix, 'lavaflow-bootstrap.py')

    if os.path.exists(script_name):
        f = open(script_name)
        cur_text = f.read()
        f.close()
    else:
        cur_text = ''
        
    print 'Updating %s' % script_name
    if cur_text == 'text':
        print 'No update'
    else:
        print 'Script changed; updating...'
    f = open(script_name, 'w')
    f.write(text)
    f.close()
开发者ID:kiwiroy,项目名称:lavaflow,代码行数:27,代码来源:lavaflow-venv.py


示例10: generate

def generate(filename, version):
    path = version
    if "==" in version:
        path = version[: version.find("==")]
    output = virtualenv.create_bootstrap_script(textwrap.dedent(after_install % (path, version)))
    fp = open(filename, "w")
    fp.write(output)
    fp.close()
开发者ID:netme,项目名称:pylons,代码行数:8,代码来源:gen-go-pylons.py


示例11: main

def main(args):
    bootstrapdir = '.'
    if len(args) > 1:
        if os.path.exists(args[1]):
            bootstrapdir = args[1]
            print 'Creating bootstrap file in: "'+bootstrapdir+'"'
        else:
            print 'Directory "'+args[1]+'" does not exist. Placing bootstrap in "'+os.path.abspath(bootstrapdir)+'" instead.'

    output = virtualenv.create_bootstrap_script(textwrap.dedent(""""""))
    f = open(bootstrapdir+'/bootstrap.py', 'w').write(output)
开发者ID:rxuriguera,项目名称:bibtexIndexMaker,代码行数:11,代码来源:createBootstrap.py


示例12: create_bootstrap

 def create_bootstrap(self, dest):
     extra_text = (
         TERRARIUM_BOOTSTRAP_EXTRA_TEXT %
             {
                 'REQUIREMENTS': self.requirements,
                 'LOGGING': logger.level,
             }
     )
     output = create_bootstrap_script(extra_text)
     with open(dest, 'w') as f:
         f.write(output)
开发者ID:KStepniowska,项目名称:terrarium,代码行数:11,代码来源:terrarium.py


示例13: create_bootstrap

 def create_bootstrap(self, dest):
     extra_text = (
         TERRARIUM_BOOTSTRAP_EXTRA_TEXT.format(
             requirements=self.requirements,
             virtualenv_log_level=self.args.virtualenv_log_level,
             pip_log_level=self.args.pip_log_level,
         )
     )
     output = create_bootstrap_script(extra_text)
     with open(dest, 'w') as f:
         f.write(output)
开发者ID:brooklynpacket,项目名称:terrarium,代码行数:11,代码来源:terrarium.py


示例14: create_bootstrap

 def create_bootstrap(self, dest):
     extra_text = (
         TERRARIUM_BOOTSTRAP_EXTRA_TEXT %
             {
                 'REQUIREMENTS': self.requirements,
                 'VENV_LOGGING': self.args.virtualenv_log_level,
                 'PIP_LOGGING': self.args.pip_log_level,
             }
     )
     output = create_bootstrap_script(extra_text)
     with open(dest, 'w') as f:
         f.write(output)
开发者ID:pombredanne,项目名称:terrarium,代码行数:12,代码来源:terrarium.py


示例15: append_to_zip

 def append_to_zip(self, bundle_path):
     """
     Populate the bundle with necessary bootstrapping python
     """
     with zipfile.ZipFile(bundle_path, mode='a') as bundle:
         for mod_name, spec in self.modules:
             mod = resolve(spec)
             if mod is not None:
                 bundle.writestr(mod_name, inspect.getsource(mod))
             else:
                 #@@ needs negative test
                 logger.error("%s does not return a module", spec)
         bundle.writestr('bootstrap.py', virtualenv.create_bootstrap_script(self.extra_text))
开发者ID:axelaclaro,项目名称:Strap,代码行数:13,代码来源:factory.py


示例16: create_virtualenv_bootstrap_script

def create_virtualenv_bootstrap_script(script_path, after_install_script_file):
    import virtualenv

    indented_customize_script = ""
    if after_install_script_file:
        customize_script_lines = open(after_install_script_file, "rb").readlines()
        indented_customize_script = "\n    # customize process\n" + \
                "\n".join(["    " + line.rstrip() for line in customize_script_lines]).rstrip() + \
                "\n"

    script = get_default_after_install_script() + indented_customize_script
    with open(script_path, "wb") as fp:
        fp.write(virtualenv.create_bootstrap_script(script))
开发者ID:pombredanne,项目名称:vebootstrap,代码行数:13,代码来源:create.py


示例17: generate

def generate(filename, version):
    # what's commented out below comes from go-pylons.py

    #path = version
    #if '==' in version:
    #    path = version[:version.find('==')]
    #output = virtualenv.create_bootstrap_script(
    #    textwrap.dedent(after_install % (path, version)))

    output = virtualenv.create_bootstrap_script(
        textwrap.dedent(after_install % version))
    fp = open(filename, 'w')
    fp.write(output)
    fp.close()
开发者ID:Pedroo22,项目名称:georchestra,代码行数:14,代码来源:gen-go-windmill.py


示例18: bootstrap

def bootstrap(dependencies, dir):
    extra = textwrap.dedent("""
    import os, subprocess
    import urllib
    from tempfile import mkdtemp
    def extend_parser(optparse_parser):
        pass
    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)
开发者ID:jrha,项目名称:aquilon,代码行数:23,代码来源:bootstrap_env.py


示例19: create_bigjob_bootstrap_script

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
开发者ID:ssarip1,项目名称:BigJob,代码行数:15,代码来源:generate_bigjob_bootstrap_script.py


示例20: main

def main():
    text = virtualenv.create_bootstrap_script(EXTRA_TEXT)
    if os.path.exists(script_name):
        f = open(script_name)
        cur_text = f.read()
        f.close()
    else:
        cur_text = ''
    print 'Updating %s' % script_name
    if cur_text == 'text':
        print 'No update'
    else:
        print 'Script changed; updating...'
        f = open(script_name, 'w')
        f.write(text)
        f.close()
开发者ID:bikeshkumar,项目名称:pinax,代码行数:16,代码来源:create-venv-script.py



注:本文中的virtualenv.create_bootstrap_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python virtualenv.create_environment函数代码示例发布时间:2022-05-26
下一篇:
Python virtualchain.get_config_filename函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap