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.

136 lines
4.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 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. library_dirs = []
  18. libraries = ['storm']
  19. extra_compile_args = ['-std=c++11']
  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. ]
  79. boolean_options = orig_build_ext.boolean_options + ['use-cln']
  80. def initialize_options (self):
  81. super(build_ext, self).initialize_options()
  82. self.use_cln = None
  83. def finalize_options(self):
  84. super(build_ext, self).finalize_options()
  85. if self.use_cln:
  86. self.libraries += ['cln']
  87. if not self.define:
  88. self.define = []
  89. else:
  90. self.define = list(self.define)
  91. self.define += [('STORMPY_USE_CLN', 1)]
  92. else:
  93. self.libraries += ['gmp', 'gmpxx']
  94. if not self.undef:
  95. self.undef = []
  96. self.undef += ['STORMPY_USE_CLN']
  97. if self.library_dirs:
  98. # Makes local storm library lookup that much easier
  99. self.rpath += self.library_dirs
  100. if platform.system() == 'Darwin' and len(self.rpath) > 0:
  101. for e in self.extensions:
  102. # If rpath is used on OS X, set this option
  103. e.extra_link_args.append('-Wl,-rpath,'+self.rpath[0])
  104. setup(name="stormpy",
  105. version="0.9",
  106. author="M. Volk",
  107. author_email="matthias.volk@cs.rwth-aachen.de",
  108. maintainer="S. Junges",
  109. maintainer_email="sebastian.junges@cs.rwth-aachen.de",
  110. url="http://moves.rwth-aachen.de",
  111. description="stormpy - Python Bindings for Storm",
  112. packages=['stormpy', 'stormpy.info', 'stormpy.expressions', 'stormpy.logic', 'stormpy.storage'],
  113. package_dir={'':'lib'},
  114. ext_package='stormpy',
  115. ext_modules=[ext_core, ext_info, ext_expressions, ext_logic, ext_storage
  116. ],
  117. cmdclass={
  118. 'build_ext': build_ext,
  119. }
  120. )