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.

133 lines
4.0 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. local_storm_path = os.path.join(PROJECT_DIR, '..')
  17. if os.path.exists(local_storm_path):
  18. include_dirs.append(local_storm_path)
  19. # Like includes, also add local path for library, assuming made in 'build'
  20. library_dirs = []
  21. local_storm_lib_path = os.path.join(PROJECT_DIR, '..', 'build/src')
  22. if os.path.exists(local_storm_lib_path):
  23. library_dirs.append(local_storm_lib_path)
  24. libraries = ['storm']
  25. extra_compile_args = ['-std=c++11']
  26. define_macros = []
  27. extra_link_args = []
  28. if platform.system() == 'Darwin':
  29. extra_link_args.append('-Wl,-rpath,'+library_dirs[0])
  30. ext_core = Extension(
  31. name='core',
  32. sources=['src/mod_core.cpp'] + core_sources,
  33. include_dirs=include_dirs,
  34. libraries=libraries,
  35. library_dirs=library_dirs,
  36. extra_compile_args=extra_compile_args,
  37. define_macros=define_macros,
  38. extra_link_args=extra_link_args
  39. )
  40. ext_info = Extension(
  41. name='info.info',
  42. sources=['src/mod_info.cpp'],
  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_expressions = Extension(
  51. name='expressions.expressions',
  52. sources=['src/mod_expressions.cpp'] + expressions_sources,
  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_logic = Extension(
  61. name='logic.logic',
  62. sources=['src/mod_logic.cpp'] + logic_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. class stormpy_build_ext(build_ext):
  71. """Extend build_ext to provide CLN toggle option
  72. """
  73. user_options = build_ext.user_options + [
  74. ('use-cln', None,
  75. "use cln numbers instead of gmpxx")
  76. ]
  77. def __init__(self, *args, **kwargs):
  78. build_ext.__init__(self, *args, **kwargs)
  79. def initialize_options (self):
  80. build_ext.initialize_options(self)
  81. self.use_cln = None
  82. def finalize_options(self):
  83. build_ext.finalize_options(self)
  84. if self.use_cln:
  85. self.libraries += ['cln']
  86. if not self.define:
  87. self.define = []
  88. else:
  89. self.define = list(self.define)
  90. self.define += [('STORMPY_USE_CLN', 1)]
  91. else:
  92. self.libraries += ['gmp', 'gmpxx']
  93. if not self.undef:
  94. self.undef = []
  95. self.undef += ['STORMPY_USE_CLN']
  96. if library_dirs:
  97. # Makes local storm library lookup that much easier
  98. self.rpath += library_dirs
  99. setup(name="stormpy",
  100. version="0.9",
  101. author="M. Volk",
  102. author_email="matthias.volk@cs.rwth-aachen.de",
  103. maintainer="S. Junges",
  104. maintainer_email="sebastian.junges@cs.rwth-aachen.de",
  105. url="http://moves.rwth-aachen.de",
  106. description="stormpy - Python Bindings for Storm",
  107. packages=['stormpy', 'stormpy.info', 'stormpy.expressions', 'stormpy.logic'],
  108. package_dir={'':'lib'},
  109. ext_package='stormpy',
  110. ext_modules=[ext_core, ext_info, ext_expressions, ext_logic
  111. ],
  112. cmdclass={
  113. 'build_ext': stormpy_build_ext,
  114. }
  115. )