Skip to content

Commit a22a0b9

Browse files
committed
enabling compatibility with older versions of pkg_utils
1 parent 3648165 commit a22a0b9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

setup.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import re
12
import setuptools
3+
import subprocess
4+
import sys
25
try:
3-
import pkg_utils
4-
except ImportError:
5-
import subprocess
6-
import sys
7-
subprocess.check_call(
8-
[sys.executable, "-m", "pip", "install", "pkg_utils"])
9-
import pkg_utils
6+
result = subprocess.run(
7+
[sys.executable, "-m", "pip", "show", "pkg_utils"],
8+
check=True, capture_output=True)
9+
match = re.search(r'\nVersion: (.*?)\n', result.stdout.decode(), re.DOTALL)
10+
assert match and tuple(match.group(1).split('.')) >= ('0', '0', '5')
11+
except (subprocess.CalledProcessError, AssertionError):
12+
subprocess.run(
13+
[sys.executable, "-m", "pip", "install", "-U", "pkg_utils"],
14+
check=True)
1015
import os
16+
import pkg_utils
1117

1218
name = 'wc_kb'
1319
dirname = os.path.dirname(__file__)

0 commit comments

Comments
 (0)