1#!/usr/bin/env python
2
3from setuptools import setup, Extension, find_packages
4import numpy as np #needed for numpy include paths
5import glob
6import os
7import sys
8from Cython.Distutils import build_ext
9import Cython
10from distutils.version import StrictVersion
11
12# make sure cython isn't too old
13if StrictVersion(Cython.__version__) < StrictVersion('0.26'):
14    sys.exit("Cython version is too old. Please update using pip install cython --upgrade [--user]")
15
16# setup moab include paths
17moab_root = '${CMAKE_SOURCE_DIR}'
18moab_source_include = moab_root + '/src/moab/'
19moab_other_source_include = moab_root + '/src/'
20moab_binary_include = '${CMAKE_BINARY_DIR}/src/'
21moab_lib_path = '${CMAKE_BINARY_DIR}/lib/'
22pymoab_src_dir = '${CMAKE_CURRENT_BINARY_DIR}/pymoab/'
23include_paths = [moab_source_include,
24                moab_other_source_include,
25                moab_binary_include,
26                 np.get_include(),
27                 pymoab_src_dir]
28
29os.environ["CC"] = "${CMAKE_C_COMPILER}"
30os.environ["CXX"] = "${CMAKE_CXX_COMPILER}"
31
32
33if "--preinstall" in sys.argv:
34    moab_rpath = '${CMAKE_INSTALL_PREFIX}/lib'
35    sys.argv.remove("--preinstall")
36else:
37    moab_rpath = moab_lib_path
38
39# set values for each module
40ext_modules = []
41for f in os.listdir(pymoab_src_dir):
42    if f.endswith(".pyx"):
43        fbase = f.split('.')[0]
44        ext = Extension( "pymoab."+fbase, ["pymoab/"+f,],
45                         language = 'c++',
46                         include_dirs = include_paths,
47                         runtime_library_dirs = [moab_rpath,],
48                         library_dirs = [moab_lib_path,],
49                         libraries = ["MOAB",])
50        ext_modules.append(ext)
51
52# setup pymoab
53setup(
54    name="pymoab",
55    cmdclass = {'build_ext': build_ext},
56    ext_modules=ext_modules,
57    packages=find_packages(),
58    package_data = {'pymoab': ['*.pxd',]},
59    version = '${MOAB_VERSION}',
60    author = "Patrick Shriwise, Guilherme Caminha, Vijay Mahadevan, Iulian Grindeanu, Anthony Scopatz",
61    author_email = "moab-dev@mcs.anl.gov"
62)
63