Skip to content

Commit

Permalink
Port Python bindings to Cython (#36)
Browse files Browse the repository at this point in the history
* Switch to Cython bindings

* [ci] Adapt travis.yml to changes

* [ci] Prevent install directory removal

* Move wrapper functions to private pxd

* Update copyright

* Fix pickling and unit tests

* Fixes for Python 3

* [CI] Setup a Python 3.4 CI build

* Add an option to install Python bindings to user space

* Fix a few more Python 3 string issues

* Use Eigen3ToPython and SVA master

* Squashed '.travis/' changes from 7a40a28..bad6dbd

bad6dbd Allow to specify pybindgen install prefix
3f214dd Update pybindgen archive url
f13ddca Use a common script for Eigen 3.2 and 3.3
0d26976 Add a script for Eigen 3.3
027bca4 Update Eigen 3.2 version to 3.2.10
629f539 ipopt: update to 3.12.6
87f7ee7 eigen: update to 3.2.9
a0c7e47 common.sh: fix OS X environment
811fbd6 Merge pull request #31 from francois-keith/dev4
4c8a74c Hard code the path to git.exe
8c1c5f5 Build in debug.
89d0b39 Add some intermediary checks.
c2f4554 [AppVeyor] Add a method to run the unit tests.
e59a441 Correct choco install.
af4c533 Merge pull request #30 from jcarpent/master
00d90b0 Fix bug in common.sh
9da636c Merge pull request #29 from jcarpent/master
dd15db5 Use CI_BRANCH instead of TRAVIS_BRANCH
448cc3f Set DO_*_ON_BRANCH to the current branch if they are not yet defined
c5ed776 [Cppcheck] Do ccpcheck only on specified branches
3c52bd1 [Coverage] Do coverage only on specified branches
2a03b5b [AppVeyor] Support for projects with fortran subdirectory
b819e8a dependencies: add missing -qq for apt-get
9b94f1a dependencies/ipopt: install dependencies with apt
7b21446 dependencies: add script to install Ipopt from source
211e163 Merge pull request #28 from gergondet/topic/Win32
8f7b969 [Win32] Add AppVeyor support
REVERT: 7a40a28 Update submodule before building
REVERT: bc0a72e [Win32] Solve an issue in functions
REVERT: 99d898d [Win32] Add AppVeyor support

git-subtree-dir: .travis
git-subtree-split: bad6dbd29cf70e852e5e427e876390d954ca7d6b

* Fix test include path
  • Loading branch information
gergondet authored Jun 7, 2017
1 parent 68ee6f4 commit 3a1a2b6
Show file tree
Hide file tree
Showing 81 changed files with 2,304 additions and 1,373 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.pyc
*~
.clang-format
binding/python/build/
binding/python/rbdyn/rbdyn.cpp
binding/python/rbdyn/rbdyn.so
binding/python/rbdyn/__init__.py
binding/python/setup.py
27 changes: 16 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2012-2016 CNRS-UM LIRMM, CNRS-AIST JRL
# Copyright 2012-2017 CNRS-UM LIRMM, CNRS-AIST JRL
#
# This file is part of RBDyn.
#
Expand All @@ -19,24 +19,29 @@ sudo: required
dist: trusty
language: cpp
compiler:
- gcc
- clang
- gcc
- clang
env:
global:
- APT_DEPENDENCIES="doxygen doxygen-latex libboost-all-dev python-numpy"
- GIT_DEPENDENCIES="jrl-umi3218/SpaceVecAlg"
- APT_DEPENDENCIES="doxygen doxygen-latex libboost-all-dev"
- GIT_DEPENDENCIES="jrl-umi3218/Eigen3ToPython jrl-umi3218/SpaceVecAlg"
- GH_USERNAME=gergondet
- GH_REPO=jrl-umi3218/RBDyn
- secure: "FCe7ktcmBJWgEFsCBnG1QfIhkgNKM3uyRMS9mXiY8hfGQ9KGj/9X4qebUmfZ1ay6Rw2B22FXpRiJk2GmsHxo1RZH3f27b6F1mWz25RgJGX986k2nPChCshf5gORfMI5BKksyXFzp24sXBLcYKGz/xrOioSUY1wPJ3JZ7r7kDEV4="
- secure: FCe7ktcmBJWgEFsCBnG1QfIhkgNKM3uyRMS9mXiY8hfGQ9KGj/9X4qebUmfZ1ay6Rw2B22FXpRiJk2GmsHxo1RZH3f27b6F1mWz25RgJGX986k2nPChCshf5gORfMI5BKksyXFzp24sXBLcYKGz/xrOioSUY1wPJ3JZ7r7kDEV4=
matrix:
- USE_PYTHON34=false
- USE_PYTHON34=true
notifications:
email:
- [email protected]
slack:
rooms:
secure: N2C/Q9nr/TNjVE1UIRhT7gXN6bfJCe1nH7FIMA0RrANsdGkGsJHhuJsiOs8cUE7ozRFSiZ/ewMSADqItfwwp692pI1wp2y0X8wxRMB3pmo01Owv7on6NgLHXY4Br6peCSwGem3MaywcN8QaBlPxNVXFTfGi39GDvA8szLkCGHGw=
script: ./.travis/run build
after_success: ./.travis/run after_success
after_failure: ./.travis/run after_failure
before_install:
- ./.travis/dependencies/eigen-3.2
- ./.travis/run before_install
- if [ $USE_PYTHON34 = true ]; then pushd .; pip install virtualenv; mkdir -p /tmp/_ci/virtualenv; virtualenv -p python3.4 3.4; source 3.4/bin/activate; popd; fi
- ./.travis/dependencies/eigen-3.2
- ./.travis/run before_install
matrix:
allow_failures:
- compiler: clang
- compiler: clang
5 changes: 4 additions & 1 deletion .travis/after_success
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ elif [[ ${CI_OS_NAME} = linux ]]; then
exit 0
fi

generate_coverage_data
if [[ ";${DO_COVERAGE_ON_BRANCH};" == *";${CI_BRANCH};"* ]]; then
generate_coverage_data
fi

# If it's not a fork or a pull request
if `test x${CI_REPO_SLUG} = x${GH_REPO} -a ${CI_PULL_REQUEST} = false`; then
set_push_uri
Expand Down
31 changes: 20 additions & 11 deletions .travis/build
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,32 @@ build_package()
echo "--> Building package..."

cd "$build_dir"
cmake "$root_dir" -DCMAKE_INSTALL_PREFIX="$install_dir" \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
-DCMAKE_MODULE_LINKER_FLAGS="--coverage" \
${CMAKE_ADDITIONAL_OPTIONS}

if [[ ";${DO_COVERAGE_ON_BRANCH};" == *";${CI_BRANCH};"* ]]; then
cmake "$root_dir" -DCMAKE_INSTALL_PREFIX="$install_dir" \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
-DCMAKE_MODULE_LINKER_FLAGS="--coverage" \
${CMAKE_ADDITIONAL_OPTIONS}
else
cmake "$root_dir" -DCMAKE_INSTALL_PREFIX="$install_dir" \
${CMAKE_ADDITIONAL_OPTIONS}
fi

${MAKE_PREFIX} make
make install

ALLOW_TESTSUITE_FAILURE=${ALLOW_TESTSUITE_FAILURE:-false}
make test || ${ALLOW_TESTSUITE_FAILURE}

cppcheck --quiet --enable=all \
-I $root_dir/src -I $root_dir/tests -I $root_dir/include \
-I $root_dir/tests/shared-tests \
-I $build_dir/include -I $install_dir/include \
-i $build_dir/CMakeFiles \
$root_dir || true
if [[ ";${DO_CPPCHECK_ON_BRANCH};" == *";${CI_BRANCH};"* ]]; then
cppcheck --quiet --enable=all \
-I $root_dir/src -I $root_dir/tests -I $root_dir/include \
-I $root_dir/tests/shared-tests \
-I $build_dir/include -I $install_dir/include \
-i $build_dir/CMakeFiles \
$root_dir || true
fi
}

