-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'wrap/' changes from dfa624e77..09f8bbf71
09f8bbf71 Merge pull request #25 from borglab/fix/function-name 0dbfb6c13 fix function name to be the correct one f69f8b01f Merge pull request #24 from borglab/fix/pip 6519a6627 use pip install to overcome superuser issues b11ecf4e8 Merge pull request #23 from borglab/fix/remove-pip-args 813030108 remove pip-args since we are using setup.py 498d233e0 Merge pull request #22 from borglab/fix/package-install 846212ac3 set correct flags for installing gtwrap package 62161cd20 Merge pull request #21 from borglab/feature/script-vars 93be1d9f8 set script variables and move pybind11 loading so gtwrap can be used under gtsam 8770e3c7e Merge pull request #20 from borglab/fix/pybind-include 8c3c83618 proper placement of pybind11 include a9ad4f504 Merge pull request #19 from borglab/feature/package 99d8a12c7 added more documentation 4cbec1579 change to macro so we don't have to deal with function scopes b83e405b8 updates to completely install the package 38a64b3de new scripts which will be installed to bin directory bf9646235 Merge pull request #18 from borglab/fix/cmake-min c7c280099 Consistent cmake minimum required 42df58f62 Merge pull request #17 from borglab/fix/cleanup e580b282d version bump 4ccd66fa5 More finegrained handling of Python version 6476fd710 Merge pull request #16 from borglab/feature/better-find-python 8ac1296a0 use setup.py to install dependencies e9ac473be install dependencies and support versions of CMake<3.12 cf272dbd2 Merge pull request #15 from borglab/feature/utils ffc9cc4f7 new utils to reduce boilerplate 20e8e8b7a Merge pull request #11 from borglab/feature/package 04b844bd6 use new version of FindPython and be consistent 3f9d7a32a Merge pull request #13 from borglab/add_license c791075a6 Add LICENSE 517b67c46 correct working directory for setup.py 1b22b47ae move matlab.h to root directory 37b407214 Proper source directory path for use in other projects 61696dd5d configure PybindWrap within the cmake directory 1b91fc9af add config file so we can use find_package a1e6f4f53 small typo da9f351be updated README and housekeeping 64b8f78d5 files needed to allow for packaging bddda7f54 package structure git-subtree-dir: wrap git-subtree-split: 09f8bbf7172ba8b1bd3d2484795743f16e1a5893
- Loading branch information
1 parent
16418e2
commit 7cc7232
Showing
18 changed files
with
424 additions
and
204 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
__pycache__/ | ||
.vscode/ | ||
*build* | ||
*dist* | ||
*.egg-info |
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,55 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
|
||
# Set the project name and version | ||
project(GTwrap VERSION 1.0) | ||
|
||
# ############################################################################## | ||
# General configuration | ||
|
||
set(WRAP_PYTHON_VERSION | ||
"Default" | ||
CACHE STRING "The Python version to use for wrapping") | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GtwrapUtils.cmake) | ||
gtwrap_get_python_version(${WRAP_PYTHON_VERSION}) | ||
|
||
# ############################################################################## | ||
# Install the CMake file to be used by other projects | ||
if(WIN32 AND NOT CYGWIN) | ||
set(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/CMake") | ||
else() | ||
set(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/cmake") | ||
endif() | ||
|
||
# Install scripts to the standard CMake script directory. | ||
install(FILES cmake/gtwrapConfig.cmake cmake/PybindWrap.cmake | ||
cmake/GtwrapUtils.cmake | ||
DESTINATION "${SCRIPT_INSTALL_DIR}/gtwrap") | ||
|
||
# Install wrapping scripts as binaries to `CMAKE_INSTALL_PREFIX/bin` so they can | ||
# be invoked for wrapping. | ||
install(PROGRAMS scripts/pybind_wrap.py scripts/matlab_wrap.py TYPE BIN) | ||
|
||
# Install pybind11 directory to `CMAKE_INSTALL_PREFIX/lib/pybind11` This will | ||
# allow the gtwrapConfig.cmake file to load it later. | ||
install(DIRECTORY pybind11 TYPE LIB) | ||
|
||
# ############################################################################## | ||
# Install the Python package | ||
find_package( | ||
Python ${WRAP_PYTHON_VERSION} | ||
COMPONENTS Interpreter | ||
REQUIRED) | ||
|
||
# Detect virtualenv and set Pip args accordingly | ||
# https://www.scivision.dev/cmake-install-python-package/ | ||
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX}) | ||
set(_pip_args) | ||
else() | ||
set(_pip_args "--user") | ||
endif() | ||
#TODO add correct flags for virtualenv | ||
|
||
# Finally install the gtwrap python package. | ||
execute_process(COMMAND ${Python_EXECUTABLE} -m pip install . ${_pip_args} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_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,13 @@ | ||
Copyright (c) 2010, Georgia Tech Research Corporation | ||
Atlanta, Georgia 30332-0415 | ||
All Rights Reserved | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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
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,74 @@ | ||
# Utilities to help with wrapping. | ||
|
||
macro(get_python_version) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.12.0") | ||
# Use older version of cmake's find_python | ||
find_package(PythonInterp) | ||
|
||
if(NOT ${PYTHONINTERP_FOUND}) | ||
message( | ||
FATAL_ERROR | ||
"Cannot find Python interpreter. Please install Python >= 3.6.") | ||
endif() | ||
|
||
find_package(PythonLibs ${PYTHON_VERSION_STRING}) | ||
|
||
set(Python_VERSION_MAJOR | ||
${PYTHON_VERSION_MAJOR} | ||
PARENT_SCOPE) | ||
set(Python_VERSION_MINOR | ||
${PYTHON_VERSION_MINOR} | ||
PARENT_SCOPE) | ||
set(Python_VERSION_PATCH | ||
${PYTHON_VERSION_PATCH} | ||
PARENT_SCOPE) | ||
set(Python_EXECUTABLE | ||
${PYTHON_EXECUTABLE} | ||
PARENT_SCOPE) | ||
|
||
else() | ||
# Get info about the Python interpreter | ||
# https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython | ||
find_package(Python COMPONENTS Interpreter Development) | ||
|
||
if(NOT ${Python_FOUND}) | ||
message( | ||
FATAL_ERROR | ||
"Cannot find Python interpreter. Please install Python>=3.6.") | ||
endif() | ||
|
||
endif() | ||
endmacro() | ||
|
||
# Set the Python version for the wrapper and set the paths to the executable and | ||
# include/library directories. WRAP_PYTHON_VERSION can be "Default" or a | ||
# specific major.minor version. | ||
macro(gtwrap_get_python_version WRAP_PYTHON_VERSION) | ||
# Unset these cached variables to avoid surprises when the python in the | ||
# current environment are different from the cached! | ||
unset(Python_EXECUTABLE CACHE) | ||
unset(Python_INCLUDE_DIRS CACHE) | ||
unset(Python_VERSION_MAJOR CACHE) | ||
unset(Python_VERSION_MINOR CACHE) | ||
unset(Python_VERSION_PATCH CACHE) | ||
|
||
# Allow override | ||
if(${WRAP_PYTHON_VERSION} STREQUAL "Default") | ||
# Check for Python3 or Python2 in order | ||
get_python_version() | ||
|
||
# Set the wrapper python version | ||
set(WRAP_PYTHON_VERSION | ||
"${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}.${Python_VERSION_PATCH}" | ||
CACHE STRING "The version of Python to build the wrappers against." | ||
FORCE) | ||
|
||
else() | ||
# Find the Python that best matches the python version specified. | ||
find_package( | ||
Python ${WRAP_PYTHON_VERSION} | ||
COMPONENTS Interpreter Development | ||
EXACT REQUIRED) | ||
endif() | ||
|
||
endmacro() |
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
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,27 @@ | ||
# This config file modifies CMAKE_MODULE_PATH so that the wrap cmake files may | ||
# be included This file also allows the use of `find_package(gtwrap)` in CMake. | ||
|
||
set(GTWRAP_DIR "${CMAKE_CURRENT_LIST_DIR}") | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") | ||
|
||
if(WIN32 AND NOT CYGWIN) | ||
set(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/CMake") | ||
else() | ||
set(SCRIPT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/cmake") | ||
endif() | ||
|
||
# Standard includes | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
include(CMakeDependentOption) | ||
|
||
# Load all the CMake scripts from the standard location | ||
include(${SCRIPT_INSTALL_DIR}/gtwrap/PybindWrap.cmake) | ||
include(${SCRIPT_INSTALL_DIR}/gtwrap/GtwrapUtils.cmake) | ||
|
||
# Set the variables for the wrapping scripts to be used in the build. | ||
set(PYBIND_WRAP_SCRIPT "${CMAKE_INSTALL_FULL_BINDIR}/pybind_wrap.py") | ||
set(MATLAB_WRAP_SCRIPT "${CMAKE_INSTALL_FULL_BINDIR}/matlab_wrap.py") | ||
|
||
# Load the pybind11 code from the library installation path | ||
add_subdirectory(${CMAKE_INSTALL_FULL_LIBDIR}/pybind11 pybind11) |
Empty file.
File renamed without changes.
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
Oops, something went wrong.