Skip to content

Commit

Permalink
Merge pull request #375 from jcarpent/devel
Browse files Browse the repository at this point in the history
Enhance support of Tensor module in external applications
  • Loading branch information
jorisv authored Nov 23, 2023
2 parents 0bdb505 + 7a0cad4 commit 3450df0
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos-linux-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
os: ["ubuntu-latest", "macos-latest"]
cxx_options: ['', '-mavx2']
build_type: [Release, Debug]
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.8", "3.12"]

include:
- os: ubuntu-latest
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/windows-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
activate-environment: eigenpy
environment-file: .github/workflows/conda/environment.yml
python-version: 3.7
python-version: "3.10"
- name: Build Eigenpy
shell: cmd /C CALL {0}
env:
Expand Down Expand Up @@ -51,11 +51,6 @@ jobs:
cmake --build . --config Release --target install
if errorlevel 1 exit 1
:: Build stubs
git clone https://github.com/jcarpent/pybind11-stubgen.git
python "%CD%\pybind11-stubgen\pybind11_stubgen\__init__.py" -o %CONDA_PREFIX%\Lib\site-packages\eigenpy eigenpy --boost-python --ignore-invalid signature --no-setup-py --root-module-suffix ""
if errorlevel 1 exit 1
:: Testing
ctest --output-on-failure -C Release -V
if errorlevel 1 exit 1
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added
- Add new helper functions to check Tensor support

### Fixed
- Fix stub generation on Windows

## [3.1.3] - 2023-11-09

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ endif(SUFFIX_SO_VERSION)

if(NOT WIN32)
target_compile_options(
${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>
${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj -MP>
"-Wno-conversion")
else()
target_compile_options(${PROJECT_NAME}
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj -MP>)
target_compile_definitions(${PROJECT_NAME} PUBLIC "HAVE_SNPRINTF")
endif()

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ EigenPy — Versatile and efficient Python bindings between Numpy and Eigen
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
</p>

**EigenPy** is an open source framework which allows to bind the famous [Eigen](http://eigen.tuxfamily.org) C++ library in Python via Boost.Python.
**EigenPy** is an open-source framework that allows the binding of the famous [Eigen](http://eigen.tuxfamily.org) C++ library in Python via Boost.Python.

**EigenPy** provides:
- full memory sharing between Numpy and Eigen avoiding memory allocation
- full memory sharing between Numpy and Eigen, avoiding memory allocation
- full support Eigen::Ref avoiding memory allocation
- full support of the Eigen::Tensor module
- exposition of the Geometry module of Eigen for easy code prototyping
- standard matrix decomposion routines of Eigen such as the Cholesky decomposition, SVD decomposition, QR decomposition, and etc.
- standard matrix decomposion routines of Eigen such as the Cholesky decomposition, SVD decomposition, QR decomposition, etc.
- full support of SWIG objects
- full support of runtime declaration of Numpy scalar types
- extended API to expose std::vector types
- full support of vectorization between C++ and Python (all the hold objects are properly aligned in memory)

## Setup

The installation of **EigenPy** on your computer is made easy for Linux/BSD, Mac OS X and Windows environments.
The installation of **EigenPy** on your computer is made easy for Linux/BSD, Mac OS X, and Windows environments.

### The Conda approach

Expand All @@ -36,7 +36,7 @@ conda install eigenpy -c conda-forge

### Ubuntu

You can easily install **EigenPy** from binairies.
You can easily install **EigenPy** from binaries.

#### Add robotpkg apt repository
1. Add robotpkg as source repository to apt:
Expand All @@ -47,7 +47,7 @@ sudo sh -c "echo 'deb [arch=amd64] http://robotpkg.openrobots.org/packages/debia
```
curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add -
```
3. You need to run at least once apt update to fetch the package descriptions:
3. You need to run at least one apt update to fetch the package descriptions:
```bash
sudo apt-get update
```
Expand All @@ -58,12 +58,12 @@ sudo apt-get update
```bash
sudo apt install robotpkg-py35-eigenpy
```
where 35 should be replaced by the python 3 you want to work this (e.g. `robotpkg-py36-eigenpy` to work with Python 3.6).
where 35 should be replaced by the Python 3, you want to work this (e.g., `robotpkg-py36-eigenpy` to work with Python 3.6).

### Mac OS X

The installation of **EigenPy** on Mac OS X is made via [HomeBrew](https://brew.sh/).
You just need to register the tap of the sofware repository.
You just need to register the tap of the software repository.

```
brew tap gepetto/homebrew-gepetto
Expand All @@ -83,8 +83,9 @@ The following people have been involved in the development of **EigenPy**:
- [Sean Yen](https://www.linkedin.com/in/seanyentw) (Microsoft): Windows integration
- [Loïc Estève](https://github.com/lesteve) (INRIA): Conda integration
- [Wilson Jallet](https://manifoldfr.github.io/) (INRIA/LAAS-CNRS): core developer
- [Joris Vaillant](https://github.com/jorisv) (Inria): core developer and manager of the project

If you have taken part to the development of **EigenPy**, feel free to add your name and contribution here.
If you have taken part in the development of **EigenPy**, feel free to add your name and contribution here.

## Acknowledgments

Expand Down
2 changes: 1 addition & 1 deletion cmake
2 changes: 2 additions & 0 deletions include/eigenpy/eigenpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace eigenpy {
*/
void EIGENPY_DLLAPI enableEigenPy();

bool EIGENPY_DLLAPI withTensorSupport();

/* Enable the Eigen--Numpy serialization for the templated MatType class.*/
template <typename MatType>
void enableEigenPySpecific();
Expand Down
10 changes: 8 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ include("${JRL_CMAKE_MODULES}/stubs.cmake")
add_custom_target(python)
set_target_properties(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)

add_library(${PYWRAP} SHARED main.cpp)
add_library(${PYWRAP} MODULE main.cpp)
add_dependencies(python ${PYWRAP})
target_link_libraries(${PYWRAP} PUBLIC ${PROJECT_NAME})

python_build_get_target(python_build_target)
add_dependencies(${PYWRAP} ${python_build_target})

# 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:
Expand Down Expand Up @@ -56,8 +60,10 @@ install(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
if(GENERATE_PYTHON_STUBS)
load_stubgen()

# Set PYWRAP and PROJECT_NAME as stubs dependencies PROJECT_NAME is mandatory
# (even if it's a PYWRAP dependency) to find PROJECT_NAME name DLL on windows
generate_stubs(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_NAME}
${ABSOLUTE_PYTHON_SITELIB} ${PYWRAP})
${ABSOLUTE_PYTHON_SITELIB} ${PYWRAP} ${PROJECT_NAME})
endif(GENERATE_PYTHON_STUBS)

# --- INSTALL SCRIPTS
Expand Down
8 changes: 8 additions & 0 deletions src/eigenpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,12 @@ void enableEigenPy() {
exposeNoneType();
}

bool withTensorSupport() {
#ifdef EIGENPY_WITH_TENSOR_SUPPORT
return true;
#else
return false;
#endif
}

} // namespace eigenpy

0 comments on commit 3450df0

Please sign in to comment.