本文整理汇总了Python中virtualenv.create_bootstrap_script函数的典型用法代码示例。如果您正苦于以下问题:Python create_bootstrap_script函数的具体用法?Python create_bootstrap_script怎么用?Python create_bootstrap_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_bootstrap_script函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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])
示例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
示例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)
示例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)
示例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)
示例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()
示例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")
示例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()
示例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()
示例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)
示例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)
示例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)
示例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)
示例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))