提交 5f17f05b 编写于 作者: M minqiyang

Add get_version function to get version from git tags

上级 9a15c923
from setuptools import setup, Distribution, Extension from setuptools import setup, Distribution, Extension
import subprocess import subprocess
import re
class BinaryDistribution(Distribution): class BinaryDistribution(Distribution):
def has_ext_modules(foo): def has_ext_modules(foo):
return True return True
...@@ -20,6 +21,40 @@ def git_commit(): ...@@ -20,6 +21,40 @@ def git_commit():
git_commit = 'Unknown' git_commit = 'Unknown'
return git_commit return git_commit
def _get_version_detail(idx):
assert idx < 3
version_details = '${PADDLE_VERSION}'.split('.')
if len(version_details) == 3:
if re.match('[0-9]+', version_details[idx]):
return int(version_details[idx])
return None
def get_minor():
minor = _get_version_detail(0)
if minor is not None:
return minor
return MINOR
def get_major():
major = _get_version_detail(1)
if major is not None:
return major
return MAJOR
def get_patch():
patch = _get_version_detail(2)
if patch is not None:
return patch
return PATCH
def is_taged():
return ISTAGED
def write_version_py(filename='paddle/version.py'): def write_version_py(filename='paddle/version.py'):
cnt = ''' cnt = '''
# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
...@@ -49,13 +84,13 @@ def mkl(): ...@@ -49,13 +84,13 @@ def mkl():
commit = git_commit() commit = git_commit()
with open(filename, 'w') as f: with open(filename, 'w') as f:
f.write(cnt % { f.write(cnt % {
'major': MAJOR, 'major': get_major(),
'minor': MINOR, 'minor': get_minor(),
'patch': PATCH, 'patch': get_patch(),
'rc': RC, 'rc': RC,
'version': '${PADDLE_VERSION}', 'version': '${PADDLE_VERSION}',
'commit': commit, 'commit': commit,
'istaged': ISTAGED, 'istaged': is_taged(),
'with_mkl': '@WITH_MKL@'}) 'with_mkl': '@WITH_MKL@'})
write_version_py(filename='@PADDLE_BINARY_DIR@/python/paddle/version.py') write_version_py(filename='@PADDLE_BINARY_DIR@/python/paddle/version.py')
...@@ -113,7 +148,7 @@ package_dir={ ...@@ -113,7 +148,7 @@ package_dir={
} }
if '${WITH_FLUID_ONLY}'== 'OFF': if '${WITH_FLUID_ONLY}'== 'OFF':
package_dir['py_paddle']='${PADDLE_BINARY_DIR}/python/py_paddle' package_dir['py_paddle']='${PADDLE_BINARY_DIR}/python/py_paddle'
paddle_rt_lib_dir = 'lib' paddle_rt_lib_dir = 'lib'
paddle_rt_libs = ['${WARPCTC_LIBRARIES}'] paddle_rt_libs = ['${WARPCTC_LIBRARIES}']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册