示例#1
0
 def test_backend_plugin_ordering(self):
   def reg_alias():
     return BuildFileAliases(targets={'override-alias': DummyTarget2})
   self.working_set.add(self.get_mock_plugin('pluginalias', '0.0.1', alias=reg_alias))
   plugins=['pluginalias==0.0.1']
   aliases = BuildFileAliases(targets={'override-alias': DummyTarget})
   with self.create_register(build_file_aliases=lambda: aliases) as backend_module:
     backends=[backend_module]
     load_backends_and_plugins(plugins, self.working_set, backends,
                               build_configuration=self.build_configuration)
   # The backend should load first, then the plugins, therefore the alias registered in
   # the plugin will override the alias registered by the backend
   registered_aliases = self.build_configuration.registered_aliases()
   self.assertEqual(DummyTarget2, registered_aliases.target_types['override-alias'])
 def test_backend_plugin_ordering(self):
   def reg_alias():
     return BuildFileAliases(targets={'override-alias': DummyTarget2})
   self.working_set.add(self.get_mock_plugin('pluginalias', '0.0.1', alias=reg_alias))
   plugins=['pluginalias==0.0.1']
   aliases = BuildFileAliases(targets={'override-alias': DummyTarget})
   with self.create_register(build_file_aliases=lambda: aliases) as backend_module:
     backends=[backend_module]
     load_backends_and_plugins(plugins, self.working_set, backends,
                               build_configuration=self.build_configuration)
   # The backend should load first, then the plugins, therefore the alias registered in
   # the plugin will override the alias registered by the backend
   registered_aliases = self.build_configuration.registered_aliases()
   self.assertEqual(DummyTarget2, registered_aliases.target_types['override-alias'])
示例#3
0
def _initialize_build_configuration(
    plugin_resolver: PluginResolver,
    options_bootstrapper: OptionsBootstrapper,
    env: CompleteEnvironment,
) -> BuildConfiguration:
    """Initialize a BuildConfiguration for the given OptionsBootstrapper.

    NB: This method:
      1. has the side-effect of (idempotently) adding PYTHONPATH entries for this process
      2. is expensive to call, because it might resolve plugins from the network
    """

    bootstrap_options = options_bootstrapper.get_bootstrap_options().for_global_scope()
    working_set = plugin_resolver.resolve(options_bootstrapper, env)

    # Add any extra paths to python path (e.g., for loading extra source backends).
    for path in bootstrap_options.pythonpath:
        if path not in sys.path:
            sys.path.append(path)
            pkg_resources.fixup_namespace_packages(path)

    # Load plugins and backends.
    return load_backends_and_plugins(
        bootstrap_options.plugins,
        working_set,
        bootstrap_options.backend_packages,
    )
示例#4
0
  def _load_plugins(self, working_set, python_paths, plugins, backend_packages):
    # Add any extra paths to python path (e.g., for loading extra source backends).
    for path in python_paths:
      if path not in sys.path:
        sys.path.append(path)
        pkg_resources.fixup_namespace_packages(path)

    # Load plugins and backends.
    return load_backends_and_plugins(plugins, working_set, backend_packages)
示例#5
0
  def _load_plugins(self, working_set, python_paths, plugins, backend_packages):
    # Add any extra paths to python path (e.g., for loading extra source backends).
    for path in python_paths:
      if path not in sys.path:
        sys.path.append(path)
        pkg_resources.fixup_namespace_packages(path)

    # Load plugins and backends.
    return load_backends_and_plugins(plugins, working_set, backend_packages)
示例#6
0
    def _load_plugins(self):
        # Add any extra paths to python path (e.g., for loading extra source backends).
        for path in self._bootstrap_options.pythonpath:
            if path not in sys.path:
                sys.path.append(path)
                pkg_resources.fixup_namespace_packages(path)

        # Load plugins and backends.
        return load_backends_and_plugins(
            self._bootstrap_options.plugins, self._bootstrap_options.plugins2,
            self._working_set, self._bootstrap_options.backend_packages,
            self._bootstrap_options.backend_packages2, BuildConfiguration())
  def _load_plugins(self, working_set, python_paths, plugins, backend_packages):
    """Load backends and plugins.

    :returns: A `BuildConfiguration` object constructed during backend/plugin loading.
    """
    # Add any extra paths to python path (e.g., for loading extra source backends).
    for path in python_paths:
      if path not in sys.path:
        sys.path.append(path)
        pkg_resources.fixup_namespace_packages(path)

    # Load plugins and backends.
    return load_backends_and_plugins(plugins, working_set, backend_packages)
示例#8
0
  def _load_plugins(self, working_set, python_paths, plugins, backend_packages):
    """Load backends and plugins.

    :returns: A `BuildConfiguration` object constructed during backend/plugin loading.
    """
    # Add any extra paths to python path (e.g., for loading extra source backends).
    for path in python_paths:
      if path not in sys.path:
        sys.path.append(path)
        pkg_resources.fixup_namespace_packages(path)

    # Load plugins and backends.
    return load_backends_and_plugins(plugins, working_set, backend_packages)
示例#9
0
    def test_backend_plugin_ordering(self):
        def reg_alias():
            return BuildFileAliases(objects={"override-alias": DummyObject2})

        self.working_set.add(self.get_mock_plugin("pluginalias", "0.0.1", alias=reg_alias))
        plugins = ["pluginalias==0.0.1"]
        aliases = BuildFileAliases(objects={"override-alias": DummyObject1})
        with self.create_register(build_file_aliases=lambda: aliases) as backend_module:
            backends = [backend_module]
            build_configuration = load_backends_and_plugins(
                plugins, self.working_set, backends, bc_builder=self.bc_builder,
            )
        # The backend should load first, then the plugins, therefore the alias registered in
        # the plugin will override the alias registered by the backend
        registered_aliases = build_configuration.registered_aliases
        self.assertEqual(DummyObject2, registered_aliases.objects["override-alias"])