setup.py 2.87 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2 3
from distutils.core import setup
from distutils.extension import Extension
from distutils.sysconfig import get_config_vars
4
import pybind11
5
import pkgconfig
Matthieu Dorier's avatar
Matthieu Dorier committed
6 7 8 9
import os
import os.path
import sys

10 11 12 13
def get_pybind11_include():
    path = os.path.dirname(pybind11.__file__)
    return '/'.join(path.split('/')[0:-4] + ['include'])

Matthieu Dorier's avatar
Matthieu Dorier committed
14 15 16 17
(opt,) = get_config_vars('OPT')
os.environ['OPT'] = " ".join(
		    flag for flag in opt.split() if flag != '-Wstrict-prototypes'
		)
18
# Find out if Numpy is present
Matthieu Dorier's avatar
Matthieu Dorier committed
19 20 21 22 23 24
try:
    import numpy
    has_numpy = 1
except ImportError:
    has_numpy = 0

25 26
# Find out the dependencies using pkgconfig 
# For client...
Matthieu Dorier's avatar
Matthieu Dorier committed
27 28 29 30
bake_client = pkgconfig.parse('bake-client')
client_libraries = bake_client['libraries']
client_library_dirs = bake_client['library_dirs']
client_include_dirs = bake_client['include_dirs']
31
client_include_dirs.append(".")
32
client_include_dirs.append(get_pybind11_include())
33
# For server...
Matthieu Dorier's avatar
Matthieu Dorier committed
34 35 36 37
bake_server = pkgconfig.parse('bake-server')
server_libraries = bake_server['libraries']
server_library_dirs = bake_server['library_dirs']
server_include_dirs = bake_server['include_dirs']
38
server_include_dirs.append(".")
39
server_include_dirs.append(get_pybind11_include())
40
# For target...
Matthieu Dorier's avatar
Matthieu Dorier committed
41 42 43 44
uuid = pkgconfig.parse('uuid')
target_libraries = uuid['libraries'] + bake_client['libraries']
target_library_dirs = uuid['library_dirs'] + bake_client['library_dirs']
target_include_dirs = uuid['include_dirs'] + bake_client['include_dirs']
45
target_include_dirs.append('.')
46
target_include_dirs.append(get_pybind11_include())
47 48
pk = pkgconfig.parse('bake-server')
target_include_dirs.extend(pk['include_dirs'])
Matthieu Dorier's avatar
Matthieu Dorier committed
49

Matthieu Dorier's avatar
Matthieu Dorier committed
50
pybake_server_module = Extension('_pybakeserver', ["pybake/src/server.cpp"],
51 52 53
		           libraries=server_libraries,
                   library_dirs=server_library_dirs,
                   include_dirs=server_include_dirs,
54
                   extra_compile_args=['-std=c++11'],
55
                   depends=["pybake/src/server.cpp"])
Matthieu Dorier's avatar
Matthieu Dorier committed
56 57

pybake_client_module = Extension('_pybakeclient', ["pybake/src/client.cpp"],
58 59 60
		           libraries=client_libraries,
                   library_dirs=client_library_dirs,
                   include_dirs=client_include_dirs,
61
                   extra_compile_args=['-std=c++11'],
62
                   depends=["pybake/src/client.cpp"],
Matthieu Dorier's avatar
Matthieu Dorier committed
63
                   define_macros=[('HAS_NUMPY', has_numpy)])
64 65

pybake_target_module = Extension('_pybaketarget', ["pybake/src/target.cpp"],
66 67 68
                    libraries=target_libraries,
                    library_dirs=target_library_dirs,
                    include_dirs=target_include_dirs,
69
                    extra_compile_args=['-std=c++11'],
70
                    depends=["pybake/src/target.cpp"])
71

Matthieu Dorier's avatar
Matthieu Dorier committed
72
setup(name='pybake',
73
      version='0.2.1',
Matthieu Dorier's avatar
Matthieu Dorier committed
74 75
      author='Matthieu Dorier',
      description="""Python binding for BAKE""",      
76
      ext_modules=[ pybake_server_module, pybake_client_module, pybake_target_module ],
Matthieu Dorier's avatar
Matthieu Dorier committed
77 78
      packages=['pybake']
     )