Skip to content

Commit 540df17

Browse files
committed
Remove usage of distutils
This module has been deprecated. See PEP 632: https://www.python.org/dev/peps/pep-0632/
1 parent b2e7687 commit 540df17

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cmake-init/cmake_init.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import sys
3232
import zipfile
3333

34-
from distutils.version import LooseVersion
35-
3634
__version__ = "0.21.5"
3735

3836
is_windows = os.name == "nt"
@@ -235,16 +233,24 @@ def write_dir(path, d, overwrite, zip_path):
235233
write_dir(next_path, d, overwrite, entry)
236234

237235

238-
def git_init(cwd):
239-
branch = ""
236+
def determine_git_version():
240237
git_version_out = \
241238
subprocess.run("git --version", shell=True, capture_output=True)
242239
if git_version_out.returncode != 0:
240+
return None
241+
git_version_str = str(git_version_out.stdout[12:], sys.stdout.encoding)
242+
git_version = list(map(int, git_version_str.rstrip().split(".")[:3]))
243+
if len(git_version) < 3:
244+
git_version += [0] * (3 - len(git_version))
245+
return tuple(git_version)
246+
247+
def git_init(cwd):
248+
git_version = determine_git_version()
249+
if git_version is None:
243250
print("\nGit can't be found! Can't initialize git for the project.\n")
244251
return
245-
git_version_str = str(git_version_out.stdout[12:], sys.stdout.encoding)
246-
git_version = LooseVersion(git_version_str.rstrip())
247-
if LooseVersion("2.28.0") <= git_version:
252+
branch = ""
253+
if (2, 28, 0) <= git_version:
248254
branch = " -b master"
249255
subprocess.run(f"git init{branch}", shell=True, check=True, cwd=cwd)
250256
print("""

0 commit comments

Comments
 (0)