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>
This commit is contained in:
Родитель
440a3ca98b
Коммит
67c77d9fbc
|
@ -36,6 +36,7 @@ __pycache__
|
|||
out/
|
||||
*.egg-info/
|
||||
.setuptools-cmake-build/
|
||||
onnxruntime_extensions/_version.py
|
||||
onnxruntime-*-*-*/
|
||||
temp_*.onnx
|
||||
# Java specific ignores
|
||||
|
|
|
@ -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"
|
15
setup.py
15
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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче