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.

85 lines
3.2 KiB

  1. from setuptools import setup, find_packages
  2. from setuptools.command.install import install
  3. from setuptools.command.develop import develop
  4. from setuptools.command.egg_info import egg_info
  5. from subprocess import call, STDOUT
  6. import distutils.sysconfig
  7. import os
  8. import os.path
  9. import tempfile
  10. import glob
  11. import shutil
  12. import distutils
  13. import multiprocessing
  14. print(os.getcwd())
  15. PYTHONINC = distutils.sysconfig.get_python_inc()
  16. PYTHONLIB = distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=True)
  17. PYTHONLIBDIR = distutils.sysconfig.get_config_var("LIBDIR")
  18. PYTHONLIBS = glob.glob(os.path.join(PYTHONLIBDIR, "*.dylib"))
  19. PYTHONLIBS.extend(glob.glob(os.path.join(PYTHONLIBDIR, "*.so")))
  20. PYTHONLIB = PYTHONLIBS[0]
  21. NO_COMPILE_CORES = multiprocessing.cpu_count()
  22. #print(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)))
  23. #print(PYTHONINC)
  24. #print(PYTHONLIB)
  25. d = "setuppy_build"
  26. PROJECT_PYTHON_DIR = "stormpy"
  27. PROJECT_PYTHON_FILES = os.path.join(os.path.dirname(os.path.realpath(__file__)), PROJECT_PYTHON_DIR)
  28. PROJECT_PYTHON_TMP_DESTINATION = os.path.join(os.path.realpath(d), PROJECT_PYTHON_DIR)
  29. print(d)
  30. if not os.path.exists(d):
  31. os.makedirs(d)
  32. class MyEggInfo(egg_info):
  33. def run(self):
  34. try:
  35. src = PROJECT_PYTHON_FILES
  36. print(src)
  37. dst = PROJECT_PYTHON_TMP_DESTINATION
  38. print(dst)
  39. distutils.dir_util.copy_tree(src, dst)
  40. egg_info.run(self)
  41. except:
  42. print("Exception occurred")
  43. egg_info.run(self)
  44. class MyInstall(install):
  45. def run(self):
  46. ret = call(["cmake", "-DSTORM_PYTHON=ON", "-DUSE_BOOST_STATIC_LIBRARIES=OFF", "-DPYTHON_LIBRARY="+PYTHONLIB, "-DPYTHON_INCLUDE_DIR="+PYTHONINC, os.path.abspath(os.path.dirname(os.path.realpath(__file__)))], cwd=d)
  47. if ret != 0:
  48. raise RuntimeError("Cmake exited with return code {}".format(ret))
  49. ret = call(["make", "stormpy", "-j"+str(NO_COMPILE_CORES)], cwd=d)
  50. if ret != 0:
  51. raise RuntimeError("Make exited with return code {}".format(ret))
  52. install.run(self)
  53. class MyDevelop(develop):
  54. def run(self):
  55. ret = call(["cmake", "-DSTORM_PYTHON=ON","-DUSE_BOOST_STATIC_LIBRARIES=OFF", "-DPYTHON_LIBRARY="+PYTHONLIB, "-DPYTHON_INCLUDE_DIR="+PYTHONINC, os.path.abspath(os.path.dirname(os.path.realpath(__file__)))], cwd=d)
  56. if ret != 0:
  57. raise RuntimeError("Cmake exited with return code {}".format(ret))
  58. ret = call(["make", "stormpy", "-j"+str(NO_COMPILE_CORES)], cwd=d)
  59. if ret != 0:
  60. raise RuntimeError("Make exited with return code {}".format(ret))
  61. develop.run(self)
  62. setup(cmdclass={'install': MyInstall, 'develop': MyDevelop, 'egg_info': MyEggInfo},
  63. name="stormpy",
  64. version="0.2",
  65. description="Stormpy - Python Bindings for Storm",
  66. package_dir={'':d},
  67. packages=['stormpy', 'stormpy.core', 'stormpy.info', 'stormpy.logic', 'stormpy.expressions'],
  68. package_data={'stormpy.core': ['_core.so'],
  69. 'stormpy.logic': ['_logic.so'],
  70. 'stormpy.info' : ['_info.so'] ,
  71. 'stormpy.expressions' : ['_expressions.so'],
  72. 'stormpy': ['*.so', '*.dylib', '*.a']},
  73. include_package_data=True)