Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable swig unittest in travis-ci #394

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ addons:
- curl
- lcov
- graphviz
- swig
before_install:
- |
if [ ${JOB} == "BUILD_AND_TEST" ]; then
Expand All @@ -51,7 +52,7 @@ before_install:
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
- pip install wheel protobuf sphinx breathe recommonmark
- pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy
script:
- paddle/scripts/travis/main.sh
notifications:
Expand Down
1 change: 1 addition & 0 deletions paddle/api/paddle_api_config.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ GFLAGS_LOCATION="@GFLAGS_LOCATION@"
CBLAS_LIBRARIES="@CBLAS_LIBS@"

CUDA_LIBRARIES="@CUDA_LIBRARIES@"
WITH_COVERALLS="@ON_COVERALLS@"
11 changes: 10 additions & 1 deletion paddle/api/paddle_ld_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self):
self.glog_libs = LIBGLOG_LIBRARY

self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS)
self.with_coverage = PaddleLDFlag.cmake_bool(WITH_COVERALLS)
self.gflags_libs = GFLAGS_LIBRARIES
self.gflags_location = GFLAGS_LOCATION
self.cblas_libs = CBLAS_LIBRARIES
Expand Down Expand Up @@ -95,6 +96,8 @@ def libs_str(self):
libs.append(self.normalize_flag(self.gflags_libs))
if self.with_gpu:
libs.append(self.normalize_flag(self.curt))
if self.with_coverage:
libs.append("-fprofile-arcs")
return " ".join(filter(lambda l: len(l) != 0, libs))

def normalize_flag(self, cmake_flag):
Expand Down Expand Up @@ -131,8 +134,14 @@ def cmake_bool(cmake_str):
return False
else:
return True

def c_flag(self):
if self.with_coverage:
return ["-fprofile-arcs", "-ftest-coverage", "-O0", "-g"]
else:
return None
except ImportError:
class PaddleLDFlag(object):
def ldflag_str(self):
pass
def c_flag(self):
pass
2 changes: 2 additions & 0 deletions paddle/scripts/travis/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ source ./common.sh
CMAKE_EXTRA=""
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"
else
CMAKE_EXTRA="-DWITH_SWIG_PY=ON"
fi


Expand Down
13 changes: 10 additions & 3 deletions paddle/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ is_lin = (system == 'linux')
# because generate paddle LDFLAGS is too complicated to do in setup.py
# it just read COMAKE generated LDFLAGS.
extra_links = []
ldflags = api.paddle_ld_flags.PaddleLDFlag()
ldflags = ldflags.ldflag_str()
obj = api.paddle_ld_flags.PaddleLDFlag()
ldflags = obj.ldflag_str()
if ldflags is not None:
extra_links.extend(ldflags.split(" "))

Expand All @@ -51,13 +51,20 @@ elif is_osx == True:

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",
version="@PADDLE_VERSION@",
ext_modules=[
Extension('py_paddle._swig_paddle', # Build SWIG Extension.
['Paddle_wrap.cxx'],
include_dirs = include_dirs,
extra_link_args = extra_links
extra_link_args = extra_links,
**attr
)
],
packages=['py_paddle'],
Expand Down