提交 57bc6238 编写于 作者: Y Yu Yang 提交者: gangliao

enable swig unittest in travis-ci (#394)

* Init

* Add numpy deps

* Refine
上级 f06f4dfb
...@@ -38,6 +38,7 @@ addons: ...@@ -38,6 +38,7 @@ addons:
- curl - curl
- lcov - lcov
- graphviz - graphviz
- swig
before_install: before_install:
- | - |
if [ ${JOB} == "BUILD_AND_TEST" ]; then if [ ${JOB} == "BUILD_AND_TEST" ]; then
...@@ -51,7 +52,7 @@ before_install: ...@@ -51,7 +52,7 @@ before_install:
fi fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
- pip install wheel protobuf sphinx breathe recommonmark - pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy
script: script:
- paddle/scripts/travis/main.sh - paddle/scripts/travis/main.sh
notifications: notifications:
......
...@@ -16,3 +16,4 @@ GFLAGS_LOCATION="@GFLAGS_LOCATION@" ...@@ -16,3 +16,4 @@ GFLAGS_LOCATION="@GFLAGS_LOCATION@"
CBLAS_LIBRARIES="@CBLAS_LIBS@" CBLAS_LIBRARIES="@CBLAS_LIBS@"
CUDA_LIBRARIES="@CUDA_LIBRARIES@" CUDA_LIBRARIES="@CUDA_LIBRARIES@"
WITH_COVERALLS="@ON_COVERALLS@"
...@@ -48,6 +48,7 @@ try: ...@@ -48,6 +48,7 @@ try:
self.glog_libs = LIBGLOG_LIBRARY self.glog_libs = LIBGLOG_LIBRARY
self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS) self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS)
self.with_coverage = PaddleLDFlag.cmake_bool(WITH_COVERALLS)
self.gflags_libs = GFLAGS_LIBRARIES self.gflags_libs = GFLAGS_LIBRARIES
self.gflags_location = GFLAGS_LOCATION self.gflags_location = GFLAGS_LOCATION
self.cblas_libs = CBLAS_LIBRARIES self.cblas_libs = CBLAS_LIBRARIES
...@@ -97,6 +98,8 @@ try: ...@@ -97,6 +98,8 @@ try:
libs.append(self.normalize_flag(self.gflags_libs)) libs.append(self.normalize_flag(self.gflags_libs))
if self.with_gpu: if self.with_gpu:
libs.append(self.normalize_flag(self.curt)) libs.append(self.normalize_flag(self.curt))
if self.with_coverage:
libs.append("-fprofile-arcs")
return " ".join(filter(lambda l: len(l) != 0, libs)) return " ".join(filter(lambda l: len(l) != 0, libs))
def normalize_flag(self, cmake_flag): def normalize_flag(self, cmake_flag):
...@@ -133,8 +136,14 @@ try: ...@@ -133,8 +136,14 @@ try:
return False return False
else: else:
return True return True
def c_flag(self):
if self.with_coverage:
return ["-fprofile-arcs", "-ftest-coverage", "-O0", "-g"]
else:
return None
except ImportError: except ImportError:
class PaddleLDFlag(object): class PaddleLDFlag(object):
def ldflag_str(self): def ldflag_str(self):
pass pass
def c_flag(self):
pass
...@@ -3,6 +3,8 @@ source ./common.sh ...@@ -3,6 +3,8 @@ source ./common.sh
CMAKE_EXTRA="" CMAKE_EXTRA=""
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
CMAKE_EXTRA="-DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib" CMAKE_EXTRA="-DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib"
else
CMAKE_EXTRA="-DWITH_SWIG_PY=ON"
fi fi
......
...@@ -31,8 +31,8 @@ is_lin = (system == 'linux') ...@@ -31,8 +31,8 @@ is_lin = (system == 'linux')
# because generate paddle LDFLAGS is too complicated to do in setup.py # because generate paddle LDFLAGS is too complicated to do in setup.py
# it just read COMAKE generated LDFLAGS. # it just read COMAKE generated LDFLAGS.
extra_links = [] extra_links = []
ldflags = api.paddle_ld_flags.PaddleLDFlag() obj = api.paddle_ld_flags.PaddleLDFlag()
ldflags = ldflags.ldflag_str() ldflags = obj.ldflag_str()
if ldflags is not None: if ldflags is not None:
extra_links.extend(ldflags.split(" ")) extra_links.extend(ldflags.split(" "))
...@@ -51,13 +51,20 @@ elif is_osx == True: ...@@ -51,13 +51,20 @@ elif is_osx == True:
include_dirs = [np.get_include(), "../"] # include numpy and paddle. include_dirs = [np.get_include(), "../"] # include numpy and paddle.
extra_c = obj.c_flag()
attr=dict()
if extra_c is not None:
attr["extra_compile_args"] = extra_c
setup(name="py_paddle", setup(name="py_paddle",
version="@PADDLE_VERSION@", version="@PADDLE_VERSION@",
ext_modules=[ ext_modules=[
Extension('py_paddle._swig_paddle', # Build SWIG Extension. Extension('py_paddle._swig_paddle', # Build SWIG Extension.
['Paddle_wrap.cxx'], ['Paddle_wrap.cxx'],
include_dirs = include_dirs, include_dirs = include_dirs,
extra_link_args = extra_links extra_link_args = extra_links,
**attr
) )
], ],
packages=['py_paddle'], packages=['py_paddle'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册