Skip to content

Commit 6e9b5dd

Browse files
Merge pull request #224 from RonnyPfannschmidt/parse-version-fix
fix #223 - dont depend on SetuptoolsVersion as its dropped in v39
2 parents 0373c11 + 4793406 commit 6e9b5dd

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ v1.16.0
88
* avoid shlex.split on windows
99
* fix #218 - better handling of mercurial edge-cases with tag commits
1010
being considered as the tagged commit
11+
* fix #223 - remove the dependency on the interal SetupttoolsVersion
12+
as it was removed after long-standing deprecation
1113

1214
v1.15.7
1315
======

setuptools_scm/version.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77
from pkg_resources import iter_entry_points
88

99
from distutils import log
10+
from pkg_resources import parse_version
1011

11-
try:
12-
from pkg_resources import parse_version, SetuptoolsVersion
13-
except ImportError as e:
14-
parse_version = SetuptoolsVersion = None
12+
13+
def _get_version_class():
14+
modern_version = parse_version("1.0")
15+
if isinstance(modern_version, tuple):
16+
return None
17+
else:
18+
return type(modern_version)
19+
20+
21+
VERSION_CLASS = _get_version_class()
1522

1623

1724
def _warn_if_setuptools_outdated():
18-
if parse_version is None:
25+
if VERSION_CLASS is None:
1926
log.warn("your setuptools is too old (<12)")
2027
log.warn("setuptools_scm functionality is degraded")
2128

@@ -44,7 +51,7 @@ def tag_to_version(tag):
4451
return version
4552
version = parse_version(version)
4653
trace('version', repr(version))
47-
if isinstance(version, SetuptoolsVersion):
54+
if isinstance(version, VERSION_CLASS):
4855
return version
4956

5057

@@ -92,7 +99,7 @@ def format_choice(self, clean_format, dirty_format):
9299
def _parse_tag(tag, preformatted):
93100
if preformatted:
94101
return tag
95-
if SetuptoolsVersion is None or not isinstance(tag, SetuptoolsVersion):
102+
if VERSION_CLASS is None or not isinstance(tag, VERSION_CLASS):
96103
tag = tag_to_version(tag)
97104
return tag
98105

0 commit comments

Comments
 (0)