import pkg_resources
import setuptools_scm
package_name = "Package name goes here..."
try:
# Try to get version number from repository
VERSION = setuptools_scm.get_version()
except LookupError:
# Not in repo, so try to get version number from pkg_resources
try:
VERSION = pkg_resources.get_distribution(package_name).version
except pkg_resources.DistributionNotFound:
# Not installed?
VERSION = "Unknown"