<commit_before># coding=utf-8
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
                        unicode_literals, with_statement)

import hashlib
import logging
import os
import site

from pex import resolver
from pex.base import requirement_is_exact
from pkg_resources import working_set as global_working_set
from pkg_resources import Requirement
from wheel.install import WheelFile

from pants.option.global_options import GlobalOptionsRegistrar
from pants.python.python_repos import PythonRepos
from pants.subsystem.subsystem import Subsystem
from pants.util.dirutil import safe_mkdir, safe_open
from pants.util.memo import memoized_property
from pants.version import PANTS_SEMVER


logger = logging.getLogger(__name__)


class PluginResolver(object):
  @staticmethod
  def _is_wheel(path):
    return os.path.isfile(path) and path.endswith('.whl')

  @staticmethod
  def _activate_wheel(wheel_path):
    install_dir = '{}-install'.format(wheel_path)
    safe_mkdir(install_dir, clean=True)
    WheelFile(wheel_path).install(force=True,
                                  overrides={
                                    'purelib': install_dir,
                                    'headers': os.path.join(install_dir, 'headers'),
                                    'scripts': os.path.join(install_dir, 'bin'),
                                    'platlib': install_dir,
                                    'data': install_dir
                                  })
    # Activate any .pth files installed above.
    site.addsitedir(install_dir)
    return install_dir

  def __init__(self, options_bootstrapper):
    self._options_bootstrapper = options_bootstrapper

    bootstrap_options = self._options_bootstrapper.get_bootstrap_options().for_global_scope()
    self._plugin_requirements = bootstrap_options.plugins
    self._plugin_cache_dir = bootstrap_options.plugin_cache_dir

  def resolve(self, working_set=None):<commit_msg>Don't reinstall plugin wheels on every invocation. (#5506)<commit_after># coding=utf-8
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
                        unicode_literals, with_statement)

import hashlib
import logging
import os
import site

from pex import resolver
from pex.base import requirement_is_exact
from pkg_resources import working_set as global_working_set
from pkg_resources import Requirement
from wheel.install import WheelFile

from pants.option.global_options import GlobalOptionsRegistrar
from pants.python.python_repos import PythonRepos
from pants.subsystem.subsystem import Subsystem
from pants.util.contextutil import temporary_dir
from pants.util.dirutil import safe_mkdir, safe_open
from pants.util.memo import memoized_property
from pants.version import PANTS_SEMVER


logger = logging.getLogger(__name__)


class PluginResolver(object):
  @staticmethod
  def _is_wheel(path):
    return os.path.isfile(path) and path.endswith('.whl')

  @classmethod
  def _activate_wheel(cls, wheel_path):
    install_dir = '{}-install'.format(wheel_path)
    if not os.path.isdir(install_dir):
      with temporary_dir(root_dir=os.path.dirname(install_dir)) as tmp:
        cls._install_wheel(wheel_path, tmp)
        os.rename(tmp, install_dir)
    # Activate any .pth files installed above.
    site.addsitedir(install_dir)
    return install_dir

  @classmethod
  def _install_wheel(cls, wheel_path, install_dir):
    safe_mkdir(install_dir, clean=True)
    WheelFile(wheel_path).install(force=True,
                                  overrides={
                                    'purelib': install_dir,
                                    'headers': os.path.join(install_dir, 'headers'),
                                    'scripts': os.path.join(install_dir, 'bin'),
                                    'platlib': install_dir,
                                    'data': install_dir
                                  })

  def __init__(self, options_bootstrapper):
    self._options_bootstrapper = options_bootstrapper

    bootstrap_options = self._options_bootstrapper.get_bootstrap_options().for_global_scope()
    self._plugin_requirements = bootstrap_options.plugins
    self._plugin_cache_dir = bootstrap_options.plugin_cache_dir

  def resolve(self, working_set=None):
{'fraction_non_alphanumeric': 0.07330867957363497, 'fraction_numerical': 0.003915597128562106, 'mean_word_length': 3.087111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399453', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1235, 'n_words': 303}