Skip to content

Add Travis support #8

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

Merged
merged 6 commits into from
Jul 5, 2018
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
57 changes: 41 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
sudo: required
env:
global:
- APT_DEPENDENCIES="doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev"
- APT_DEPENDENCIES="cmake cmake-data doxygen doxygen-latex libltdl-dev libboost-all-dev liblog4cxx10-dev"
- HOMEBREW_DEPENDENCIES="doxygen log4cxx dartsim/dart/ipopt openblas mumps"
- GIT_DEPENDENCIES="roboptim/roboptim-core roboptim/roboptim-core-plugin-ipopt"
- GH_USERNAME=thomas-moulard
- GH_REPO=roboptim/roboptim-core-python
Expand All @@ -20,19 +17,22 @@ branches:
- dev
- travis
before_install:
- sudo add-apt-repository ppa:fkrull/deadsnakes -y
- sudo apt-get update -q
- sudo apt-get install python${TRAVIS_PYTHON_VERSION}-dev
- if [ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]; then pip install futures; fi;
- pip install matplotlib
- export TRAVIS_PYTHON_VERSION_SHORT=$(echo "${TRAVIS_PYTHON_VERSION}" | cut -d'.' -f-2)
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo add-apt-repository ppa:fkrull/deadsnakes -y; fi;
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get update -q; fi;
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo apt-get install python${TRAVIS_PYTHON_VERSION_SHORT}-dev; fi;
- if [ "${TRAVIS_PYTHON_VERSION_SHORT}" == "2.7" ]; then pip2 install futures; fi;
- pip install matplotlib || pip2 install matplotlib
- ./.travis/dependencies/eigen-3.2
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then CC=gcc CXX=g++ ./.travis/dependencies/ipopt; fi
- ./.travis/run before_install
script:
- export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION}\"`"
- export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION}*.so\" -print -quit`"
- export CMAKE_ADDITIONAL_OPTIONS="-DPython_ADDITIONAL_VERSIONS=${TRAVIS_PYTHON_VERSION} -DPythonLibs_FIND_VERSION=${TRAVIS_PYTHON_VERSION} -DPYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/"
- export LD_LIBRARY_PATH="/tmp/_ci/install/lib/roboptim-core/"
- export PYTHON_INCLUDE_DIR="`find /usr/include -name Python.h -printf '%h\n' | grep \"python${TRAVIS_PYTHON_VERSION_SHORT}\"`"
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export PYTHON_LIBRARY="`find /usr/lib -name \"libpython${TRAVIS_PYTHON_VERSION_SHORT}*.so\" -print -quit`"; fi;
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export PYTHON_LIBRARY='#{%x(python-config --prefix).chomp}/lib/libpython2.7.dylib'; fi;
- export CMAKE_ADDITIONAL_OPTIONS="-DPython_ADDITIONAL_VERSIONS=${TRAVIS_PYTHON_VERSION_SHORT} -DPythonLibs_FIND_VERSION=${TRAVIS_PYTHON_VERSION_SHORT} -DPYTHON_EXECUTABLE=${VIRTUAL_ENV}/bin/python -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_PACKAGES_PATH=${VIRTUAL_ENV}/lib/python${TRAVIS_PYTHON_VERSION_SHORT}/site-packages/"
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then export LD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$LD_LIBRARY_PATH; fi
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then export DYLD_LIBRARY_PATH=`pkg-config --variable=plugindir roboptim-core`:$DYLD_LIBRARY_PATH; fi
- ./.travis/run build
after_success:
# Print Ipopt logs even after success
Expand All @@ -46,4 +46,29 @@ after_failure: ./.travis/run after_failure
matrix:
allow_failures:
# Known issue with virtualenv
- python: "2.7"
- python: "2.7.6"
- python: "2.7.3"
- os: osx # TODO: Fix ipopt install
include:
- os: linux
dist: trusty
language: python
python: "2.7.6" # Match the system's version
- os: linux
dist: trusty
language: python
python: "3.5.3" # Match the system's version
- os: linux
dist: precise
env: MASTER_PPA="george-edison55/precise-backports"
language: python
python: "2.7.3" # Match the system's version
- os: linux
dist: precise
env: MASTER_PPA="george-edison55/precise-backports"
language: python
python: "3.5.2" # Match the system's version
- os: osx
language: cpp
compiler: clang
env: TRAVIS_PYTHON_VERSION="2.7"
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SET(HEADERS

SET(CXX_DISABLE_WERROR 1) #FIXME: disable for now.

SET(PKG_CONFIG_ADDITIONAL_VARIABLES plugindir ${PKG_CONFIG_ADDITIONAL_VARIABLES})
SETUP_PROJECT()

# Search for dependencies.
Expand Down
6 changes: 1 addition & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ INCLUDE_DIRECTORIES(SYSTEM ${NUMPY_INCLUDE_DIRS})
# Compile library
ADD_LIBRARY(roboptim-core-python SHARED
${HEADERS}
common.hh
common.cc
to-python.cc)

TARGET_LINK_LIBRARIES(roboptim-core-python ${PYTHON_LIBRARIES})
Expand All @@ -27,7 +25,7 @@ PKG_CONFIG_APPEND_LIBS(roboptim-core-python)
SET(LOCAL_MODULE_DIR "${PROJECT_BINARY_DIR}/src")

# Compile module
ADD_LIBRARY(wrap MODULE wrap.cc)
ADD_LIBRARY(wrap MODULE common.cc wrap.cc)
PKG_CONFIG_USE_DEPENDENCY(wrap roboptim-core)
SET_TARGET_PROPERTIES(wrap PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LOCAL_MODULE_DIR}/roboptim/core
Expand All @@ -36,8 +34,6 @@ SET_TARGET_PROPERTIES(wrap PROPERTIES
# Link against Boost.
TARGET_LINK_LIBRARIES(wrap ${Boost_LIBRARIES})

TARGET_LINK_LIBRARIES(wrap roboptim-core-python)

SET_TARGET_PROPERTIES(wrap PROPERTIES PREFIX "")

# Install libraries
Expand Down
34 changes: 34 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,45 @@
# Use adequate Python executable for tests
SET(TEST_COMMAND "${PYTHON_EXECUTABLE}")

SET(PLUGINDIR "")
IF(ROBOPTIM_CORE_FOUND)
SET(PLUGINDIR ${ROBOPTIM_CORE_PLUGINDIR})
ELSEIF()
SET(PLUGINDIR ${ROBOPTIM_CORE_DEBUG_PLUGINDIR})
ENDIF()

IF("${PLUGINDIR}" STREQUAL "")
MESSAGE(FATAL_ERROR "Plugin directory not found")
ENDIF()

# SET_TEST_ENV(NAME)
# ------------------
#
# Add the plugin directory to the proper environment variables.
#
MACRO(SET_TEST_ENV NAME)
# TODO: adapt for WIN32
IF(UNIX)
IF(APPLE)
SET_PROPERTY(
TEST ${NAME} APPEND PROPERTY ENVIRONMENT
"DYLD_LIBRARY_PATH=${PLUGINDIR}:$ENV{DYLD_LIBRARY_PATH}")
ELSE()
SET_PROPERTY(
TEST ${NAME} APPEND PROPERTY ENVIRONMENT
"LD_LIBRARY_PATH=${PLUGINDIR}:$ENV{LD_LIBRARY_PATH}")
ENDIF()
ENDIF()
ENDMACRO()

MACRO(REGISTER_TEST NAME)
ADD_TEST(${NAME} "${TEST_COMMAND}" "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.py")

# Update PYTHONPATH to find the Python module
SET_TESTS_PROPERTIES(${NAME} PROPERTIES ENVIRONMENT
"PYTHONPATH=${CMAKE_BINARY_DIR}/src")

SET_TEST_ENV(${NAME})
ENDMACRO()

# Check roboptim-py internal API.
Expand Down
1 change: 1 addition & 0 deletions tests/to-python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ BOOST_AUTO_TEST_CASE (redir)
ToPython tp;

tp << "import numpy as np"
<< "np.set_printoptions(formatter={'all': lambda x: str(x)})"
<< "ar = np.zeros((3,3))"
<< "print(ar)"
<< "ar[0,1] = 42."
Expand Down
6 changes: 3 additions & 3 deletions tests/to-python.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[[ 0. 0. 0.]
[ 0. 0. 0.]
[ 0. 0. 0.]]
[[0.0 0.0 0.0]
[0.0 0.0 0.0]
[0.0 0.0 0.0]]
42.0