本文整理匯總了Python中distutils.cmd方法的典型用法代碼示例。如果您正苦於以下問題:Python distutils.cmd方法的具體用法?Python distutils.cmd怎麽用?Python distutils.cmd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils
的用法示例。
在下文中一共展示了distutils.cmd方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_cmdline_options
# 需要導入模塊: import distutils [as 別名]
# 或者: from distutils import cmd [as 別名]
def get_cmdline_options(self):
"""Return a '{cmd: {opt:val}}' map of all command-line options
Option names are all long, but do not include the leading '--', and
contain dashes rather than underscores. If the option doesn't take
an argument (e.g. '--quiet'), the 'val' is 'None'.
Note that options provided by config files are intentionally excluded.
"""
d = {}
for cmd, opts in self.command_options.items():
for opt, (src, val) in opts.items():
if src != "command line":
continue
opt = opt.replace('_', '-')
if val == 0:
cmdobj = self.get_command_obj(cmd)
neg_opt = self.negative_opt.copy()
neg_opt.update(getattr(cmdobj, 'negative_opt', {}))
for neg, pos in neg_opt.items():
if pos == opt:
opt = neg
val = None
break
else:
raise AssertionError("Shouldn't be able to get here")
elif val == 1:
val = None
d.setdefault(cmd, {})[opt] = val
return d
示例2: create_command
# 需要導入模塊: import distutils [as 別名]
# 或者: from distutils import cmd [as 別名]
def create_command(text, commands):
"""Creates a custom setup.py command."""
class CustomCommand(BaseCommand):
description = text
def run(self):
for cmd in commands:
subprocess.check_call(cmd)
return CustomCommand
示例3: run
# 需要導入模塊: import distutils [as 別名]
# 或者: from distutils import cmd [as 別名]
def run(self):
pattern = "vies/locale/*/LC_MESSAGES/django.po"
for file in glob.glob(pattern):
cmd = ["msgfmt", "-c"]
name, ext = os.path.splitext(file)
cmd += ["-o", "%s.mo" % name]
cmd += ["%s.po" % name]
self.announce(
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec
示例4: run
# 需要導入模塊: import distutils [as 別名]
# 或者: from distutils import cmd [as 別名]
def run(self):
# shamelessly lifted from setuptools.command.test.test.run()
dist = self.distribution
if dist.install_requires:
dist.fetch_build_eggs(dist.install_requires)
if dist.tests_require:
dist.fetch_build_eggs(dist.tests_require)
cmd = self._test_cmd_string()
if self.dry_run:
self.announce("skipping '%s' (dry run)" % (cmd,))
else:
self.announce("running '%s'" % (cmd,))
self.with_project_on_sys_path(self.run_tests)
示例5: run
# 需要導入模塊: import distutils [as 別名]
# 或者: from distutils import cmd [as 別名]
def run(self):
for cmd in pipenv_setup:
assert os.system(cmd) == 0
print(
"\npipenv run pytest runs the tests"
"\npipenv shell enters the virtualenv"
)