Skip to content

Commit 5a68b0e

Browse files
committed
Generate bpython._version for tarballs from github (fixes bpython#643)
1 parent 8f7f025 commit 5a68b0e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ def git_describe_to_python_version(version):
105105
except OSError:
106106
pass
107107

108+
if version == "unknown":
109+
# get version from directory name (tarballs downloaded from tags)
110+
# directories are named bpython-X.Y-release in this case
111+
basename = os.path.basename(os.path.dirname(__file__))
112+
basename_components = basename.split("-")
113+
if (
114+
len(basename_components) == 3
115+
and basename_components[0] == "bpython"
116+
and basename_components[2] == "release"
117+
):
118+
version = basename_components[1]
119+
108120
with open(version_file, "w") as vf:
109121
vf.write("# Auto-generated file, do not edit!\n")
110122
vf.write(f"__version__ = '{version}'\n")

0 commit comments

Comments
 (0)