You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.7 KiB

  1. #!/usr/bin/env python
  2. from setuptools import setup
  3. from distutils.core import Extension
  4. from distutils.command.build_ext import build_ext
  5. import os.path
  6. import platform
  7. from glob import glob
  8. PROJECT_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
  9. # Glob source files for modules
  10. core_sources = glob(os.path.join('src', 'core', '*.cpp'))
  11. expressions_sources = glob(os.path.join('src', 'expressions', '*.cpp'))
  12. logic_sources = glob(os.path.join('src', 'logic', '*.cpp'))
  13. # Configuration shared between external modules follows
  14. # To help along, if storm and/or pybind is not system installed, retrieve from storm distribution
  15. include_dirs = ['.', 'src', 'resources/pybind11/include/']
  16. # Add more include dirs
  17. # TODO handle by cmake
  18. include_dirs.extend(['../build/include/', '../resources/3rdparty/sylvan/src/', '../resources/3rdparty/exprtk/', '../resources/3rdparty/gmm-5.0/include/'])
  19. carl_dir = "/Users/mvolk/develop/carl/src/"
  20. include_dirs.append(carl_dir)
  21. boost_dir = '/usr/local/include/'
  22. include_dirs.append(boost_dir)
  23. cudd_dirs = ['../resources/3rdparty/cudd-3.0.0/cplusplus/', '../resources/3rdparty/cudd-3.0.0/mtr/', '../resources/3rdparty/cudd-3.0.0/cudd/']
  24. include_dirs.extend(cudd_dirs)
  25. log4cplus_dirs = ['../resources/3rdparty/log4cplus-1.1.3-rc1/include/', '../build/resources/3rdparty/log4cplus-1.1.3-rc1/include/']
  26. include_dirs.extend(log4cplus_dirs)
  27. local_storm_path = os.path.join(PROJECT_DIR, '..')
  28. if os.path.exists(local_storm_path):
  29. include_dirs.append(local_storm_path)
  30. # Like includes, also add local path for library, assuming made in 'build'
  31. library_dirs = []
  32. local_storm_lib_path = os.path.join(PROJECT_DIR, '..', 'build/src')
  33. if os.path.exists(local_storm_lib_path):
  34. library_dirs.append(local_storm_lib_path)
  35. libraries = ['storm']
  36. extra_compile_args = ['-std=c++11']
  37. define_macros = []
  38. extra_link_args = []
  39. if platform.system() == 'Darwin':
  40. extra_link_args.append('-Wl,-rpath,'+library_dirs[0])
  41. ext_core = Extension(
  42. name='core',
  43. sources=['src/mod_core.cpp'] + core_sources,
  44. include_dirs=include_dirs,
  45. libraries=libraries,
  46. library_dirs=library_dirs,
  47. extra_compile_args=extra_compile_args,
  48. define_macros=define_macros,
  49. extra_link_args=extra_link_args
  50. )
  51. ext_info = Extension(
  52. name='info.info',
  53. sources=['src/mod_info.cpp'],
  54. include_dirs=include_dirs,
  55. libraries=libraries,
  56. library_dirs=library_dirs,
  57. extra_compile_args=extra_compile_args,
  58. define_macros=define_macros,
  59. extra_link_args=extra_link_args
  60. )
  61. ext_expressions = Extension(
  62. name='expressions.expressions',
  63. sources=['src/mod_expressions.cpp'] + expressions_sources,
  64. include_dirs=include_dirs,
  65. libraries=libraries,
  66. library_dirs=library_dirs,
  67. extra_compile_args=extra_compile_args,
  68. define_macros=define_macros,
  69. extra_link_args=extra_link_args
  70. )
  71. ext_logic = Extension(
  72. name='logic.logic',
  73. sources=['src/mod_logic.cpp'] + logic_sources,
  74. include_dirs=include_dirs,
  75. libraries=libraries,
  76. library_dirs=library_dirs,
  77. extra_compile_args=extra_compile_args,
  78. define_macros=define_macros,
  79. extra_link_args=extra_link_args
  80. )
  81. class stormpy_build_ext(build_ext):
  82. """Extend build_ext to provide CLN toggle option
  83. """
  84. user_options = build_ext.user_options + [
  85. ('use-cln', None,
  86. "use cln numbers instead of gmpxx")
  87. ]
  88. def __init__(self, *args, **kwargs):
  89. build_ext.__init__(self, *args, **kwargs)
  90. def initialize_options (self):
  91. build_ext.initialize_options(self)
  92. self.use_cln = None
  93. def finalize_options(self):
  94. build_ext.finalize_options(self)
  95. if self.use_cln:
  96. self.libraries += ['cln']
  97. if not self.define:
  98. self.define = []
  99. else:
  100. self.define = list(self.define)
  101. self.define += [('STORMPY_USE_CLN', 1)]
  102. else:
  103. self.libraries += ['gmp', 'gmpxx']
  104. if not self.undef:
  105. self.undef = []
  106. self.undef += ['STORMPY_USE_CLN']
  107. if library_dirs:
  108. # Makes local storm library lookup that much easier
  109. self.rpath += library_dirs
  110. setup(name="stormpy",
  111. version="0.9",
  112. author="M. Volk",
  113. author_email="matthias.volk@cs.rwth-aachen.de",
  114. maintainer="S. Junges",
  115. maintainer_email="sebastian.junges@cs.rwth-aachen.de",
  116. url="http://moves.rwth-aachen.de",
  117. description="stormpy - Python Bindings for Storm",
  118. packages=['stormpy', 'stormpy.info', 'stormpy.expressions', 'stormpy.logic'],
  119. package_dir={'':'lib'},
  120. ext_package='stormpy',
  121. ext_modules=[ext_core, ext_info, ext_expressions, ext_logic
  122. ],
  123. cmdclass={
  124. 'build_ext': stormpy_build_ext,
  125. }
  126. )