setup.py 2.5 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 pkgconfig
Matthieu Dorier's avatar
Matthieu Dorier committed
5 6 7 8 9 10 11 12
import os
import os.path
import sys

(opt,) = get_config_vars('OPT')
os.environ['OPT'] = " ".join(
		    flag for flag in opt.split() if flag != '-Wstrict-prototypes'
		)
13
python_version = str(sys.version_info[0])+str(sys.version_info[1])
Matthieu Dorier's avatar
Matthieu Dorier committed
14

15
# Find out if Numpy is present
Matthieu Dorier's avatar
Matthieu Dorier committed
16 17 18 19 20 21
try:
    import numpy
    has_numpy = 1
except ImportError:
    has_numpy = 0

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
# Find out the dependencies using pkgconfig 
# For client...
pk = pkgconfig.parse('bake-client')
client_libraries = pk['libraries']
client_libraries.append('boost_python'+python_version)
if(has_numpy == 1):
    client_libraries.append('boost_numpy'+python_version)
client_library_dirs = pk['library_dirs']
client_include_dirs = pk['include_dirs']
client_include_dirs.append(".")
# For server...
pk = pkgconfig.parse('bake-server')
server_libraries = pk['libraries']
server_libraries.append('boost_python'+python_version)
server_library_dirs = pk['library_dirs']
server_include_dirs = pk['include_dirs']
server_include_dirs.append(".")
# For target...
pk = pkgconfig.parse('uuid')
target_libraries = pk['libraries']
target_library_dirs = pk['library_dirs']
target_include_dirs = pk['include_dirs']
target_include_dirs.append('.')
pk = pkgconfig.parse('bake-server')
target_include_dirs.extend(pk['include_dirs'])
Matthieu Dorier's avatar
Matthieu Dorier committed
47

Matthieu Dorier's avatar
Matthieu Dorier committed
48
pybake_server_module = Extension('_pybakeserver', ["pybake/src/server.cpp"],
49 50 51 52
		           libraries=server_libraries,
                   library_dirs=server_library_dirs,
                   include_dirs=server_include_dirs,
                   depends=["pybake/src/server.cpp"])
Matthieu Dorier's avatar
Matthieu Dorier committed
53 54

pybake_client_module = Extension('_pybakeclient', ["pybake/src/client.cpp"],
55 56 57 58
		           libraries=client_libraries,
                   library_dirs=client_library_dirs,
                   include_dirs=client_include_dirs,
                   depends=["pybake/src/client.cpp"],
Matthieu Dorier's avatar
Matthieu Dorier committed
59
                   define_macros=[('HAS_NUMPY', has_numpy)])
60 61

pybake_target_module = Extension('_pybaketarget', ["pybake/src/target.cpp"],
62 63 64 65
                    libraries=target_libraries,
                    library_dirs=target_library_dirs,
                    include_dirs=target_include_dirs,
                    depends=["pybake/src/target.cpp"])
66

Matthieu Dorier's avatar
Matthieu Dorier committed
67 68 69 70
setup(name='pybake',
      version='0.1',
      author='Matthieu Dorier',
      description="""Python binding for BAKE""",      
71
      ext_modules=[ pybake_server_module, pybake_client_module, pybake_target_module ],
Matthieu Dorier's avatar
Matthieu Dorier committed
72 73
      packages=['pybake']
     )