def installed(package, version):
if not exists(package):<EOL><INDENT>return False<EOL><DEDENT>number, comparator = _split_version_specifier(version)<EOL>modversion = _query(package, '<STR_LIT>')<EOL>try:<EOL><INDENT>result = _compare_versions(modversion, number)<EOL><DEDENT>except ValueError:<EOL><INDENT>msg = "<STR_LIT>".format(version)<EOL>raise ValueError(msg)<EOL><DEDENT>if comparator in ('<STR_LIT>', '<STR_LIT:=>', '<STR_LIT>'):<EOL><INDENT>return result == <NUM_LIT:0><EOL><DEDENT>if comparator == '<STR_LIT:>>':<EOL><INDENT>return result > <NUM_LIT:0><EOL><DEDENT>if comparator == '<STR_LIT>':<EOL><INDENT>return result >= <NUM_LIT:0><EOL><DEDENT>if comparator == '<STR_LIT:<>':<EOL><INDENT>return result < <NUM_LIT:0><EOL><DEDENT>if comparator == '<STR_LIT>':<EOL><INDENT>return result <= <NUM_LIT:0><EOL><DEDENT>
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``.