code: def install_build_requires(pkg_targets):
      def pip_install(pkg_name, pkg_vers=None):
          pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name
          print '[WARNING] %s not found, attempting to install using a raw "pip install" call!' % pkg_name_version
          subprocess.Popen('pip install %s' % pkg_name_version, shell=True).communicate()
      def get_pkg_info(pkg):
          pkg_name, pkg_vers = None, None
          if '==' in pkg:
              pkg_name, pkg_vers = pkg.split('==')
          else:
              pkg_name = pkg.replace('>', '').replace('<', '').split('=')[0]
          return pkg_name, pkg_vers
      for pkg in pkg_targets:
          pkg_name, pkg_vers = get_pkg_info(pkg)
          try:
              pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name
              if pkg_vers:
                  version = getattr(importlib.import_module(pkg_name), '__version__')
                  if version != pkg_vers:
                      pip_install(pkg_name, pkg_vers)
              else:
                  importlib.import_module(pkg_name)
          except ImportError:
              pip_install(pkg_name, pkg_vers)