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:
Wenbing Li 2023-01-12 14:28:32 -08:00 коммит произвёл GitHub
Родитель 440a3ca98b
Коммит 67c77d9fbc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 11 добавлений и 11 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -36,6 +36,7 @@ __pycache__
out/ out/
*.egg-info/ *.egg-info/
.setuptools-cmake-build/ .setuptools-cmake-build/
onnxruntime_extensions/_version.py
onnxruntime-*-*-*/ onnxruntime-*-*-*/
temp_*.onnx temp_*.onnx
# Java specific ignores # 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"

Просмотреть файл

@ -126,10 +126,8 @@ def read_requirements():
# read version from the package file. # read version from the package file.
def read_version(): def read_version():
version_str = '1.0.0' version_str = '1.0.0'
with (open(os.path.join(TOP_DIR, 'onnxruntime_extensions/_version.py'), "r")) as f: with (open(os.path.join(TOP_DIR, 'version.txt'), "r")) as f:
line = [_ for _ in [dedent(_) for _ in f.readlines()] if _.startswith("__version__")] version_str = f.readline().strip()
if len(line) > 0:
version_str = line[0].split('=')[1].strip('" \n\r')
# is it a dev build or release? # is it a dev build or release?
build_id = os.getenv('BUILD_BUILDID', None) build_id = os.getenv('BUILD_BUILDID', None)
@ -142,6 +140,11 @@ def read_version():
version_str += '+' + cid[:7] version_str += '+' + cid[:7]
return version_str 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": if sys.platform == "win32":
load_msvcvar() 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 start_pos = 0 if start_pos < 0 else start_pos
end_pos = long_description.find('# Contributing') end_pos = long_description.find('# Contributing')
long_description = long_description[start_pos:end_pos] long_description = long_description[start_pos:end_pos]
ortx_version = read_version()
write_py_version(ortx_version)
setup( setup(
name=PACKAGE_NAME, name=PACKAGE_NAME,
version=read_version(), version=ortx_version,
packages=packages, packages=packages,
package_dir=package_dir, package_dir=package_dir,
package_data=package_data, package_data=package_data,