本文整理汇总了Python中waflib.Utils.subst_vars方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.subst_vars方法的具体用法?Python Utils.subst_vars怎么用?Python Utils.subst_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.subst_vars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_env
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def prepare_env(self,env):
if not env.PREFIX:
env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
if not env.BINDIR:
env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
if not env.LIBDIR:
env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env)
示例2: process_py
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def process_py(self,node):
assert(node.get_bld_sig())
assert(getattr(self,'install_path')),'add features="py"'
if self.install_path:
if self.install_from:
self.bld.install_files(self.install_path,[node],cwd=self.install_from,relative_trick=True)
else:
self.bld.install_files(self.install_path,[node],relative_trick=True)
lst=[]
if self.env.PYC:
lst.append('pyc')
if self.env.PYO:
lst.append('pyo')
if self.install_path:
if self.install_from:
pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.install_from)),self.env)
else:
pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.path)),self.env)
else:
pyd=node.abspath()
for ext in lst:
if self.env.PYTAG:
name=node.name[:-3]
pyobj=node.parent.get_bld().make_node('__pycache__').make_node("%s.%s.%s"%(name,self.env.PYTAG,ext))
pyobj.parent.mkdir()
else:
pyobj=node.change_ext(".%s"%ext)
tsk=self.create_task(ext,node,pyobj)
tsk.pyd=pyd
if self.install_path:
self.bld.install_files(os.path.dirname(pyd),pyobj,cwd=node.parent.get_bld(),relative_trick=True)
示例3: feature_py
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def feature_py(self):
install_path=getattr(self,'install_path','${PYTHONDIR}')
install_from=getattr(self,'install_from',None)
if install_from and not isinstance(install_from,Node.Node):
install_from=self.path.find_dir(install_from)
inputs=[]
for x in Utils.to_list(self.source):
if isinstance(x,Node.Node):
y=x
else:
y=self.path.find_resource(x)
inputs.append(y)
if install_path:
if install_from:
pyd=Utils.subst_vars("%s/%s"%(install_path,y.path_from(install_from)),self.env)
else:
pyd=Utils.subst_vars("%s/%s"%(install_path,y.path_from(self.path)),self.env)
else:
pyd=y.abspath()
for ext in("pyc","pyo"):
if install_from:
pyobj=self.path.get_bld().make_node(y.change_ext(".%s"%ext).get_bld().path_from(install_from.get_bld()))
else:
pyobj=self.path.get_bld().make_node(y.change_ext(".%s"%ext).name)
pyobj.parent.mkdir()
tsk=self.create_task(ext,y,pyobj)
tsk.pyd=pyd
if install_path:
self.bld.install_files(install_path,pyobj,cwd=self.path.get_bld(),relative_trick=True)
if install_path:
if install_from:
self.bld.install_files(install_path,inputs,cwd=install_from,relative_trick=True)
else:
self.bld.install_files(install_path,inputs)
示例4: prepare_env
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def prepare_env(self, env):
"""insert various variables in the environment"""
if not env.PREFIX:
env.PREFIX = os.path.abspath(os.path.expanduser(Options.options.prefix))
if not env.BINDIR:
env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env)
if not env.LIBDIR:
env.LIBDIR = Utils.subst_vars('${PREFIX}/lib', env)
示例5: run
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def run(self):
cmd = [
Utils.subst_vars("${PYTHON}", self.env),
Utils.subst_vars("${PYFLAGS_OPT}", self.env),
"-c",
INST,
self.inputs[0].abspath(),
self.outputs[0].abspath(),
self.pyd,
]
ret = self.generator.bld.exec_command(cmd)
return ret
示例6: prepare_env
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def prepare_env(self, env):
"""
Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env``
:type env: :py:class:`waflib.ConfigSet.ConfigSet`
:param env: a ConfigSet, usually ``conf.env``
"""
if not env.PREFIX:
env.PREFIX = os.path.abspath(os.path.expanduser(Options.options.prefix))
if not env.BINDIR:
env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env)
if not env.LIBDIR:
env.LIBDIR = Utils.subst_vars('${PREFIX}/lib', env)
示例7: add_dependency
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def add_dependency(bld, tgt, src):
# Expand configuration variables (e.g.
# "${root}/tools" -> "/home/.../tenshi/tools")
tgt = Utils.subst_vars(tgt, bld.env)
src = Utils.subst_vars(src, bld.env)
# Handle paths relative the current wscript
src_node = bld.path.find_resource(src)
if src_node is None:
# Handle paths relative to the root and absolute paths.
src_node = bld.root.find_resource(src)
if src_node is None:
bld.fatal("Could not find manual dependency '{}'".format(src))
bld.add_manual_dependency(tgt, src_node)
示例8: dep_build
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def dep_build(self, *k, **kw):
"""Configure/Make/Make install to the dist directory"""
k, kw = base(self, *k, **kw)
k, kw = fetch(self, *k, **kw)
self.start_msg("Building %s" % kw["name"])
if not os.path.isdir(kw["prefix"]):
config_cmd = kw.get("config_cmd", "%(src)s/configure --prefix=%(prefix)s")
build_cmd = kw.get("build_cmd", Utils.subst_vars('${MAKE} ${JOBS}',self.env))
install_cmd = kw.get("install_cmd", Utils.subst_vars('${MAKE} ${JOBS} install', self.env))
self.end_msg("...")
if not os.path.exists(kw["build"]):
if kw.get("build_dir", True):
os.makedirs(kw["build"])
self.start_msg(" Configure %s" % kw["name"])
self.cmd_and_log(
config_cmd % kw,
#(config_cmd % kw).split(' '),
output=Context.BOTH,
shell=True,
cwd=kw.get("config_cwd",kw["build"]) % kw
)
self.end_msg("Ok")
self.start_msg(" Compile %s" % kw["name"])
self.cmd_and_log(
build_cmd % kw,
#(build_cmd % kw).split(' '),
output=Context.BOTH,
shell=True,
cwd=kw.get("build_cwd",kw["build"]) % kw
)
self.end_msg("Ok")
if not os.path.exists(kw["prefix"]):
self.start_msg(" Install %s" % kw["name"])
self.cmd_and_log(
install_cmd % kw,
#(install_cmd % kw).split(' '),
output=Context.BOTH,
shell=True,
cwd=kw.get("install_cwd",kw["build"]) % kw
)
self.end_msg("Ok")
else:
self.end_msg("Already done")
示例9: setup_py_build
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def setup_py_build(task):
"""
"""
if bld.env.IS_WINDOWS:
wsdk_env = cls._get_wdsk_env()
cmd = Utils.subst_vars('${PYTHON} setup.py build'\
' --build-base="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}"'\
' --build-platlib="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}/${PLATFORM_NAME}"'\
' --compiler=msvc', bld.env)
task.exec_command(cmd, cwd=bld.path.abspath(), env=wsdk_env)
else:
cmd = Utils.subst_vars('${PYTHON} setup.py build'\
' --build-base="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}"'\
' --build-platlib="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}/${PLATFORM_NAME}"',
bld.env)
task.exec_command(cmd, cwd=bld.path.abspath(), env=wsdk_env)
示例10: configure
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def configure(conf):
def get_param(varname,default):
return getattr(Options.options,varname,'')or default
env=conf.env
env.LIBDIR=env.BINDIR=[]
env.EXEC_PREFIX=get_param('EXEC_PREFIX',env.PREFIX)
corner_case=False
if str(env.PREFIX)=='/usr':
corner_case=True
env.PREFIX=''
env.PACKAGE=getattr(Context.g_module,'APPNAME',None)or env.PACKAGE
complete=False
iter=0
while not complete and iter<len(_options)+1:
iter+=1
complete=True
for name,help,default in _options:
name=name.upper()
if not env[name]:
try:
env[name]=Utils.subst_vars(get_param(name,default).replace('/',os.sep),env)
except TypeError:
complete=False
if corner_case:
env.PREFIX='/usr'
if not complete:
lst=[name for name,_,_ in _options if not env[name.upper()]]
raise conf.errors.WafError('Variable substitution failure %r'%lst)
示例11: configure
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def configure(self):
try:
if sys.version_info >= (3, 0):
self.find_program('virtualenv', var="VIRTUALENV", mandatory=True, okmsg="ok")
else:
self.find_program('virtualenv2', var="VIRTUALENV", mandatory=True, okmsg="ok")
except ConfigurationError as e:
name = "virtualenv"
version = "trunk"
self.dep_fetch(
name = name,
version = version,
git_url = "https://github.com/pypa/virtualenv.git",
)
self.find_program('virtualenv.py', var="VIRTUALENV", mandatory=True, okmsg="ok", path_list=[self.dep_path(name, version)])
self.start_msg("Create python virtualenv")
self.env["VENV_PATH"] = os.path.join(self.bldnode.abspath(), ".conf_check_venv")
self.cmd_and_log(
[Utils.subst_vars('${VIRTUALENV}',self.env), "-p", sys.executable, self.env.VENV_PATH],
output=Context.BOTH,
cwd=self.bldnode.abspath()
)
self.end_msg("ok")
self.find_program('python', var="VPYTHON", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
self.find_program('pip', var="VPIP", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
示例12: get_install_path
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def get_install_path(self):
"installation path prefixed by the destdir, the variables like in '${PREFIX}/bin' are substituted"
dest = self.dest.replace('/', os.sep)
dest = Utils.subst_vars(self.dest, self.env)
if Options.options.destdir:
dest = os.path.join(Options.options.destdir, dest.lstrip(os.sep))
return dest
示例13: get_inst_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def get_inst_node(self, dest, name):
dest = Utils.subst_vars(dest, self.env)
dest = dest.replace('/', os.sep)
if Options.options.destdir:
dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep))
return self.bld.srcnode.make_node([dest, name])
示例14: run
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def run(self):
if not self.env['VALADOCFLAGS']:
self.env['VALADOCFLAGS'] = ''
cmd = [Utils.subst_vars(VALADOC_STR, self.env)]
cmd.append ('-o %s' % self.output_dir)
if getattr(self, 'doclet', None):
cmd.append ('--doclet %s' % self.doclet)
cmd.append ('--package-name %s' % self.package_name)
if getattr(self, 'package_version', None):
cmd.append ('--package-version %s' % self.package_version)
if getattr(self, 'packages', None):
for package in self.packages:
cmd.append ('--pkg %s' % package)
if getattr(self, 'vapi_dirs', None):
for vapi_dir in self.vapi_dirs:
cmd.append ('--vapidir %s' % vapi_dir)
if not getattr(self, 'protected', None):
cmd.append ('--no-protected')
if getattr(self, 'private', None):
cmd.append ('--private')
if getattr(self, 'inherit', None):
cmd.append ('--inherit')
if getattr(self, 'deps', None):
cmd.append ('--deps')
if getattr(self, 'enable_non_null_experimental', None):
cmd.append ('--enable-non-null-experimental')
if getattr(self, 'force', None):
cmd.append ('--force')
cmd.append (' '.join ([x.abspath() for x in self.files]))
return self.generator.bld.exec_command(' '.join(cmd))
示例15: apply_target_framework
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import subst_vars [as 别名]
def apply_target_framework(self):
if getattr(self.bld, 'is_idegen', False):
return
# Add TargetFrameworkAttribute to the assembly
self.env.EMIT_SOURCE = Utils.subst_vars(target_framework_template, self.env)
name = '.NETFramework,Version=%s.AssemblyAttributes.cs' % self.env.TARGET_FRAMEWORK
target = self.path.find_or_declare(name)
tsk = self.create_task('emit', None, [ target ])
self.source = self.to_nodes(self.source) + tsk.outputs
# For any use entries that can't be resolved to a task generator
# assume they are system reference assemblies and add them to the
# ASSEMBLIES variable so they get full path linkage automatically added
filtered = []
names = self.to_list(getattr(self, 'use', []))
get = self.bld.get_tgen_by_name
for x in names:
try:
y = get(x)
if 'fake_lib' in getattr(y, 'features', ''):
y.post()
install_outputs(y)
filtered.append(x)
except Errors.WafError:
self.env.append_value('ASSEMBLIES', x)
self.use = filtered