from typing import Any
from typing import Optional
import pkg_resources


def get_pkg_version(pkg: Any) -> Optional[str]:
    """Get the python package version.

    pkg needs to be the package name from setup.py or the name used to
    install from pypi.
    """
    try:
        return pkg_resources.get_distribution(pkg).version
    except:
        return None