# debian_build_package
Expand Down
13 changes: 13 additions & 0 deletions .travis/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ _setup_osx_env()
export CXX=g++-4.8
export CC=gcc-4.8
fi

export DYLD_LIBRARY_PATH="$install_dir/lib:$DYLD_LIBRARY_PATH"
export LTDL_LIBRARY_PATH="$install_dir/lib:$LTDL_LIBRARY_PATH"
export PKG_CONFIG_PATH="$install_dir/lib/pkgconfig:$PKG_CONFIG_PATH"
}

# setup_ci_env
Expand Down Expand Up @@ -227,6 +231,15 @@ setup_ci_env
export CMAKE_VERBOSE_MAKEFILE=1
export CTEST_OUTPUT_ON_FAILURE=1

# Add default DO_*_ON_BRANCH if needed
if [ -z ${DO_COVERAGE_ON_BRANCH+x} ]; then
export DO_COVERAGE_ON_BRANCH=${CI_BRANCH}
fi

if [ -z ${DO_CPPCHECK_ON_BRANCH+x} ]; then
export DO_CPPCHECK_ON_BRANCH=${CI_BRANCH}
fi

# Create layout.
mkdir -p "$build_dir"
mkdir -p "$install_dir"
23 changes: 3 additions & 20 deletions .travis/dependencies/eigen-3.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,7 @@
#
# Setup Eigen 3.2
#
. `dirname $0`/../common.sh
EIGEN_VERSION=3.2.10
EIGEN_HASH=b9cd8366d4e8

