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.

142 lines
4.4 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 as orig_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. include_dirs = [PROJECT_DIR, os.path.join(PROJECT_DIR, 'src'),
  16. os.path.join(PROJECT_DIR, 'resources', 'pybind11', 'include')]
  17. libraries = ['storm']
  18. library_dirs = []
  19. extra_compile_args = []
  20. define_macros = []
  21. extra_link_args = []
  22. ext_core = Extension(
  23. name='core',
  24. sources=['src/mod_core.cpp'] + core_sources,
  25. include_dirs=include_dirs,
  26. libraries=libraries,
  27. library_dirs=library_dirs,
  28. extra_compile_args=extra_compile_args,
  29. define_macros=define_macros,
  30. extra_link_args=extra_link_args
  31. )
  32. ext_info = Extension(
  33. name='info.info',
  34. sources=['src/mod_info.cpp'],
  35. include_dirs=include_dirs,
  36. libraries=libraries,
  37. library_dirs=library_dirs,
  38. extra_compile_args=extra_compile_args,
  39. define_macros=define_macros,
  40. extra_link_args=extra_link_args
  41. )
  42. ext_expressions = Extension(
  43. name='expressions.expressions',
  44. sources=['src/mod_expressions.cpp'] + expressions_sources,
  45. include_dirs=include_dirs,
  46. libraries=libraries,
  47. library_dirs=library_dirs,
  48. extra_compile_args=extra_compile_args,
  49. define_macros=define_macros,
  50. extra_link_args=extra_link_args
  51. )
  52. ext_logic = Extension(
  53. name='logic.logic',
  54. sources=['src/mod_logic.cpp'] + logic_sources,
  55. include_dirs=include_dirs,
  56. libraries=libraries,
  57. library_dirs=library_dirs,
  58. extra_compile_args=extra_compile_args,
  59. define_macros=define_macros,
  60. extra_link_args=extra_link_args
  61. )
  62. ext_storage = Extension(
  63. name='storage.storage',
  64. sources=['src/mod_storage.cpp'] + storage_sources,
  65. include_dirs=include_dirs,
  66. libraries=libraries,
  67. library_dirs=library_dirs,
  68. extra_compile_args=extra_compile_args,
  69. define_macros=define_macros,
  70. extra_link_args=extra_link_args
  71. )
  72. class build_ext(orig_build_ext):
  73. """Extend build_ext to provide CLN toggle option
  74. """
  75. user_options = orig_build_ext.user_options + [
  76. ('use-cln', None,
  77. "use cln numbers instead of gmpxx"),
  78. ('compile-flags', None,
  79. "compile flags for C++"),
  80. ]
  81. boolean_options = orig_build_ext.boolean_options + ['use-cln']
  82. def initialize_options (self):
  83. super(build_ext, self).initialize_options()
  84. self.use_cln = None
  85. self.compile_flags = None
  86. def finalize_options(self):
  87. super(build_ext, self).finalize_options()
  88. if self.use_cln:
  89. self.libraries += ['cln']
  90. if not self.define:
  91. self.define = []
  92. else:
  93. self.define = list(self.define)
  94. self.define += [('STORMPY_USE_CLN', 1)]
  95. else:
  96. self.libraries += ['gmp', 'gmpxx']
  97. if not self.undef:
  98. self.undef = []
  99. self.undef += ['STORMPY_USE_CLN']
  100. if self.library_dirs:
  101. # Makes local storm library lookup that much easier
  102. self.rpath += self.library_dirs
  103. if platform.system() == 'Darwin' and len(self.rpath) > 0:
  104. for e in self.extensions:
  105. # If rpath is used on OS X, set this option
  106. e.extra_link_args.append('-Wl,-rpath,'+self.rpath[0])
  107. for e in self.extensions:
  108. e.extra_compile_args += self.compile_flags.split()
  109. setup(name="stormpy",
  110. version="0.9",
  111. author="M. Volk",
  112. author_email="matthias.volk@cs.rwth-aachen.de",
  113. maintainer="S. Junges",
  114. maintainer_email="sebastian.junges@cs.rwth-aachen.de",
  115. url="http://moves.rwth-aachen.de",
  116. description="stormpy - Python Bindings for Storm",
  117. packages=['stormpy', 'stormpy.info', 'stormpy.expressions', 'stormpy.logic', 'stormpy.storage'],
  118. package_dir={'':'lib'},
  119. ext_package='stormpy',
  120. ext_modules=[ext_core, ext_info, ext_expressions, ext_logic, ext_storage
  121. ],
  122. cmdclass={
  123. 'build_ext': build_ext,
  124. }
  125. )