Skip to content

Commit

Permalink
fix #223 - dont depend on SetuptoolsVersion as its dropped in v39
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Mar 19, 2018
1 parent 0373c11 commit 4793406
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -8,6 +8,8 @@ v1.16.0
* avoid shlex.split on windows
* fix #218 - better handling of mercurial edge-cases with tag commits
being considered as the tagged commit
* fix #223 - remove the dependency on the interal SetupttoolsVersion
as it was removed after long-standing deprecation

v1.15.7
======
Expand Down
21 changes: 14 additions & 7 deletions setuptools_scm/version.py
Expand Up @@ -7,15 +7,22 @@
from pkg_resources import iter_entry_points

from distutils import log
from pkg_resources import parse_version

try:
from pkg_resources import parse_version, SetuptoolsVersion
except ImportError as e:
parse_version = SetuptoolsVersion = None

def _get_version_class():
modern_version = parse_version("1.0")
if isinstance(modern_version, tuple):
return None
else:
return type(modern_version)


VERSION_CLASS = _get_version_class()


def _warn_if_setuptools_outdated():
if parse_version is None:
if VERSION_CLASS is None:
log.warn("your setuptools is too old (<12)")
log.warn("setuptools_scm functionality is degraded")

Expand Down Expand Up @@ -44,7 +51,7 @@ def tag_to_version(tag):
return version
version = parse_version(version)
trace('version', repr(version))
if isinstance(version, SetuptoolsVersion):
if isinstance(version, VERSION_CLASS):
return version


Expand Down Expand Up @@ -92,7 +99,7 @@ def format_choice(self, clean_format, dirty_format):
def _parse_tag(tag, preformatted):
if preformatted:
return tag
if SetuptoolsVersion is None or not isinstance(tag, SetuptoolsVersion):
if VERSION_CLASS is None or not isinstance(tag, VERSION_CLASS):
tag = tag_to_version(tag)
return tag

Expand Down

0 comments on commit 4793406

Please sign in to comment.