本文整理汇总了Python中pants.option.options_bootstrapper.OptionsBootstrapper.get_full_options方法的典型用法代码示例。如果您正苦于以下问题:Python OptionsBootstrapper.get_full_options方法的具体用法?Python OptionsBootstrapper.get_full_options怎么用?Python OptionsBootstrapper.get_full_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.option.options_bootstrapper.OptionsBootstrapper
的用法示例。
在下文中一共展示了OptionsBootstrapper.get_full_options方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_full_options_caching
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_full_options_caching(self):
with temporary_file_path() as config:
args = self._config_path(config)
bootstrapper = OptionsBootstrapper(env={}, args=args)
opts1 = bootstrapper.get_full_options(
known_scope_infos=[ScopeInfo("", ScopeInfo.GLOBAL), ScopeInfo("foo", ScopeInfo.TASK)]
)
opts2 = bootstrapper.get_full_options(
known_scope_infos=[ScopeInfo("foo", ScopeInfo.TASK), ScopeInfo("", ScopeInfo.GLOBAL)]
)
self.assertIs(opts1, opts2)
opts3 = bootstrapper.get_full_options(
known_scope_infos=[
ScopeInfo("", ScopeInfo.GLOBAL),
ScopeInfo("foo", ScopeInfo.TASK),
ScopeInfo("", ScopeInfo.GLOBAL),
]
)
self.assertIs(opts1, opts3)
opts4 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo("", ScopeInfo.GLOBAL)])
self.assertIsNot(opts1, opts4)
opts5 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo("", ScopeInfo.GLOBAL)])
self.assertIs(opts4, opts5)
self.assertIsNot(opts1, opts5)
示例2: test_create_bootstrapped_multiple_config_override
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_create_bootstrapped_multiple_config_override(self):
# check with multiple config files, the latest values always get taken
# in this case worker_count will be overwritten, while fruit stays the same
with temporary_file() as fp:
fp.write(dedent("""
[compile.apt]
worker_count: 1
[fruit]
apple: red
"""))
fp.close()
args = ['--config-override={}'.format(fp.name)] + self._config_path(fp.name)
bootstrapper_single_config = OptionsBootstrapper(args=args)
opts_single_config = bootstrapper_single_config.get_full_options(known_scope_infos=[
ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('compile.apt', ScopeInfo.TASK),
ScopeInfo('fruit', ScopeInfo.TASK),
])
# So we don't choke on these on the cmd line.
opts_single_config.register('', '--pants-config-files')
opts_single_config.register('', '--config-override', type=list)
opts_single_config.register('compile.apt', '--worker-count')
opts_single_config.register('fruit', '--apple')
self.assertEquals('1', opts_single_config.for_scope('compile.apt').worker_count)
self.assertEquals('red', opts_single_config.for_scope('fruit').apple)
with temporary_file() as fp2:
fp2.write(dedent("""
[compile.apt]
worker_count: 2
"""))
fp2.close()
args = ['--config-override={}'.format(fp.name),
'--config-override={}'.format(fp2.name)] + self._config_path(fp.name)
bootstrapper_double_config = OptionsBootstrapper(args=args)
opts_double_config = bootstrapper_double_config.get_full_options(known_scope_infos=[
ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('compile.apt', ScopeInfo.TASK),
ScopeInfo('fruit', ScopeInfo.TASK),
])
# So we don't choke on these on the cmd line.
opts_double_config.register('', '--pants-config-files')
opts_double_config.register('', '--config-override', type=list)
opts_double_config.register('compile.apt', '--worker-count')
opts_double_config.register('fruit', '--apple')
self.assertEquals('2', opts_double_config.for_scope('compile.apt').worker_count)
self.assertEquals('red', opts_double_config.for_scope('fruit').apple)
示例3: test_create_bootstrapped_multiple_config_override
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_create_bootstrapped_multiple_config_override(self):
# check with multiple config files, the latest values always get taken
# in this case strategy will be overwritten, while fruit stays the same
with temporary_file() as fp:
fp.write(dedent("""
[compile.apt]
strategy: global
[fruit]
apple: red
"""))
fp.close()
bootstrapper_single_config = OptionsBootstrapper(configpath=fp.name,
args=['--config-override={}'.format(fp.name)])
opts_single_config = bootstrapper_single_config.get_full_options(known_scope_infos=[
ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('compile.apt', ScopeInfo.TASK),
ScopeInfo('fruit', ScopeInfo.TASK),
])
opts_single_config.register('', '--config-override') # So we don't choke on it on the cmd line.
opts_single_config.register('compile.apt', '--strategy')
opts_single_config.register('fruit', '--apple')
self.assertEquals('global', opts_single_config.for_scope('compile.apt').strategy)
self.assertEquals('red', opts_single_config.for_scope('fruit').apple)
with temporary_file() as fp2:
fp2.write(dedent("""
[compile.apt]
strategy: isolated
"""))
fp2.close()
bootstrapper_double_config = OptionsBootstrapper(
configpath=fp.name,
args=['--config-override={}'.format(fp.name),
'--config-override={}'.format(fp2.name)])
opts_double_config = bootstrapper_double_config.get_full_options(known_scope_infos=[
ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('compile.apt', ScopeInfo.TASK),
ScopeInfo('fruit', ScopeInfo.TASK),
])
opts_double_config.register('', '--config-override') # So we don't choke on it on the cmd line.
opts_double_config.register('compile.apt', '--strategy')
opts_double_config.register('fruit', '--apple')
self.assertEquals('isolated', opts_double_config.for_scope('compile.apt').strategy)
self.assertEquals('red', opts_double_config.for_scope('fruit').apple)
示例4: test_create_bootstrapped_options
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_create_bootstrapped_options(self):
# Check that we can set a bootstrap option from a cmd-line flag and have that interpolate
# correctly into regular config.
with temporary_file() as fp:
fp.write(
dedent(
"""
[foo]
bar: %(pants_workdir)s/baz
[fruit]
apple: %(pants_supportdir)s/banana
"""
)
)
fp.close()
args = ["--pants-workdir=/qux"] + self._config_path(fp.name)
bootstrapper = OptionsBootstrapper(env={"PANTS_SUPPORTDIR": "/pear"}, args=args)
opts = bootstrapper.get_full_options(
known_scope_infos=[
ScopeInfo("", ScopeInfo.GLOBAL),
ScopeInfo("foo", ScopeInfo.TASK),
ScopeInfo("fruit", ScopeInfo.TASK),
]
)
# So we don't choke on these on the cmd line.
opts.register("", "--pants-workdir")
opts.register("", "--pants-config-files")
opts.register("foo", "--bar")
opts.register("fruit", "--apple")
self.assertEquals("/qux/baz", opts.for_scope("foo").bar)
self.assertEquals("/pear/banana", opts.for_scope("fruit").apple)
示例5: test_create_bootstrapped_options
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_create_bootstrapped_options(self):
# Check that we can set a bootstrap option from a cmd-line flag and have that interpolate
# correctly into regular config.
with temporary_file() as fp:
fp.write(dedent("""
[foo]
bar: %(pants_workdir)s/baz
[fruit]
apple: %(pants_supportdir)s/banana
"""))
fp.close()
bootstrapper = OptionsBootstrapper(env={
'PANTS_SUPPORTDIR': '/pear'
},
configpath=fp.name,
args=['--pants-workdir=/qux'])
opts = bootstrapper.get_full_options(known_scope_infos=[
ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('foo', ScopeInfo.TASK),
ScopeInfo('fruit', ScopeInfo.TASK)
])
opts.register('', '--pants-workdir') # So we don't choke on it on the cmd line.
opts.register('foo', '--bar')
opts.register('fruit', '--apple')
self.assertEquals('/qux/baz', opts.for_scope('foo').bar)
self.assertEquals('/pear/banana', opts.for_scope('fruit').apple)
示例6: setup
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def setup(self):
options_bootstrapper = OptionsBootstrapper()
# Force config into the cache so we (and plugin/backend loading code) can use it.
# TODO: Plumb options in explicitly.
options_bootstrapper.get_bootstrap_options()
self.config = Config.from_cache()
# Add any extra paths to python path (eg for loading extra source backends)
extra_paths = self.config.getlist('backends', 'python-path', [])
if extra_paths:
sys.path.extend(extra_paths)
# Load plugins and backends.
backend_packages = self.config.getlist('backends', 'packages', [])
plugins = self.config.getlist('backends', 'plugins', [])
build_configuration = load_plugins_and_backends(plugins, backend_packages)
# Now that plugins and backends are loaded, we can gather the known scopes.
self.targets = []
known_scopes = ['']
for goal in Goal.all():
# Note that enclosing scopes will appear before scopes they enclose.
known_scopes.extend(filter(None, goal.known_scopes()))
# Now that we have the known scopes we can get the full options.
self.options = options_bootstrapper.get_full_options(known_scopes=known_scopes)
self.register_options()
self.run_tracker = RunTracker.from_config(self.config)
report = initial_reporting(self.config, self.run_tracker)
self.run_tracker.start(report)
url = self.run_tracker.run_info.get_info('report_url')
if url:
self.run_tracker.log(Report.INFO, 'See a report at: %s' % url)
else:
self.run_tracker.log(Report.INFO, '(To run a reporting server: ./pants server)')
self.build_file_parser = BuildFileParser(build_configuration=build_configuration,
root_dir=self.root_dir,
run_tracker=self.run_tracker)
self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
self.build_graph = BuildGraph(run_tracker=self.run_tracker,
address_mapper=self.address_mapper)
with self.run_tracker.new_workunit(name='bootstrap', labels=[WorkUnit.SETUP]):
# construct base parameters to be filled in for BuildGraph
for path in self.config.getlist('goals', 'bootstrap_buildfiles', default=[]):
build_file = BuildFile.from_cache(root_dir=self.root_dir, relpath=path)
# TODO(pl): This is an unfortunate interface leak, but I don't think
# in the long run that we should be relying on "bootstrap" BUILD files
# that do nothing except modify global state. That type of behavior
# (e.g. source roots, goal registration) should instead happen in
# project plugins, or specialized configuration files.
self.build_file_parser.parse_build_file_family(build_file)
# Now that we've parsed the bootstrap BUILD files, and know about the SCM system.
self.run_tracker.run_info.add_scm_info()
self._expand_goals_and_specs()
示例7: test_full_options_caching
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def test_full_options_caching(self):
with temporary_file_path() as config:
bootstrapper = OptionsBootstrapper(env={}, configpath=config, args=[])
opts1 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('foo', ScopeInfo.TASK)])
opts2 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo('foo', ScopeInfo.TASK),
ScopeInfo('', ScopeInfo.GLOBAL)])
self.assertIs(opts1, opts2)
opts3 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo('', ScopeInfo.GLOBAL),
ScopeInfo('foo', ScopeInfo.TASK),
ScopeInfo('', ScopeInfo.GLOBAL)])
self.assertIs(opts1, opts3)
opts4 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo('', ScopeInfo.GLOBAL)])
self.assertIsNot(opts1, opts4)
opts5 = bootstrapper.get_full_options(known_scope_infos=[ScopeInfo('', ScopeInfo.GLOBAL)])
self.assertIs(opts4, opts5)
self.assertIsNot(opts1, opts5)
示例8: setup
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def setup(self):
options_bootstrapper = OptionsBootstrapper()
bootstrap_options = options_bootstrapper.get_bootstrap_options()
# Get logging setup prior to loading backends so that they can log as needed.
self._setup_logging(bootstrap_options.for_global_scope())
# Add any extra paths to python path (eg for loading extra source backends)
for path in bootstrap_options.for_global_scope().pythonpath:
sys.path.append(path)
pkg_resources.fixup_namespace_packages(path)
# Load plugins and backends.
plugins = bootstrap_options.for_global_scope().plugins
backend_packages = bootstrap_options.for_global_scope().backend_packages
build_configuration = load_plugins_and_backends(plugins, backend_packages)
# Now that plugins and backends are loaded, we can gather the known scopes.
self.targets = []
known_scope_infos = [ScopeInfo.for_global_scope()]
# Add scopes for all needed subsystems.
subsystems = (set(self.subsystems) | Goal.subsystems() | build_configuration.subsystems())
for subsystem in subsystems:
known_scope_infos.append(ScopeInfo(subsystem.options_scope, ScopeInfo.GLOBAL_SUBSYSTEM))
# Add scopes for all tasks in all goals.
for goal in Goal.all():
known_scope_infos.extend(filter(None, goal.known_scope_infos()))
# Now that we have the known scopes we can get the full options.
self.options = options_bootstrapper.get_full_options(known_scope_infos)
self.register_options(subsystems)
# Make the options values available to all subsystems.
Subsystem._options = self.options
# Now that we have options we can instantiate subsystems.
self.run_tracker = RunTracker.global_instance()
self.reporting = Reporting.global_instance()
report = self.reporting.initial_reporting(self.run_tracker)
self.run_tracker.start(report)
url = self.run_tracker.run_info.get_info('report_url')
if url:
self.run_tracker.log(Report.INFO, 'See a report at: {}'.format(url))
else:
self.run_tracker.log(Report.INFO, '(To run a reporting server: ./pants server)')
self.build_file_parser = BuildFileParser(build_configuration=build_configuration,
root_dir=self.root_dir,
run_tracker=self.run_tracker)
rev = self.options.for_global_scope().build_file_rev
if rev:
ScmBuildFile.set_rev(rev)
ScmBuildFile.set_scm(get_scm())
build_file_type = ScmBuildFile
else:
build_file_type = FilesystemBuildFile
self.address_mapper = BuildFileAddressMapper(self.build_file_parser, build_file_type)
self.build_graph = BuildGraph(run_tracker=self.run_tracker,
address_mapper=self.address_mapper)
# TODO(John Sirois): Kill when source root registration is lifted out of BUILD files.
with self.run_tracker.new_workunit(name='bootstrap', labels=[WorkUnit.SETUP]):
source_root_bootstrapper = SourceRootBootstrapper.global_instance()
source_root_bootstrapper.bootstrap(self.address_mapper, self.build_file_parser)
self._expand_goals_and_specs()
# Now that we've parsed the bootstrap BUILD files, and know about the SCM system.
self.run_tracker.run_info.add_scm_info()
示例9: setup
# 需要导入模块: from pants.option.options_bootstrapper import OptionsBootstrapper [as 别名]
# 或者: from pants.option.options_bootstrapper.OptionsBootstrapper import get_full_options [as 别名]
def setup(self):
options_bootstrapper = OptionsBootstrapper()
# Force config into the cache so we (and plugin/backend loading code) can use it.
# TODO: Plumb options in explicitly.
bootstrap_options = options_bootstrapper.get_bootstrap_options()
self.config = Config.from_cache()
# Get logging setup prior to loading backends so that they can log as needed.
self._setup_logging(bootstrap_options.for_global_scope())
# Add any extra paths to python path (eg for loading extra source backends)
for path in bootstrap_options.for_global_scope().pythonpath:
sys.path.append(path)
pkg_resources.fixup_namespace_packages(path)
# Load plugins and backends.
backend_packages = self.config.getlist('backends', 'packages', [])
plugins = self.config.getlist('backends', 'plugins', [])
build_configuration = load_plugins_and_backends(plugins, backend_packages)
# Now that plugins and backends are loaded, we can gather the known scopes.
self.targets = []
known_scopes = ['']
# Add scopes for global subsystem instances.
for subsystem_type in set(self.subsystems) | Goal.global_subsystem_types():
known_scopes.append(subsystem_type.qualify_scope(Options.GLOBAL_SCOPE))
# Add scopes for all tasks in all goals.
for goal in Goal.all():
# Note that enclosing scopes will appear before scopes they enclose.
known_scopes.extend(filter(None, goal.known_scopes()))
# Now that we have the known scopes we can get the full options.
self.options = options_bootstrapper.get_full_options(known_scopes=known_scopes)
self.register_options()
# Make the options values available to all subsystems.
Subsystem._options = self.options
# Now that we have options we can instantiate subsystems.
self.run_tracker = RunTracker.global_instance()
report = initial_reporting(self.config, self.run_tracker)
self.run_tracker.start(report)
url = self.run_tracker.run_info.get_info('report_url')
if url:
self.run_tracker.log(Report.INFO, 'See a report at: {}'.format(url))
else:
self.run_tracker.log(Report.INFO, '(To run a reporting server: ./pants server)')
self.build_file_parser = BuildFileParser(build_configuration=build_configuration,
root_dir=self.root_dir,
run_tracker=self.run_tracker)
rev = self.options.for_global_scope().build_file_rev
if rev:
ScmBuildFile.set_rev(rev)
ScmBuildFile.set_scm(get_scm())
build_file_type = ScmBuildFile
else:
build_file_type = FilesystemBuildFile
self.address_mapper = BuildFileAddressMapper(self.build_file_parser, build_file_type)
self.build_graph = BuildGraph(run_tracker=self.run_tracker,
address_mapper=self.address_mapper)
with self.run_tracker.new_workunit(name='bootstrap', labels=[WorkUnit.SETUP]):
# construct base parameters to be filled in for BuildGraph
for path in self.config.getlist('goals', 'bootstrap_buildfiles', default=[]):
build_file = self.address_mapper.from_cache(root_dir=self.root_dir, relpath=path)
# TODO(pl): This is an unfortunate interface leak, but I don't think
# in the long run that we should be relying on "bootstrap" BUILD files
# that do nothing except modify global state. That type of behavior
# (e.g. source roots, goal registration) should instead happen in
# project plugins, or specialized configuration files.
self.build_file_parser.parse_build_file_family(build_file)
self._expand_goals_and_specs()
# Now that we've parsed the bootstrap BUILD files, and know about the SCM system.
self.run_tracker.run_info.add_scm_info()