Commit 4c0de5fc authored by ashawkey's avatar ashawkey
Browse files

add eigen as a submodule

parent 9a8da7d2
[submodule "third_party/eigen"]
path = third_party/eigen
url = https://gitlab.com/libeigen/eigen
...@@ -4,14 +4,8 @@ A CUDA Mesh BVH acceleration toolkit. ...@@ -4,14 +4,8 @@ A CUDA Mesh BVH acceleration toolkit.
### Install ### Install
Please make sure [`eigen >= 3.3`](https://eigen.tuxfamily.org/index.php?title=Main_Page) is installed. ```bash
For example, ubuntu systems can use `sudo apt install libeigen3-dev`. git clone --recursive https://github.com/ashawkey/cubvh
```python
pip install git+https://github.com/ashawkey/cubvh
# or locally
git clone https://github.com/ashawkey/cubvh
cd cubvh cd cubvh
pip install . pip install .
``` ```
...@@ -26,6 +20,12 @@ To patch up these two versions, clone this repository, and copy `patch/eigen` to ...@@ -26,6 +20,12 @@ To patch up these two versions, clone this repository, and copy `patch/eigen` to
cp -r patch/eigen ~/anaconda3/lib/python3.9/site-packages/torch/include/pybind11/ cp -r patch/eigen ~/anaconda3/lib/python3.9/site-packages/torch/include/pybind11/
``` ```
**`fatal error: Eigen/Dense: No such file or directory`**
Please make sure [`eigen >= 3.3`](https://eigen.tuxfamily.org/index.php?title=Main_Page) is installed.
We have included it as a submodule in this repository, but you can also install it in your system include path.
(For example, ubuntu systems can use `sudo apt install libeigen3-dev`.)
### Usage ### Usage
```python ```python
......
...@@ -7,83 +7,6 @@ from torch.utils.cpp_extension import BuildExtension, CUDAExtension ...@@ -7,83 +7,6 @@ from torch.utils.cpp_extension import BuildExtension, CUDAExtension
_src_path = os.path.dirname(os.path.abspath(__file__)) _src_path = os.path.dirname(os.path.abspath(__file__))
# ref: https://github.com/sxyu/sdf/blob/master/setup.py
def find_eigen(min_ver=(3, 3, 0)):
"""Helper to find or download the Eigen C++ library"""
import re, os
try_paths = [
'/usr/include/eigen3',
'/usr/local/include/eigen3',
os.path.expanduser('~/.local/include/eigen3'),
'C:/Program Files/eigen3',
'C:/Program Files (x86)/eigen3',
]
WORLD_VER_STR = "#define EIGEN_WORLD_VERSION"
MAJOR_VER_STR = "#define EIGEN_MAJOR_VERSION"
MINOR_VER_STR = "#define EIGEN_MINOR_VERSION"
EIGEN_WEB_URL = 'https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.bz2'
TMP_EIGEN_FILE = 'tmp_eigen.tar.bz2'
TMP_EIGEN_DIR = './eigen3.3.7'
min_ver_str = '.'.join(map(str, min_ver))
eigen_path = None
for path in try_paths:
macros_path = os.path.join(path, 'Eigen/src/Core/util/Macros.h')
if os.path.exists(macros_path):
macros = open(macros_path, 'r').read().split('\n')
world_ver, major_ver, minor_ver = None, None, None
for line in macros:
if line.startswith(WORLD_VER_STR):
world_ver = int(line[len(WORLD_VER_STR):])
elif line.startswith(MAJOR_VER_STR):
major_ver = int(line[len(MAJOR_VER_STR):])
elif line.startswith(MINOR_VER_STR):
minor_ver = int(line[len(MINOR_VER_STR):])
if world_ver is None or major_ver is None or minor_ver is None:
print('Failed to parse macros file', macros_path)
else:
ver = (world_ver, major_ver, minor_ver)
ver_str = '.'.join(map(str, ver))
if ver < min_ver:
print('Found unsuitable Eigen version', ver_str, 'at',
path, '(need >= ' + min_ver_str + ')')
else:
print('Found Eigen version', ver_str, 'at', path)
eigen_path = path
break
if eigen_path is None:
try:
import urllib.request
print("Couldn't find Eigen locally, downloading...")
req = urllib.request.Request(
EIGEN_WEB_URL,
data=None,
headers={
'User-Agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36'
})
with urllib.request.urlopen(req) as resp,\
open(TMP_EIGEN_FILE, 'wb') as file:
data = resp.read()
file.write(data)
import tarfile
tar = tarfile.open(TMP_EIGEN_FILE)
tar.extractall()
tar.close()
eigen_path = TMP_EIGEN_DIR
os.remove(TMP_EIGEN_FILE)
except:
print('Download failed, failed to find Eigen')
if eigen_path is not None:
print('Found eigen at', eigen_path)
return eigen_path
if os.name == "nt": if os.name == "nt":
# find cl.exe # find cl.exe
...@@ -169,7 +92,7 @@ setup( ...@@ -169,7 +92,7 @@ setup(
]], ]],
include_dirs=[ include_dirs=[
os.path.join(_src_path, 'include'), os.path.join(_src_path, 'include'),
find_eigen(), os.path.join(_src_path, 'third_party', 'eigen'),
], ],
extra_compile_args={ extra_compile_args={
'cxx': base_cflags, 'cxx': base_cflags,
......
Subproject commit e63d9f6ccb7f6f29f31241b87c542f3f0ab3112b
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment