Skip to content

Commit

Permalink
Merge pull request #49 from cchampet/fix_buildWithPython3
Browse files Browse the repository at this point in the history
Fix build when generate SWIG java and python 3 bindings
  • Loading branch information
fabiencastan committed Feb 6, 2016
2 parents a073be8 + 4980e6a commit 96db7d3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
23 changes: 10 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ env:
- SEQUENCEPARSER_BUILD=${TRAVIS_BUILD_DIR}/build-sequenceparser
- SEQUENCEPARSER_INSTALL=${TRAVIS_BUILD_DIR}/install-sequenceparser
- CI_NODE_TOTAL=2
matrix:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.4

# This results in a 2×2 build matrix.
# Where the variables are: os / compiler
# This results in a 2×2x2 build matrix.
# Where the variables are: os / compiler / python version

addons:
apt:
sources: ['boost-latest', 'kalakris-cmake']
sources: ['boost-latest', 'kalakris-cmake', 'pythonxy-devel']
packages:
- cmake
- swig
- libboost1.55-all-dev
- python-dev
- python-nose
- python3-dev
- python3-nose

cache:
# Caching Ubuntu packages
Expand All @@ -41,13 +46,5 @@ before_script:
- uname -a

script:
# build
- mkdir ${SEQUENCEPARSER_BUILD} && cd ${SEQUENCEPARSER_BUILD}
- cmake .. -DCMAKE_INSTALL_PREFIX=${SEQUENCEPARSER_INSTALL} -DSEQUENCEPARSER_PYTHON_VERSION=2.7
- make
- make install

# tests
- cd ${TRAVIS_BUILD_DIR}
- export PYTHONPATH=$PYTHONPATH:${SEQUENCEPARSER_INSTALL}/lib/python2.7/site-packages
- nosetests pyTest
- tools/travis/build.sh
- tools/travis/launch_tests.sh
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(SWIG_FOUND)
set_source_files_properties(${SEQUENCEPARSER_BINDING_FILE} PROPERTIES CPLUSPLUS ON)

# Swig flags
set(CMAKE_SWIG_FLAGS -c++ -fcompact -small -O -Wall)
set(COMMON_SWIG_FLAGS -c++ -fcompact -small -O -Wall)

### PYTHON BINDING
find_package(PythonLibs ${SEQUENCEPARSER_PYTHON_VERSION})
Expand All @@ -56,7 +56,7 @@ if(SWIG_FOUND)

# Swig flags
if(${PYTHONLIBS_VERSION_STRING} VERSION_GREATER "3")
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -py3)
set(CMAKE_SWIG_FLAGS ${COMMON_SWIG_FLAGS} -py3)
endif()

# Create '_sequenceparser' shared lib (python)
Expand Down Expand Up @@ -103,7 +103,7 @@ if(SWIG_FOUND)
include_directories(${JNI_INCLUDE_DIRS})

# Swig flags
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -package org.sequenceparser)
set(CMAKE_SWIG_FLAGS ${COMMON_SWIG_FLAGS} -package org.sequenceparser)

# Create 'sequenceparser-java' shared lib
swig_add_module(sequenceparser-java java ${SEQUENCEPARSER_BINDING_FILE})
Expand Down
2 changes: 1 addition & 1 deletion src/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define SEQUENCEPARSER_VERSION_MAJOR 1
#define SEQUENCEPARSER_VERSION_MINOR 2
#define SEQUENCEPARSER_VERSION_MICRO 0
#define SEQUENCEPARSER_VERSION_MICRO 1

#include <string>
#include <cstddef>
Expand Down
17 changes: 17 additions & 0 deletions tools/travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status
set -e
# Print commands and their arguments as they are executed.
set -x

# Create directory of build
mkdir ${SEQUENCEPARSER_BUILD}
cd ${SEQUENCEPARSER_BUILD}

# Build sequenceParser
cmake --version
cmake .. -DCMAKE_INSTALL_PREFIX=${SEQUENCEPARSER_INSTALL} -DSEQUENCEPARSER_PYTHON_VERSION=${PYTHON_VERSION}
make -k
make install
cd ..
16 changes: 16 additions & 0 deletions tools/travis/launch_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status
set -e
# Print commands and their arguments as they are executed.
set -x

# set env
export PYTHONPATH=$PYTHONPATH:${SEQUENCEPARSER_INSTALL}/lib/python${PYTHON_VERSION}/site-packages

# nosetests
if [[ ${PYTHON_VERSION} == "2.7" ]]; then
nosetests ${TRAVIS_BUILD_DIR}/pyTest -v
elif [[ ${PYTHON_VERSION} == "3.4" ]]; then
nosetests3 ${TRAVIS_BUILD_DIR}/pyTest -v
fi

0 comments on commit 96db7d3

Please sign in to comment.