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.

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