From 3d3b834e2c10c9b6f7bd2e44369c76043e334814 Mon Sep 17 00:00:00 2001 From: Parmeet Singh Bhatia Date: Fri, 23 Apr 2021 11:20:44 -0400 Subject: [PATCH 1/3] adding version.txt file --- setup.py | 3 ++- version.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 version.txt diff --git a/setup.py b/setup.py index 95fffe4035..2572090147 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,8 @@ def read(*names, **kwargs): def _get_version(): - version = '0.10.0a0' + with open(os.path.join(ROOT_DIR, 'version.txt'), 'r') as f: + version = f.readline().strip() sha = None try: diff --git a/version.txt b/version.txt new file mode 100644 index 0000000000..7e4490fc70 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.10.0a0 \ No newline at end of file From 61d29a9e346827511350ba6505a8978b46fd0398 Mon Sep 17 00:00:00 2001 From: Parmeet Singh Bhatia Date: Fri, 23 Apr 2021 13:48:57 -0400 Subject: [PATCH 2/3] modifying code for readability --- setup.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 2572090147..db1bd12753 100644 --- a/setup.py +++ b/setup.py @@ -18,20 +18,19 @@ def read(*names, **kwargs): def _get_version(): - with open(os.path.join(ROOT_DIR, 'version.txt'), 'r') as f: - version = f.readline().strip() - sha = None - try: cmd = ['git', 'rev-parse', 'HEAD'] sha = subprocess.check_output(cmd, cwd=str(ROOT_DIR)).decode('ascii').strip() except Exception: - pass - - if os.getenv('BUILD_VERSION'): - version = os.getenv('BUILD_VERSION') - elif sha is not None: - version += '+' + sha[:7] + sha = None + + if 'BUILD_VERSION' in os.environ: + version = os.environ('BUILD_VERSION') + else: + with open(os.path.join(ROOT_DIR, 'version.txt'), 'r') as f: + version = f.readline().strip() + if sha is not None: + version += '+' + sha[:7] if sha is None: sha = 'Unknown' From e5ad619fa75eece44b393a66d13068857e28e1c7 Mon Sep 17 00:00:00 2001 From: Parmeet Singh Bhatia Date: Fri, 23 Apr 2021 13:55:14 -0400 Subject: [PATCH 3/3] fixing build error --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index db1bd12753..5db3388053 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def _get_version(): sha = None if 'BUILD_VERSION' in os.environ: - version = os.environ('BUILD_VERSION') + version = os.environ['BUILD_VERSION'] else: with open(os.path.join(ROOT_DIR, 'version.txt'), 'r') as f: version = f.readline().strip()