Skip to content
Snippets Groups Projects
Unverified Commit 1477a95b authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #259 from jcarpent/devel

Add generation of Python stubs
parents 4972b13b a5e72306
No related branches found
No related tags found
No related merge requests found
Pipeline #15886 passed with warnings
......@@ -4,8 +4,10 @@ on: [push,pull_request]
jobs:
eigenpy-conda:
name: CI - EigenPy on ${{ matrix.os }} via Conda
name: CI on ${{ matrix.os }} via Conda
runs-on: ${{ matrix.os }}
env:
CCACHE_DIR: /github/home/.ccache # Enable ccache
strategy:
fail-fast: false
......@@ -14,10 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
run: |
git submodule update --init
with:
submodules: recursive
- uses: conda-incubator/setup-miniconda@v2
with:
......@@ -26,22 +26,27 @@ jobs:
environment-file: .github/workflows/conda/environment.yml
python-version: 3.8
- uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ matrix.os }}
- name: Install cmake and update conda
shell: bash -l {0}
run: |
conda activate eigenpy
conda install cmake -c main
- name: Build EigenPy
shell: bash -l {0}
run: |
conda activate eigenpy
echo $CONDA_PREFIX
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$(which python3)
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$(which python3) -DGENERATE_PYTHON_STUBS=ON
make
make build_tests
export CTEST_OUTPUT_ON_FAILURE=1
......
......@@ -39,6 +39,7 @@ jobs:
-G "NMake Makefiles" ^
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^
-DCMAKE_BUILD_TYPE=Release ^
-DGENERATE_PYTHON_STUBS=ON ^
-DPYTHON_SITELIB=%CONDA_PREFIX%\Lib\site-packages ^
-DPYTHON_EXECUTABLE=%CONDA_PREFIX%\python.exe ^
..
......
......@@ -44,6 +44,8 @@ INCLUDE(cmake/python.cmake)
INCLUDE(cmake/ide.cmake)
INCLUDE(cmake/apple.cmake)
OPTION(GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF)
STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# If needed, fix CMake policy for APPLE systems
......@@ -60,6 +62,16 @@ FIND_NUMPY()
IF(WIN32)
LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})
# Set default Windows build paths
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH "Single directory for all libraries")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH "Single directory for all executables")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH "Sing$le directory for all archives")
ENDIF(WIN32)
# ----------------------------------------------------
......@@ -150,7 +162,7 @@ SET(${PROJECT_NAME}_SOLVERS_SOURCES
SET(${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/decompositions.cpp
)
SET(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_SOLVERS_SOURCES}
${${PROJECT_NAME}_DECOMPOSITIONS_SOURCES}
......@@ -175,11 +187,11 @@ SET(${PROJECT_NAME}_SOURCES
)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
SYSTEM PUBLIC
${Boost_INCLUDE_DIRS}
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
SYSTEM PUBLIC
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
......
Subproject commit 4b30eba00b9e197583f3239e5a6a454e8655ea03
Subproject commit 11fe06f8159e6abcf251214fd22b37d6b6dfa695
......@@ -3,33 +3,34 @@
#
# --- LIBRARY --- #
SET(PYWRAP ${PROJECT_NAME}_pywrap)
SET(PYWRAP ${PROJECT_NAME}_pywrap)
SET(PYWRAP ${PYWRAP} PARENT_SCOPE)
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}")
include(${PROJECT_SOURCE_DIR}/cmake/stubs.cmake)
ADD_CUSTOM_TARGET(python)
SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
ADD_LIBRARY(${PYWRAP} SHARED main.cpp)
ADD_DEPENDENCIES(python ${PYWRAP})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME})
# BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS spews conversion warnings from int to long unsigned int.
# Unfortunately, using literals does not work in a macro. As such, this turns them off for the entire wrapper:
IF(NOT WIN32)
TARGET_COMPILE_OPTIONS(${PYWRAP} PRIVATE "-Wno-conversion")
ENDIF()
IF(IS_ABSOLUTE ${PYTHON_SITELIB})
SET(${PYWRAP}_INSTALL_DIR ${PYTHON_SITELIB}/${PROJECT_NAME})
SET(ABSOLUTE_PYTHON_SITELIB ${PYTHON_SITELIB})
ELSE()
SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
SET(ABSOLUTE_PYTHON_SITELIB ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB})
ENDIF()
SET(${PYWRAP}_INSTALL_DIR ${ABSOLUTE_PYTHON_SITELIB}/${PROJECT_NAME})
SET_TARGET_PROPERTIES(${PYWRAP}
PROPERTIES
PROPERTIES
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
OUTPUT_NAME "${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}"
)
......@@ -39,12 +40,20 @@ ENDIF()
INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
# --- GENERATE STUBS
IF(GENERATE_PYTHON_STUBS)
LOAD_STUBGEN()
GENERATE_STUBS(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_NAME} ${ABSOLUTE_PYTHON_SITELIB})
ENDIF(GENERATE_PYTHON_STUBS)
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
__init__.py
)
FOREACH(python ${PYTHON_FILES})
PYTHON_BUILD(${PROJECT_NAME} ${python})
INSTALL(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
......
#
# Copyright (c) 2017-2019 CNRS INRIA
# Copyright (c) 2017-2021 CNRS INRIA
#
# This file is part of eigenpy
# eigenpy is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# Pinocchio is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# eigenpy If not, see
# <http://www.gnu.org/licenses/>.
from .eigenpy import *
from .eigenpy import __version__, __raw_version__
from .eigenpy_pywrap import *
from .eigenpy_pywrap import __version__, __raw_version__
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2020, INRIA
* Copyright 2018-2021, INRIA
*/
#include "eigenpy/eigenpy.hpp"
......@@ -19,42 +19,42 @@
using namespace eigenpy;
BOOST_PYTHON_MODULE(eigenpy)
BOOST_PYTHON_MODULE(eigenpy_pywrap)
{
namespace bp = boost::python;
enableEigenPy();
bp::scope().attr("__version__") = eigenpy::printVersion();
bp::scope().attr("__raw_version__") = bp::str(EIGENPY_VERSION);
bp::def("checkVersionAtLeast",&eigenpy::checkVersionAtLeast,
bp::args("major_version","minor_version","patch_version"),
"Checks if the current version of EigenPy is at least the version provided by the input arguments.");
exposeAngleAxis();
exposeQuaternion();
exposeGeometryConversion();
exposeComputationInfo();
{
bp::scope solvers = boost::python::class_<SolversScope>("solvers");
exposeSolvers();
exposePreconditioners();
register_symbolic_link_to_registered_type<Eigen::ComputationInfo>();
}
{
using namespace Eigen;
bp::def("is_approx",(bool (*)(const Eigen::MatrixBase<MatrixXd> &, const Eigen::MatrixBase<MatrixXd> &, const double &))&is_approx<MatrixXd,MatrixXd>,
bp::args("A","B","prec"),
"Returns True if A is approximately equal to B, within the precision determined by prec.");
bp::def("is_approx",(bool (*)(const Eigen::MatrixBase<MatrixXd> &, const Eigen::MatrixBase<MatrixXd> &))&is_approx<MatrixXd,MatrixXd>,
bp::args("A","B"),
"Returns True if A is approximately equal to B.");
}
exposeDecompositions();
}
......@@ -42,26 +42,26 @@ ADD_PYTHON_UNIT_TEST("py-return-by-ref" "unittest/python/test_return_by_ref.py"
ADD_PYTHON_UNIT_TEST("py-eigen-ref" "unittest/python/test_eigen_ref.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-user-type" "unittest/python/test_user_type.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-switch" "unittest/python/test_switch.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-switch" "unittest/python/test_switch.py" "python;unittest")
SET_TESTS_PROPERTIES("py-switch" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-dimensions" "unittest/python/test_dimensions.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-dimensions" "unittest/python/test_dimensions.py" "python;unittest")
SET_TESTS_PROPERTIES("py-dimensions" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-version" "unittest/python/test_version.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-version" "unittest/python/test_version.py" "python;unittest")
SET_TESTS_PROPERTIES("py-version" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-eigen-solver" "unittest/python/test_eigen_solver.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-eigen-solver" "unittest/python/test_eigen_solver.py" "python;unittest")
SET_TESTS_PROPERTIES("py-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-self-adjoint-eigen-solver" "unittest/python/test_self_adjoint_eigen_solver.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-self-adjoint-eigen-solver" "unittest/python/test_self_adjoint_eigen_solver.py" "python;unittest")
SET_TESTS_PROPERTIES("py-self-adjoint-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-LLT" "unittest/python/test_LLT.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-LLT" "unittest/python/test_LLT.py" "python;unittest")
SET_TESTS_PROPERTIES("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python;unittest")
SET_TESTS_PROPERTIES("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-MINRES" "unittest/python/test_MINRES.py" "python/eigenpy;unittest")
ADD_PYTHON_UNIT_TEST("py-MINRES" "unittest/python/test_MINRES.py" "python;unittest")
SET_TESTS_PROPERTIES("py-MINRES" PROPERTIES DEPENDS ${PYWRAP})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment