From fa83d6fd9b47e3ec2b4d98b4c9a19e83d3988b14 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Thu, 20 Jul 2017 10:26:21 +0800 Subject: [PATCH 1/7] write versino.py --- python/setup.py.in | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python/setup.py.in b/python/setup.py.in index 65a26940d4d70..d66c25a18060b 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,5 +1,28 @@ from setuptools import setup +def git_commit(): + try: + cmd = ["git", "rev-parse", "HEAD"] + git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0].strip() + except: + git_commit = "Unknown" + return git_commit + +def write_version_py(filename="paddle/version.py"): + cnt = """ +# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY +# +version = %(version)s +git_revision = %(git_commit) +""" + commit_id = git_commit() + with open(filename, "w") as f: + f.write(cnt % { + "version" : "${PADDLE_VERSION}", + "git_commit": commit_id}) + +write_version_py() + packages=['paddle', 'paddle.proto', 'paddle.trainer', From 69b4aa307e8b09d4f2c9ed802b31b2af18312170 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Thu, 20 Jul 2017 13:22:14 +0800 Subject: [PATCH 2/7] add version py --- python/paddle/__init__.py | 1 + python/setup.py.in | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index f662d6826321e..120a1bb8289fc 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -11,3 +11,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +__all__ = ['version'] diff --git a/python/setup.py.in b/python/setup.py.in index d66c25a18060b..bae62cac67d4e 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,9 +1,10 @@ from setuptools import setup +import subprocess def git_commit(): try: cmd = ["git", "rev-parse", "HEAD"] - git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0].strip() + git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip() except: git_commit = "Unknown" return git_commit @@ -12,8 +13,8 @@ def write_version_py(filename="paddle/version.py"): cnt = """ # THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # -version = %(version)s -git_revision = %(git_commit) +version = "%(version)s" +git_commit = "%(git_commit)s" """ commit_id = git_commit() with open(filename, "w") as f: @@ -21,7 +22,7 @@ git_revision = %(git_commit) "version" : "${PADDLE_VERSION}", "git_commit": commit_id}) -write_version_py() +write_version_py(filename="${PROJ_ROOT}/python/paddle/version.py") packages=['paddle', 'paddle.proto', From b94558bfd94ad3060669ac818737539f324c783c Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Thu, 20 Jul 2017 13:26:20 +0800 Subject: [PATCH 3/7] clean init py --- python/paddle/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index 120a1bb8289fc..f662d6826321e 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -__all__ = ['version'] From ef195f58b04bed84ac46b37e0737637112e80898 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Mon, 24 Jul 2017 23:09:50 +0800 Subject: [PATCH 4/7] add istaged, major and etc... fields --- doc/design/releasing_process.md | 3 ++- python/setup.py.in | 38 ++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/design/releasing_process.md b/doc/design/releasing_process.md index 3692a5248a355..3543f6693a7a2 100644 --- a/doc/design/releasing_process.md +++ b/doc/design/releasing_process.md @@ -7,6 +7,7 @@ Paddle每次发新的版本,遵循以下流程: 1. 从`develop`分支派生出新的分支,分支名为`release/版本号`。例如,`release/0.10.0` 2. 将新分支的版本打上tag,tag为`版本号rc.Patch号`。第一个tag为`0.10.0rc1`,第二个为`0.10.0rc2`,依次类推。 3. 对这个版本的提交,做如下几个操作: + * 修改`python/setup.py.in`中的版本信息,并将`istaged`字段设为`True`。 * 编译这个版本的Docker发行镜像,发布到dockerhub。如果失败,修复Docker编译镜像问题,Patch号加一,返回第二步 * 编译这个版本的Ubuntu Deb包。如果失败,修复Ubuntu Deb包编译问题,Patch号加一,返回第二步。 * 使用Regression Test List作为检查列表,测试Docker镜像/ubuntu安装包的功能正确性 @@ -34,7 +35,7 @@ Paddle开发过程使用[git-flow](http://nvie.com/posts/a-successful-git-branch * 建议,开发者fork的版本库使用`develop`分支同步主版本库的`develop`分支 * 建议,开发者fork的版本库中,再基于`develop`版本fork出自己的功能分支。 * 当功能分支开发完毕后,向Paddle的主版本库提交`Pull Reuqest`,进而进行代码评审。 - * 在评审过程中,开发者修改自己的代码,可以继续在自己的功能分支提交代码。 + * 在评审过程中,开发者修改自己的代码,可以继续在自己的功能分支提交代码。 * BugFix分支也是在开发者自己的fork版本库维护,与功能分支不同的是,BugFix分支需要分别给主版本库的`master`、`develop`与可能有的`release/版本号`分支,同时提起`Pull Request`。 diff --git a/python/setup.py.in b/python/setup.py.in index bae62cac67d4e..8222084dbef78 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,6 +1,14 @@ from setuptools import setup import subprocess +MAJOR = 0 +MINOR = 10 +PATCH = 0 +RC = 0 +ISTAGED = False + + + def git_commit(): try: cmd = ["git", "rev-parse", "HEAD"] @@ -13,14 +21,34 @@ def write_version_py(filename="paddle/version.py"): cnt = """ # THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # -version = "%(version)s" -git_commit = "%(git_commit)s" +full_version = "%(major)d.%(minor)d.%(patch)d" +major = "%(major)d" +minor = "%(minor)d" +patch = "%(patch)d" +rc = "%(rc)d" +istaged = %(istaged)s +commit = "%(commit)s" + +def show(): + if istaged: + print "full_version:", full_version + print "major:", major + print "minor:", minor + print "patch:", patch + print "rc:", rc + else: + print "commit:", commit """ - commit_id = git_commit() + commit = git_commit() with open(filename, "w") as f: f.write(cnt % { - "version" : "${PADDLE_VERSION}", - "git_commit": commit_id}) + "major": MAJOR, + "minor": MINOR, + "patch": PATCH, + "rc": RC, + "version": "${PADDLE_VERSION}", + "commit": commit, + "istaged": ISTAGED}) write_version_py(filename="${PROJ_ROOT}/python/paddle/version.py") From 798424c8a73030acdfc32c6306c8b7256b2ea406 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Mon, 23 Oct 2017 15:50:18 +0800 Subject: [PATCH 5/7] update --- python/setup.py.in | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/python/setup.py.in b/python/setup.py.in index ad2d83eb844a7..ebbade7697ce4 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -14,46 +14,46 @@ ISTAGED = False def git_commit(): try: - cmd = ["git", "rev-parse", "HEAD"] + cmd = ['git', 'rev-parse', 'HEAD'] git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip() except: - git_commit = "Unknown" + git_commit = 'Unknown' return git_commit -def write_version_py(filename="paddle/version.py"): - cnt = """ +def write_version_py(filename='paddle/version.py'): + cnt = ''' # THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # -full_version = "%(major)d.%(minor)d.%(patch)d" -major = "%(major)d" -minor = "%(minor)d" -patch = "%(patch)d" -rc = "%(rc)d" +full_version = '%(major)d.%(minor)d.%(patch)d' +major = '%(major)d' +minor = '%(minor)d' +patch = '%(patch)d' +rc = '%(rc)d' istaged = %(istaged)s -commit = "%(commit)s" +commit = '%(commit)s' def show(): if istaged: - print "full_version:", full_version - print "major:", major - print "minor:", minor - print "patch:", patch - print "rc:", rc + print 'full_version:', full_version + print 'major:', major + print 'minor:', minor + print 'patch:', patch + print 'rc:', rc else: - print "commit:", commit -""" + print 'commit:', commit +''' commit = git_commit() - with open(filename, "w") as f: + with open(filename, 'w') as f: f.write(cnt % { - "major": MAJOR, - "minor": MINOR, - "patch": PATCH, - "rc": RC, - "version": "${PADDLE_VERSION}", - "commit": commit, - "istaged": ISTAGED}) + 'major': MAJOR, + 'minor': MINOR, + 'patch': PATCH, + 'rc': RC, + 'version': '${PADDLE_VERSION}', + 'commit': commit, + 'istaged': ISTAGED}) -write_version_py(filename="${PROJ_ROOT}/python/paddle/version.py") +write_version_py(filename='$@PADDLE_SOURCE_DIR@/python/paddle/version.py') packages=['paddle', @@ -74,7 +74,7 @@ with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f: setup_requires = f.read().splitlines() if '${CMAKE_SYSTEM_PROCESSOR}' not in ['arm', 'armv7-a', 'aarch64']: - setup_requires+=["opencv-python"] + setup_requires+=['opencv-python'] # the prefix is sys.prefix which should always be usr paddle_bin_dir = 'opt/paddle/bin' From 214623e54454285d0ec826b6453048331cb1b09b Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Mon, 23 Oct 2017 18:06:42 +0800 Subject: [PATCH 6/7] update --- .gitignore | 1 + python/paddle/__init__.py | 2 ++ python/setup.py.in | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 351b8204100df..ee9a4a341334f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ cmake_install.cmake paddle/.timestamp python/paddlepaddle.egg-info/ paddle/pybind/pybind.h +python/paddle/version.py diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index f662d6826321e..715a6107a7387 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -11,3 +11,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from version import full_version as __version__ +from version import commit as __git_commit__ diff --git a/python/setup.py.in b/python/setup.py.in index ebbade7697ce4..6fa85b70ecf37 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -53,7 +53,7 @@ def show(): 'commit': commit, 'istaged': ISTAGED}) -write_version_py(filename='$@PADDLE_SOURCE_DIR@/python/paddle/version.py') +write_version_py(filename='@PADDLE_SOURCE_DIR@/python/paddle/version.py') packages=['paddle', From 0b6f39b78c8913687f197c5c852a04f8b5ae9319 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Mon, 23 Oct 2017 19:44:19 +0800 Subject: [PATCH 7/7] update --- python/paddle/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index 715a6107a7387..1030c94e16376 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -11,5 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from version import full_version as __version__ -from version import commit as __git_commit__ +try: + from version import full_version as __version__ + from version import commit as __git_commit__ +except ImportError: + import sys + sys.stderr.write('''Warning with import paddle: you should not + import paddle from the source directory; please install paddlepaddle*.whl firstly.''' + )