summaryrefslogtreecommitdiff
path: root/src/python/setup.py.in
blob: 2d96c57bc0c5479594d68b4cba5f2e4c0b24cf61 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from setuptools import setup, Extension
from Cython.Build import cythonize
from numpy import get_include as numpy_get_include

"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
    See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
    Author(s):       Vincent Rouvreau

   Copyright (C) 2019  Inria

   Modification(s):
     - YYYY/MM Author: Description of the modification
"""

__author__ = "Vincent Rouvreau"
__copyright__ = "Copyright (C) 2016  Inria"
__license__ = "MIT"

modules = [@GUDHI_PYTHON_MODULES_TO_COMPILE@]

source_dir='@CMAKE_CURRENT_SOURCE_DIR@/gudhi/'
extra_compile_args=[@GUDHI_PYTHON_EXTRA_COMPILE_ARGS@]
extra_link_args=[@GUDHI_PYTHON_EXTRA_LINK_ARGS@]
libraries=[@GUDHI_PYTHON_LIBRARIES@]
library_dirs=[@GUDHI_PYTHON_LIBRARY_DIRS@]
include_dirs = [numpy_get_include(), '@CMAKE_CURRENT_SOURCE_DIR@/gudhi/', @GUDHI_PYTHON_INCLUDE_DIRS@]
runtime_library_dirs=[@GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS@]

# Copied from https://github.com/pybind/python_example/blob/master/setup.py
class get_pybind_include(object):
    """Helper class to determine the pybind11 include path
    The purpose of this class is to postpone importing pybind11
    until it is actually installed, so that the ``get_include()``
    method can be invoked. """

    def __init__(self, user=False):
        self.user = user

    def __str__(self):
        import pybind11
        return pybind11.get_include(self.user)

# Create ext_modules list from module list
ext_modules = []
for module in modules:
    ext_modules.append(Extension(
        'gudhi.' + module,
        sources = [source_dir + module + '.pyx',],
        language = 'c++',
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        libraries=libraries,
        library_dirs=library_dirs,
        include_dirs=include_dirs,
        runtime_library_dirs=runtime_library_dirs,))
ext_modules = cythonize(ext_modules)

ext_modules.append(Extension(
    'gudhi.hera',
    sources = [source_dir + 'hera.cc'],
    language = 'c++',
    include_dirs = include_dirs +
        ['@CMAKE_SOURCE_DIR@/ext/hera/geom_matching/wasserstein/include',
        get_pybind_include(False), get_pybind_include(True)],
    extra_compile_args=extra_compile_args + [@GUDHI_PYBIND11_EXTRA_COMPILE_ARGS@],
    ))

setup(
    name = 'gudhi',
    packages=["gudhi",],
    author='GUDHI Editorial Board',
    author_email='gudhi-contact@lists.gforge.inria.fr',
    version='@GUDHI_VERSION@',
    url='http://gudhi.gforge.inria.fr/',
    ext_modules = ext_modules,
    install_requires = ['cython','numpy >= 1.9','pybind11',],
    setup_requires = ['numpy >= 1.9','pybind11',],
)