From 67c77d9fbc31110f20c226267331b4297c2d379c Mon Sep 17 00:00:00 2001 From: Wenbing Li <10278425+wenbingl@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:28:32 -0800 Subject: [PATCH] align python package version with version.txt (#345) * align python package version with version.txt * Update setup.py Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> * remove a line Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> --- .gitignore | 1 + onnxruntime_extensions/_version.py | 6 ------ setup.py | 15 ++++++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 onnxruntime_extensions/_version.py diff --git a/.gitignore b/.gitignore index 876c3112..aa14c1e2 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ __pycache__ out/ *.egg-info/ .setuptools-cmake-build/ +onnxruntime_extensions/_version.py onnxruntime-*-*-*/ temp_*.onnx # Java specific ignores diff --git a/onnxruntime_extensions/_version.py b/onnxruntime_extensions/_version.py deleted file mode 100644 index 60139ccd..00000000 --- a/onnxruntime_extensions/_version.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -############################################################################### - -__version__ = "0.5.0" diff --git a/setup.py b/setup.py index d46e7cba..469f3226 100644 --- a/setup.py +++ b/setup.py @@ -126,10 +126,8 @@ def read_requirements(): # read version from the package file. def read_version(): version_str = '1.0.0' - with (open(os.path.join(TOP_DIR, 'onnxruntime_extensions/_version.py'), "r")) as f: - line = [_ for _ in [dedent(_) for _ in f.readlines()] if _.startswith("__version__")] - if len(line) > 0: - version_str = line[0].split('=')[1].strip('" \n\r') + with (open(os.path.join(TOP_DIR, 'version.txt'), "r")) as f: + version_str = f.readline().strip() # is it a dev build or release? build_id = os.getenv('BUILD_BUILDID', None) @@ -142,6 +140,11 @@ def read_version(): version_str += '+' + cid[:7] return version_str +def write_py_version(ortx_version): + text = ["# Generated by setup.py, DON'T MANUALLY UPDATE IT!\n", + "__version__ = \"{}\"\n".format(ortx_version)] + with (open(os.path.join(TOP_DIR, 'onnxruntime_extensions/_version.py'), "w")) as _f: + _f.writelines(text) if sys.platform == "win32": load_msvcvar() @@ -165,10 +168,12 @@ with open(os.path.join(TOP_DIR, "README.md"), 'r', encoding="utf-8") as _f: start_pos = 0 if start_pos < 0 else start_pos end_pos = long_description.find('# Contributing') long_description = long_description[start_pos:end_pos] +ortx_version = read_version() +write_py_version(ortx_version) setup( name=PACKAGE_NAME, - version=read_version(), + version=ortx_version, packages=packages, package_dir=package_dir, package_data=package_data,