code: def installed(package, version):
      
      if not exists(package):
          return False
  
      number, comparator = _split_version_specifier(version)
      modversion = _query(package, '--modversion')
  
      try:
          result = _compare_versions(modversion, number)
      except ValueError:
          msg = "{0} is not a correct version specifier".format(version)
          raise ValueError(msg)
  
      if comparator in ('', '=', '=='):
          return result == 0
  
      if comparator == '>':
          return result > 0
  
      if comparator == '>=':
          return result >= 0
  
      if comparator == '<':
          return result < 0
  
      if comparator == '<=':
          return result <= 0
docs: Check if the package meets the required version.
  
      The version specifier consists of an optional comparator (one of =, ==, >,
      <, >=, <=) and an arbitrarily long version number separated by dots. The
      should be as you would expect, e.g. for an installed version '0.1.2' of
      package 'foo':
  
      >>> installed('foo', '==0.1.2')
      True
      >>> installed('foo', '<0.1')
      False
      >>> installed('foo', '>= 0.0.4')
      True
  
      If ``pkg-config`` not on path, raises ``EnvironmentError``.