|
21 | 21 | import os |
22 | 22 | import shutil |
23 | 23 | import sys |
| 24 | +import yaml |
| 25 | +import subprocess |
24 | 26 |
|
25 | 27 | from setuptools import find_packages |
26 | 28 | from setuptools.dist import Distribution |
@@ -67,6 +69,30 @@ def get_lib_path(): |
67 | 69 |
|
68 | 70 | LIB_LIST, __version__ = get_lib_path() |
69 | 71 |
|
| 72 | +def get_version(pkg_dir, main_branch = "master"): |
| 73 | + with open("VERSION.in") as fh: |
| 74 | + vinfo = yaml.load(fh.read(), Loader=yaml.BaseLoader) |
| 75 | + version = '.'.join([vinfo["major"], vinfo["minor"], vinfo["patch"]]) |
| 76 | + |
| 77 | + if 'GIT_HASH' in os.environ: |
| 78 | + # In tox the .git directory is not available so do this instead |
| 79 | + vinfo['git_hash'] = os.environ['GIT_HASH'] |
| 80 | + else: |
| 81 | + proc = subprocess.Popen(['git','log','-1','--format=%h'], stdout=subprocess.PIPE) |
| 82 | + proc.wait() |
| 83 | + if proc.returncode != 0: |
| 84 | + raise RuntimeError("ERROR: unable to execute git log") |
| 85 | + vinfo['git_hash'] = proc.stdout.read().decode('utf-8').rstrip() |
| 86 | + |
| 87 | + with open(pkg_dir + "/VERSION","w") as fh: |
| 88 | + fh.write(yaml.dump(vinfo)) |
| 89 | + |
| 90 | + # This comes from Jenkins for upstream/downstream builds |
| 91 | + if 'DEV_VERSION' in os.environ: |
| 92 | + version = version + ".dev0+" + os.environ['DEV_VERSION'] |
| 93 | + |
| 94 | + return version |
| 95 | + |
70 | 96 | if not os.getenv('CONDA_BUILD'): |
71 | 97 | curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) |
72 | 98 | for i, path in enumerate(LIB_LIST): |
@@ -107,8 +133,8 @@ def get_lib_path(): |
107 | 133 | "data_files": [('topi', LIB_LIST)] |
108 | 134 | } |
109 | 135 |
|
110 | | -setup(name='topi', |
111 | | - version=__version__, |
| 136 | +setup(name='sima-topi', |
| 137 | + version=get_version('topi', 'sima'), |
112 | 138 | description="TOPI: TVM operator index", |
113 | 139 | install_requires=[ |
114 | 140 | "numpy", |
|
0 commit comments