Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
falls back to the logic sdist would use.
"""
# Lazy import because pkg_resources is costly to import so defer until
# we absolutely need it.
import pkg_resources
try:
requirement = pkg_resources.Requirement.parse(self.package)
provider = pkg_resources.get_provider(requirement)
result_string = provider.version
except pkg_resources.DistributionNotFound:
# The most likely cause for this is running tests in a tree
# produced from a tarball where the package itself has not been
# installed into anything. Revert to setup-time logic.
from pbr import packaging
result_string = packaging.get_version(self.package)
return SemanticVersion.from_pip_string(result_string)