-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") | ||
|
||
################################################################################ | ||
# Setup the build mode | ||
set(CMAKE_BUILD_TYPE "Release") | ||
message(STATUS "=====================================================") | ||
message(STATUS "configuring build for PyDart") | ||
message(STATUS "=====================================================") | ||
|
||
IF(NOT CMAKE_BUILD_TYPE) | ||
SET(CMAKE_BUILD_TYPE "Release") | ||
ENDIF(NOT CMAKE_BUILD_TYPE) | ||
|
||
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") | ||
|
||
IF(CMAKE_BUILD_TYPE MATCHES "Release") | ||
message(STATUS "Set the release mode") | ||
ADD_DEFINITIONS(-DNDEBUG ) | ||
ADD_DEFINITIONS(-DBOOST_UBLAS_NDEBUG ) | ||
ENDIF (CMAKE_BUILD_TYPE MATCHES "Release") | ||
|
||
IF(APPLE) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flat_namespace -undefined suppress") | ||
ELSEIF(UNIX) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-enum-compare") | ||
ENDIF() | ||
MESSAGE(STATUS "CXX_FLAGS = ${CMAKE_CXX_FLAGS}") | ||
|
||
################################################################################ | ||
# Find the required packages | ||
### SWIG | ||
find_package(SWIG REQUIRED) | ||
message(STATUS "SWIG_FOUND = ${SWIG_FOUND}") | ||
message(STATUS "SWIG_USE_FILE = ${SWIG_USE_FILE}") | ||
include(${SWIG_USE_FILE}) | ||
### PythonLibs | ||
find_package(PythonLibs REQUIRED) | ||
message(STATUS "PYTHON_INCLUDE_DIR = ${PYTHON_INCLUDE_DIR}") | ||
include_directories(${PYTHON_INCLUDE_DIR}) | ||
message(STATUS "PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}") | ||
|
||
### PythonLibs | ||
find_package(NumPy REQUIRED) | ||
message(STATUS "NUMPY_INCLUDE_DIRS = ${NUMPY_INCLUDE_DIRS}") | ||
include_directories(${NUMPY_INCLUDE_DIRS}) | ||
|
||
### Eigen | ||
find_package(Eigen REQUIRED) | ||
message(STATUS "Eigen_INCLUDE_DIRS = ${Eigen_INCLUDE_DIRS}") | ||
include_directories(${Eigen_INCLUDE_DIRS}) | ||
### OpenGL | ||
find_package(OpenGL) | ||
if (OPENGL_FOUND) | ||
message(STATUS "OPENGL FOUND") | ||
else (OPENGL_FOUND) | ||
message(STATUS "OPENGL NOT FOUND") | ||
endif () | ||
### GLUT | ||
find_package(GLUT) | ||
if (GLUT_FOUND) | ||
message(STATUS "GLUT FOUND") | ||
message(STATUS "GLUT_LIBRARIES = ${GLUT_LIBRARIES}") | ||
else (GLUT_FOUND) | ||
message(STATUS "GLUT NOT FOUND") | ||
endif () | ||
|
||
find_package(Bullet) | ||
if (BULLET_FOUND) | ||
message(STATUS "Bullet Found") | ||
message(STATUS "Bullet include directories = ${BULLET_INCLUDE_DIRS}") | ||
message(STATUS "Bullet Libraries = ${BULLET_LIBRARIES}") | ||
include_directories(${BULLET_INCLUDE_DIRS}) | ||
else (BULLET_FOUND) | ||
message(STATUS "Bullet NOT Found") | ||
endif () | ||
|
||
################################################################################ | ||
# Configure the project | ||
#### Directories | ||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/pydart_api") | ||
|
||
include_directories(".") | ||
include_directories("${CMAKE_SOURCE_DIR}") | ||
include_directories("${CMAKE_SOURCE_DIR}/pydart_api") | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
#### Projectfiles | ||
file(GLOB pydart_py "pydart/*.py") | ||
file(GLOB pydart_srcs "pydart_api/*.cpp") | ||
file(GLOB pydart_hdrs "pydart_api/*.h") | ||
file(GLOB pydart_interfaces "pydart_api/pydart_api.i") | ||
message(STATUS "pydart_py = ${pydart_py}") | ||
message(STATUS "pydart_hdrs = ${pydart_hdrs}") | ||
message(STATUS "pydart_srcs = ${pydart_srcs}") | ||
#### SWIG configurations | ||
set(CMAKE_SWIG_FLAGS "") | ||
set_source_files_properties(${pydart_interfaces} PROPERTIES CPLUSPLUS ON) | ||
set_source_files_properties(${pydart_interfaces} PROPERTIES SWIG_FLAGS "-includeall") | ||
#### SWIG commands | ||
set(CMAKE_SWIG_OUTDIR "${CMAKE_SOURCE_DIR}/pydart") | ||
swig_add_module(pydart_api python ${pydart_py} ${pydart_srcs} ${pydart_hdrs} ${pydart_interfaces}) | ||
swig_link_libraries(pydart_api ${PYTHON_LIBRARIES}) | ||
swig_link_libraries(pydart_api dart dart-core ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) | ||
swig_link_libraries(pydart_api ${BULLET_LIBRARIES}) | ||
|
||
# ADD_CUSTOM_TARGET(_pydart_api_py | ||
# COMMAND echo 'Copy _pydart_api.py to pydart directory if different' | ||
# COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
# "${CMAKE_BINARY_DIR}/_pydart_api.py" | ||
# "${CMAKE_SOURCE_DIR}/pydart/") | ||
# ADD_DEPENDENCIES(_pydart_api _pydart_api_py) | ||
install(FILES "${CMAKE_BINARY_DIR}/_pydart_api.so" | ||
DESTINATION "${CMAKE_SOURCE_DIR}/pydart") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from pydart import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# import sys | ||
# sys.path.append('/home/sehoonha/dev/pydart') | ||
import pydart | ||
|
||
print('Hello, PyDART!') | ||
pydart.init() | ||
print('pydart initialization OK') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Find Eigen | ||
# | ||
# This sets the following variables: | ||
# Eigen_FOUND | ||
# Eigen_INCLUDE_DIRS | ||
|
||
find_path(Eigen_INCLUDE_DIR | ||
NAMES Eigen/Core | ||
PATHS "${CMAKE_INSTALL_PREFIX}/include" | ||
PATH_SUFFIXES eigen3 eigen) | ||
|
||
set(Eigen_INCLUDE_DIRS ${Eigen_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Eigen DEFAULT_MSG Eigen_INCLUDE_DIR) | ||
|
||
mark_as_advanced(Eigen_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# - Find the NumPy libraries | ||
# This module finds if NumPy is installed, and sets the following variables | ||
# indicating where it is. | ||
# | ||
# TODO: Update to provide the libraries and paths for linking npymath lib. | ||
# | ||
# NUMPY_FOUND - was NumPy found | ||
# NUMPY_VERSION - the version of NumPy found as a string | ||
# NUMPY_VERSION_MAJOR - the major version number of NumPy | ||
# NUMPY_VERSION_MINOR - the minor version number of NumPy | ||
# NUMPY_VERSION_PATCH - the patch version number of NumPy | ||
# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 | ||
# NUMPY_INCLUDE_DIRS - path to the NumPy include files | ||
|
||
#============================================================================ | ||
# Copyright 2012 Continuum Analytics, Inc. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files | ||
# (the "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to permit | ||
# persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
# OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
#============================================================================ | ||
|
||
# Finding NumPy involves calling the Python interpreter | ||
if(NumPy_FIND_REQUIRED) | ||
find_package(PythonInterp REQUIRED) | ||
else() | ||
find_package(PythonInterp) | ||
endif() | ||
|
||
if(NOT PYTHONINTERP_FOUND) | ||
set(NUMPY_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" | ||
"import numpy as n; print(n.__version__); print(n.get_include());" | ||
RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS | ||
OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT | ||
ERROR_VARIABLE _NUMPY_ERROR_VALUE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) | ||
if(NumPy_FIND_REQUIRED) | ||
message(FATAL_ERROR | ||
"NumPy import failure:\n${_NUMPY_ERROR_VALUE}") | ||
endif() | ||
set(NUMPY_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
# Convert the process output into a list | ||
string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES_OUTPUT}) | ||
string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) | ||
# Just in case there is unexpected output from the Python command. | ||
list(GET _NUMPY_VALUES -2 NUMPY_VERSION) | ||
list(GET _NUMPY_VALUES -1 NUMPY_INCLUDE_DIRS) | ||
|
||
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _VER_CHECK "${NUMPY_VERSION}") | ||
if("${_VER_CHECK}" STREQUAL "") | ||
# The output from Python was unexpected. Raise an error always | ||
# here, because we found NumPy, but it appears to be corrupted somehow. | ||
message(FATAL_ERROR | ||
"Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n") | ||
return() | ||
endif() | ||
|
||
# Make sure all directory separators are '/' | ||
string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) | ||
|
||
# Get the major and minor version numbers | ||
string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) | ||
list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) | ||
list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) | ||
list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) | ||
string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) | ||
math(EXPR NUMPY_VERSION_DECIMAL | ||
"(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") | ||
|
||
find_package_message(NUMPY | ||
"Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" | ||
"${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") | ||
|
||
set(NUMPY_FOUND TRUE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Find TinyXML | ||
# | ||
# This sets the following variables: | ||
# TinyXML2_FOUND | ||
# TinyXML2_INCLUDE_DIRS | ||
# TinyXML2_LIBRARIES | ||
|
||
find_path(TinyXML2_INCLUDE_DIR tinyxml2.h | ||
PATHS "${CMAKE_INSTALL_PREFIX}/include") | ||
|
||
set(TinyXML2_INCLUDE_DIRS ${TinyXML2_INCLUDE_DIR}) | ||
|
||
if(MSVC) | ||
set(TinyXML2_LIBRARIES optimized tinyxml2 debug tinyxml2d) | ||
else() | ||
set(TinyXML2_LIBRARIES tinyxml2) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TinyXML2_INCLUDE_DIR) | ||
|
||
mark_as_advanced(TinyXML2_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pydart import * | ||
# from pydart_api import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from setuptools import setup | ||
|
||
setup(name='pydart', | ||
version='0.01', | ||
description='Python Interface for DART Simulator', | ||
url='https://github.com/sehoonha/pydart', | ||
author='Sehoon Ha', | ||
author_email='sehoon.ha@gmail.com', | ||
license='BSD', | ||
packages=['pydart'], | ||
zip_safe=False) |