From e136d41f33d32a3085836339f95d62bb34f40420 Mon Sep 17 00:00:00 2001 From: Tzu-Wei Huang Date: Fri, 5 Jul 2019 02:15:59 +0800 Subject: [PATCH] improve setup.py --- setup.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index 41c95787..8a33cd91 100644 --- a/setup.py +++ b/setup.py @@ -30,18 +30,16 @@ def run(self): with open('HISTORY.rst') as history_file: history = history_file.read() -# comment if preparing PyPI package -# version = '1.8' +preparing_PyPI_package = False +version_git = version = '1.8' -# if os.path.exists('.git'): -# sha = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() -# version_git = version + '+' + sha[:7] -# else: -# version_git = version +if not preparing_PyPI_package: + if os.path.exists('.git'): + sha = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() + version_git = version_git + '+' + sha[:7] -# with open('tensorboardX/__init__.py', 'a') as f: -# f.write('\n__version__ = "{}"\n'.format(version_git)) -# end of comment + with open('tensorboardX/__init__.py', 'a') as f: + f.write('\n__version__ = "{}"\n'.format(version_git)) requirements = [ 'numpy', @@ -90,8 +88,8 @@ def run(self): # checklist: update History.rst readme.md -# version=version_git <--- change to sha-less version (in setup.py) -# __version__ = "1.x" (__init__.py) +# change preparing_PyPI_package to True +# remove __version__ = "1.old" in __init__.py # commit # add tag # python setup.py sdist bdist_wheel --universal