Skip to content

Commit c4599d3

Browse files
authored
Add version api (#2985)
* write versino.py * add version py * clean init py * add istaged, major and etc... fields * update * update * update
1 parent 0d4f050 commit c4599d3

File tree

4 files changed

+72
-9
lines changed

4 files changed

+72
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ cmake_install.cmake
2828
paddle/.timestamp
2929
python/paddlepaddle.egg-info/
3030
paddle/pybind/pybind.h
31+
python/paddle/version.py

doc/design/releasing_process.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ PaddlePaddle使用git-flow branching model做分支管理,使用[Semantic Vers
55
PaddlePaddle每次发新的版本,遵循以下流程:
66

77
1.`develop`分支派生出新的分支,分支名为`release/版本号`。例如,`release/0.10.0`
8-
2. 将新分支的版本打上tag,tag为`版本号rc.Patch号`。第一个tag为`0.10.0rc1`,第二个为`0.10.0rc2`,依次类推。
9-
3. 对这个版本的提交,做如下几个操作:
8+
1. 将新分支的版本打上tag,tag为`版本号rc.Patch号`。第一个tag为`0.10.0rc1`,第二个为`0.10.0rc2`,依次类推。
9+
1. 对这个版本的提交,做如下几个操作:
10+
* 修改`python/setup.py.in`中的版本信息,并将`istaged`字段设为`True`。
1011
* 编译这个版本的Docker发行镜像,发布到dockerhub。如果失败,修复Docker编译镜像问题,Patch号加一,返回第二步
1112
* 编译这个版本的Ubuntu Deb包。如果失败,修复Ubuntu Deb包编译问题,Patch号加一,返回第二步。
1213
* 使用Regression Test List作为检查列表,测试Docker镜像/ubuntu安装包的功能正确性
@@ -20,17 +21,17 @@ PaddlePaddle每次发新的版本,遵循以下流程:
2021
pip install twine
2122
twine upload dist/[package to upload]
2223
```
23-
4. 第三步完成后,将`release/版本号`分支合入master分支,并删除`release/版本号`分支。将master分支的合入commit打上tag,tag为`版本号`。同时再将`master`分支合入`develop`分支。最后删除`release/版本号`分支。
24-
5. 编译master分支的Docker发行镜像,发布到dockerhub。编译ubuntu的deb包,发布到github release页面
25-
6. 协同完成Release Note的书写
24+
1. 第三步完成后,将`release/版本号`分支合入master分支,并删除`release/版本号`分支。将master分支的合入commit打上tag,tag为`版本号`。同时再将`master`分支合入`develop`分支。最后删除`release/版本号`分支。
25+
1. 编译master分支的Docker发行镜像,发布到dockerhub。编译ubuntu的deb包,发布到github release页面
26+
1. 协同完成Release Note的书写
2627

2728

2829
需要注意的是:
2930

3031
* `release/版本号`分支一旦建立,一般不允许再从`develop`分支合入`release/版本号`。这样保证`release/版本号`分支功能的封闭,方便测试人员测试PaddlePaddle的行为。
3132
*`release/版本号`分支存在的时候,如果有bugfix的行为,需要将bugfix的分支同时merge到`master`, `develop``release/版本号`这三个分支。
3233

33-
# PaddlePaddle 分支规范
34+
## PaddlePaddle 分支规范
3435

3536
PaddlePaddle开发过程使用[git-flow](http://nvie.com/posts/a-successful-git-branching-model/)分支规范,并适应github的特性做了一些区别。
3637

@@ -47,11 +48,11 @@ PaddlePaddle开发过程使用[git-flow](http://nvie.com/posts/a-successful-git-
4748

4849
* BugFix分支也是在开发者自己的fork版本库维护,与功能分支不同的是,BugFix分支需要分别给主版本库的`master``develop`与可能有的`release/版本号`分支,同时提起`Pull Request`
4950

50-
# PaddlePaddle回归测试列表
51+
## PaddlePaddle回归测试列表
5152

5253
本列表说明PaddlePaddle发版之前需要测试的功能点。
5354

54-
## PaddlePaddle Book中所有章节
55+
### PaddlePaddle Book中所有章节
5556

5657
PaddlePaddle每次发版本首先要保证PaddlePaddle Book中所有章节功能的正确性。功能的正确性包括验证PaddlePaddle目前的`paddle_trainer`训练和纯使用`Python`训练模型正确性。
5758

python/paddle/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
try:
15+
from version import full_version as __version__
16+
from version import commit as __git_commit__
17+
except ImportError:
18+
import sys
19+
sys.stderr.write('''Warning with import paddle: you should not
20+
import paddle from the source directory; please install paddlepaddle*.whl firstly.'''
21+
)

python/setup.py.in

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
11
from setuptools import setup, Distribution, Extension
2+
import subprocess
23
class BinaryDistribution(Distribution):
34
def has_ext_modules(foo):
45
return True
56

7+
MAJOR = 0
8+
MINOR = 10
9+
PATCH = 0
10+
RC = 0
11+
ISTAGED = False
12+
13+
14+
15+
def git_commit():
16+
try:
17+
cmd = ['git', 'rev-parse', 'HEAD']
18+
git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip()
19+
except:
20+
git_commit = 'Unknown'
21+
return git_commit
22+
23+
def write_version_py(filename='paddle/version.py'):
24+
cnt = '''
25+
# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
26+
#
27+
full_version = '%(major)d.%(minor)d.%(patch)d'
28+
major = '%(major)d'
29+
minor = '%(minor)d'
30+
patch = '%(patch)d'
31+
rc = '%(rc)d'
32+
istaged = %(istaged)s
33+
commit = '%(commit)s'
34+
35+
def show():
36+
if istaged:
37+
print 'full_version:', full_version
38+
print 'major:', major
39+
print 'minor:', minor
40+
print 'patch:', patch
41+
print 'rc:', rc
42+
else:
43+
print 'commit:', commit
44+
'''
45+
commit = git_commit()
46+
with open(filename, 'w') as f:
47+
f.write(cnt % {
48+
'major': MAJOR,
49+
'minor': MINOR,
50+
'patch': PATCH,
51+
'rc': RC,
52+
'version': '${PADDLE_VERSION}',
53+
'commit': commit,
54+
'istaged': ISTAGED})
55+
56+
write_version_py(filename='@PADDLE_SOURCE_DIR@/python/paddle/version.py')
57+
58+
659
packages=['paddle',
760
'paddle.proto',
861
'paddle.trainer',
@@ -21,7 +74,7 @@ with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f:
2174
setup_requires = f.read().splitlines()
2275

2376
if '${CMAKE_SYSTEM_PROCESSOR}' not in ['arm', 'armv7-a', 'aarch64']:
24-
setup_requires+=["opencv-python"]
77+
setup_requires+=['opencv-python']
2578

2679
# the prefix is sys.prefix which should always be usr
2780
paddle_bin_dir = 'opt/paddle/bin'

0 commit comments

Comments
 (0)