goalie.is_package_version

goalie.is_package_version(x: str, version: str, op: str = '>=') bool

Check whether an installed package satisfies a version constraint.

Parameters:
  • x (str) – Package name.

  • version (str) – Version string to compare against (e.g. "1.2.0").

  • op (str) – Comparison operator: ">=", ">", "==", "!=", "<", or "<=".

Returns:

True if the installed version satisfies the constraint. False if the package is not installed.

Return type:

bool

Raises:

ValueError – If op is not one of the supported operators.

Examples

>>> isinstance(is_package_version("goalie", "0.0.1"), bool)
True
>>> is_package_version("nonexistent_pkg_xyz_abc", "1.0.0")
False