Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
record associated with the package, and if there is no such record
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)
def my_get_script_args(*args, **kwargs):
return _main_module()._orig_get_script_args(*args, **kwargs)
packaging.override_get_script_args = my_get_script_args
easy_install.get_script_args = my_get_script_args
# another hack to allow setup from tarball.
orig_get_version = packaging.get_version
def my_get_version(package_name, pre_version=None):
if package_name == 'ryu':
return str(version)
return orig_get_version(package_name, pre_version)
packaging.get_version = my_get_version
# pbr's setup_hook replaces easy_install.get_script_args with
# their own version, override_get_script_args, prefering simpler
# scripts which are not aware of multi-version.
# prevent that by doing the opposite. it's a horrible hack
# but we are in patching wars already...
from pbr import packaging
def my_get_script_args(*args, **kwargs):
return _main_module()._orig_get_script_args(*args, **kwargs)
packaging.override_get_script_args = my_get_script_args
easy_install.get_script_args = my_get_script_args
# another hack to allow setup from tarball.
orig_get_version = packaging.get_version
def my_get_version(package_name, pre_version=None):
if package_name == 'yabmp':
return str(version)
return orig_get_version(package_name, pre_version)
packaging.get_version = my_get_version
record associated with the package, and if there is no such record
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)