-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
43 lines (33 loc) · 1.73 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from setuptools import setup
import git
from pathlib import Path
from pybind11.setup_helpers import Pybind11Extension
import os
# Eigen can either be provided by conda or needs to be in "usr/include/eigen3"
# ToDo: The latter might break under windows.
class get_eigen_include(object):
# Based on the implementation from: https://github.com/MatPiq/RlassoModels/blob/master/setup.py
# This finally, allowed me to fix my building issues since the author of the repo above had
# the same problem: https://github.com/readthedocs/readthedocs.org/issues/9034.
# I made some changes to stream-line the cloning into Eigen a bit.
def __str__(self) -> str:
# Local build based on conda
if "CONDA_PREFIX" in os.environ:
if os.path.isdir(os.environ["CONDA_PREFIX"] + "/include/eigen3"):
return os.environ["CONDA_PREFIX"] + "/include/eigen3"
# Local build with alternative accepted location.
if os.path.isdir("usr/local/include/eigen3"):
return "usr/local/include/eigen3"
target_dir = Path(__file__).resolve().parent / "eigen"
if target_dir.exists():
return target_dir.name
# If we cannot find an eigen installation in the current step we have to download it first.
# See: https://gist.github.com/plembo/a786ce2851cec61ac3a051fcaf3ccdab
git.Repo.clone_from("https://gitlab.com/libeigen/eigen.git",target_dir,branch="3.4.0")
return target_dir.name
# Create Pybind setuptools extension
ext = Pybind11Extension(name='cpp_solvers',
sources=['src/mssm/src/cpp/cpp_solvers.cpp'],
include_dirs=[get_eigen_include()],
cxx_std=14)
setup(ext_modules=[ext])