EIGEN_VERSION=3.2.8
EIGEN_HASH=07105f7124f9

# Checkout Eigen
cd "$build_dir"
wget --quiet "http://bitbucket.org/eigen/eigen/get/${EIGEN_VERSION}.tar.gz"
tar xzf ${EIGEN_VERSION}.tar.gz
cd "$build_dir/eigen-eigen-${EIGEN_HASH}/"
mkdir -p "$build_dir/eigen-eigen-${EIGEN_HASH}/_build"
cd "$build_dir/eigen-eigen-${EIGEN_HASH}/_build"

# Build, make and install Eigen
cmake .. -DCMAKE_INSTALL_PREFIX:STRING="$install_dir"
make
make install

# Check install
pkg-config --modversion "eigen3 >= ${EIGEN_VERSION}"
pkg-config --cflags "eigen3 >= ${EIGEN_VERSION}"
. `dirname $0`/eigen-common.sh $EIGEN_VERSION $EIGEN_HASH
8 changes: 8 additions & 0 deletions .travis/dependencies/eigen-3.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
#
# Setup Eigen 3.3
#
EIGEN_VERSION=3.3.1
EIGEN_HASH=f562a193118d

. `dirname $0`/eigen-common.sh $EIGEN_VERSION $EIGEN_HASH
25 changes: 25 additions & 0 deletions .travis/dependencies/eigen-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#
# Setup Eigen
#
. `dirname $0`/../common.sh

EIGEN_VERSION=$1
EIGEN_HASH=$2

# Checkout Eigen
cd "$build_dir"
wget --quiet "http://bitbucket.org/eigen/eigen/get/${EIGEN_VERSION}.tar.gz"
tar xzf ${EIGEN_VERSION}.tar.gz
cd "$build_dir/eigen-eigen-${EIGEN_HASH}/"
mkdir -p "$build_dir/eigen-eigen-${EIGEN_HASH}/_build"
cd "$build_dir/eigen-eigen-${EIGEN_HASH}/_build"

# Build, make and install Eigen
cmake .. -DCMAKE_INSTALL_PREFIX:STRING="$install_dir"
make
make install

# Check install
pkg-config --modversion "eigen3 >= ${EIGEN_VERSION}"
pkg-config --cflags "eigen3 >= ${EIGEN_VERSION}"
2 changes: 1 addition & 1 deletion .travis/dependencies/ipopt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
${SUDO_CMD} apt-get update -qq
${SUDO_CMD} apt-get install -qq libblas-dev liblapack-dev libmumps-seq-dev gfortran

IPOPT_VERSION=3.12.4
IPOPT_VERSION=3.12.6

build_dir=`mktemp -d`
trap "rm -rf -- '$build_dir'" EXIT
Expand Down
10 changes: 8 additions & 2 deletions .travis/dependencies/pybindgen-0.16
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@

. `dirname $0`/../common.sh

