Skip to content

Commit f94c1fe

Browse files
committed
only get version if _version.py doesn't exist
1 parent d7ec78e commit f94c1fe

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

setup.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,24 @@ def convert_sls_version_to_python(sls_version: str) -> str:
5454
return python_version
5555

5656

57-
try:
58-
gitversion = (
59-
subprocess.check_output(
60-
"git describe --tags --always --first-parent".split()
57+
if not path.exists(VERSION_PY_PATH):
58+
try:
59+
gitversion = (
60+
subprocess.check_output(
61+
"git describe --tags --always --first-parent".split()
62+
)
63+
.decode()
64+
.strip()
6165
)
62-
.decode()
63-
.strip()
64-
)
65-
open(VERSION_PY_PATH, "w").write(
66-
'__version__ = "{}"\n'.format(
67-
convert_sls_version_to_python(gitversion)
66+
open(VERSION_PY_PATH, "w").write(
67+
'__version__ = "{}"\n'.format(
68+
convert_sls_version_to_python(gitversion)
69+
)
6870
)
69-
)
70-
if not path.exists("build"):
71-
makedirs("build")
72-
except subprocess.CalledProcessError:
73-
print("outside git repo, not generating new version string")
71+
if not path.exists("build"):
72+
makedirs("build")
73+
except subprocess.CalledProcessError:
74+
print("outside git repo, not generating new version string")
7475
exec(open(VERSION_PY_PATH).read())
7576

7677

0 commit comments

Comments
 (0)