Updates vendored subliminal to 2.1.0

Updates rarfile to 3.1
Updates stevedore to 3.5.0
Updates appdirs to 1.4.4
Updates click to 8.1.3
Updates decorator to 5.1.1
Updates dogpile.cache to 1.1.8
Updates pbr to 5.11.0
Updates pysrt to 1.1.2
Updates pytz to 2022.6
Adds importlib-metadata version 3.1.1
Adds typing-extensions version 4.1.1
Adds zipp version 3.11.0
This commit is contained in:
Labrys of Knossos 2022-11-29 00:08:39 -05:00
commit f05b09f349
694 changed files with 16621 additions and 11056 deletions

View file

@ -15,13 +15,24 @@
# under the License.
"""
Utilities for consuming the version from pkg_resources.
Utilities for consuming the version from importlib-metadata.
"""
import itertools
import operator
import sys
# TODO(stephenfin): Remove this once we drop support for Python < 3.8
if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata
use_importlib = True
else:
try:
import importlib_metadata
use_importlib = True
except ImportError:
use_importlib = False
def _is_int(string):
try:
@ -323,8 +334,8 @@ class SemanticVersion(object):
version number of the component to preserve sorting. (Used for
rpm support)
"""
if ((self._prerelease_type or self._dev_count)
and pre_separator is None):
if ((self._prerelease_type or self._dev_count) and
pre_separator is None):
segments = [self.decrement().brief_string()]
pre_separator = "."
else:
@ -431,12 +442,15 @@ class VersionInfo(object):
"""Obtain a version from pkg_resources or setup-time logic if missing.
This will try to get the version of the package from the pkg_resources
This will try to get the version of the package from the
record associated with the package, and if there is no such record
importlib_metadata record associated with the package, and if there
falls back to the logic sdist would use.
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)
@ -447,6 +461,25 @@ class VersionInfo(object):
# 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 _get_version_from_importlib_metadata(self):
"""Obtain a version from importlib or setup-time logic if missing.
This will try to get the version of the package from the
importlib_metadata record associated with the package, and if there
is no such record falls back to the logic sdist would use.
"""
try:
distribution = importlib_metadata.distribution(self.package)
result_string = distribution.version
except importlib_metadata.PackageNotFoundError:
# 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 release_string(self):
@ -459,7 +492,12 @@ class VersionInfo(object):
def semantic_version(self):
"""Return the SemanticVersion object for this version."""
if self._semantic is None:
self._semantic = self._get_version_from_pkg_resources()
# TODO(damami): simplify this once Python 3.8 is the oldest
# we support
if use_importlib:
self._semantic = self._get_version_from_importlib_metadata()
else:
self._semantic = self._get_version_from_pkg_resources()
return self._semantic
def version_string(self):