if [ $# -ge 1 ]; then
PYBINDGEN_INSTALL_PREFIX=$1
else
PYBINDGEN_INSTALL_PREFIX=/usr/local
fi

# Install dependencies
${SUDO_CMD} apt-get install -qq gccxml python-pygccxml

# Get pybindgen
cd "$build_dir"
wget --quiet https://pybindgen.googlecode.com/files/pybindgen-0.16.0.tar.bz2
wget --quiet https://launchpad.net/pybindgen/trunk/0.16/+download/pybindgen-0.16.0.tar.bz2
tar xjf pybindgen-0.16.0.tar.bz2
cd "$build_dir/pybindgen-0.16.0/"

# Configure build and install
./waf configure
./waf --prefix=$PYBINDGEN_INSTALL_PREFIX configure
./waf
${SUDO_CMD} ./waf install
29 changes: 24 additions & 5 deletions .travis/functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function install_choco_dependencies
{
ForEach($choco_dep in $Env:CHOCO_DEPENDENCIES.split(' '))
{
choco install $choco_dep
choco install $choco_dep -y
}
}

Expand All @@ -75,13 +75,17 @@ function install_git_dependencies
git clone -b "$git_dep_branch" "$git_dep_uri" "$git_dep"
cd $git_dep
git submodule update --init
if ($lastexitcode -ne 0){ exit $lastexitcode }
md build
cd build
# For projects that use cmake_add_subfortran directory this removes sh.exe
# from the path
$Env:Path = $Env:Path -replace "Git","dummy"
cmake ../ -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="${Env:CMAKE_INSTALL_PREFIX}" -DPYTHON_BINDING=OFF -DMINGW_GFORTRAN="$env:MINGW_GFORTRAN"
msbuild INSTALL.vcxproj
cmake ../ -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="${Env:CMAKE_INSTALL_PREFIX}" -DPYTHON_BINDING=OFF -DMINGW_GFORTRAN="$env:MINGW_GFORTRAN" -DGIT="C:/Program Files/Git/cmd/git.exe"

if ($lastexitcode -ne 0){ exit $lastexitcode }
msbuild INSTALL.vcxproj /p:Configuration=Debug
if ($lastexitcode -ne 0){ exit $lastexitcode }
# Reverse our dirty work
$Env:Path = $Env:Path -replace "dummy","Git"
}
Expand All @@ -97,11 +101,26 @@ function build_project
{
cd $Env:PROJECT_SOURCE_DIR
git submodule update --init
if ($lastexitcode -ne 0){ exit $lastexitcode }
md build
cd build
# See comment in dependencies regarding $Env:Path manipulation
$Env:Path = $Env:Path -replace "Git","dummy"
cmake ../ -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="${Env:CMAKE_INSTALL_PREFIX}" -DPYTHON_BINDING=OFF -DMINGW_GFORTRAN="$env:MINGW_GFORTRAN"
msbuild INSTALL.vcxproj
cmake ../ -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="${Env:CMAKE_INSTALL_PREFIX}" -DPYTHON_BINDING=OFF -DMINGW_GFORTRAN="$env:MINGW_GFORTRAN" -DGIT="C:/Program Files/Git/cmd/git.exe"
if ($lastexitcode -ne 0){ exit $lastexitcode }
msbuild INSTALL.vcxproj /p:Configuration=Debug
if ($lastexitcode -ne 0){ exit $lastexitcode }
$Env:Path = $Env:Path -replace "dummy","Git"
}

function test_project
{
cd %PROJECT_SOURCE_DIR%/build
ctest -N
ctest --build-config Debug --exclude-regex example
if ($lastexitcode -ne 0)
{
type Testing/Temporary/LastTest.log
exit $lastexitcode
}
}
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2012-2016 CNRS-UM LIRMM, CNRS-AIST JRL
# Copyright 2012-2017 CNRS-UM LIRMM, CNRS-AIST JRL
#
# This file is part of RBDyn.
#
Expand Down Expand Up @@ -33,7 +33,8 @@ SET(CXX_DISABLE_WERROR True)

SETUP_PROJECT()

option(PYTHON_BINDING "Generate python binding." OFF)
option(PYTHON_BINDING "Generate python binding." ON)
option(PYTHON_BINDING_USER_INSTALL "Install the Python bindings in user space" OFF)
option(DISABLE_TESTS "Disable unit tests." OFF)
option(BENCHMARKS "Generate benchmarks." OFF)

Expand All @@ -55,6 +56,8 @@ IF(MSVC)
SET(CMAKE_MSVCIDE_RUN_PATH "\$(SolutionDir)/src/\$(Configuration)")
ENDIF(MSVC)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

add_subdirectory(src)

if(NOT ${DISABLE_TESTS} OR ${BENCHMARKS})
Expand Down
Loading

0 comments on commit 3a1a2b6

Please sign in to comment.