From 50f182a08b9ec6bce81591c00a138fcf6c8588e5 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 19 Apr 2021 15:36:15 +0800 Subject: [PATCH] fix(whl): support wheel version without sdk info, which caused by python official PYPI do not support LOCAL_VERSION; sync lite setup.py GitOrigin-RevId: 014f7f2204ed311998e8978ef76d83c394d451c3 --- imperative/python/setup.py | 19 +++++++++++++------ .../whl/manylinux2014/build_wheel_common.sh | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/imperative/python/setup.py b/imperative/python/setup.py index 47677f778..99a9e2739 100644 --- a/imperative/python/setup.py +++ b/imperative/python/setup.py @@ -49,17 +49,24 @@ __version__ = v['__version__'] email = 'megengine@megvii.com' # https://www.python.org/dev/peps/pep-0440 # Public version identifiers: [N!]N(.N)*[{a|b|rc}N][.postN][.devN] +# Local version identifiers: [+] # PUBLIC_VERSION_POSTFIX use to handle rc or dev info public_version_postfix = os.environ.get('PUBLIC_VERSION_POSTFIX') if public_version_postfix: __version__ = '{}{}'.format(__version__, public_version_postfix) + +local_version = [] +strip_sdk_info = os.environ.get('STRIP_SDK_INFO', 'False').lower() sdk_name = os.environ.get('SDK_NAME', 'cpu') -__version__ = '{}+{}'.format(__version__, sdk_name) -# Local version identifiers: [+] -# reserved for special whl package -local_version = os.environ.get('LOCAL_VERSION') -if local_version: - __version__ = '{}.{}'.format(__version__, local_version) +if 'true' == strip_sdk_info: + print('wheel version strip sdk info') +else: + local_version.append(sdk_name) +local_postfix = os.environ.get('LOCAL_VERSION') +if local_postfix: + local_version.append(local_postfix) +if len(local_version): + __version__ = '{}+{}'.format(__version__, '.'.join(local_version)) packages = find_packages(exclude=['test']) megengine_data = [ diff --git a/scripts/whl/manylinux2014/build_wheel_common.sh b/scripts/whl/manylinux2014/build_wheel_common.sh index 063038526..bdc060552 100755 --- a/scripts/whl/manylinux2014/build_wheel_common.sh +++ b/scripts/whl/manylinux2014/build_wheel_common.sh @@ -222,6 +222,7 @@ docker run --rm -it $TMPFS_ARGS \ -e UID=${USERID} \ -e PUBLIC_VERSION_POSTFIX=${PUBLIC_VERSION_POSTFIX} \ -e LOCAL_VERSION=${LOCAL_VERSION} \ + -e STRIP_SDK_INFO=${STRIP_SDK_INFO} \ -e BUILD_WHL_CPU_ONLY=${BUILD_WHL_CPU_ONLY} \ -e ALL_PYTHON="${ALL_PYTHON}" \ -e EXTRA_CMAKE_FLAG="$EXTRA_CMAKE_FLAG" \ -- GitLab