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.

82 lines
3.0 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. print(os.getcwd())
  14. PYTHONINC = distutils.sysconfig.get_python_inc()
  15. PYTHONLIB = distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=True)
  16. PYTHONLIBDIR = distutils.sysconfig.get_config_var("LIBDIR")
  17. PYTHONLIBS = glob.glob(os.path.join(PYTHONLIBDIR, "*.dylib"))
  18. PYTHONLIBS.extend(glob.glob(os.path.join(PYTHONLIBDIR, "*.so")))
  19. PYTHONLIB = PYTHONLIBS[0]
  20. #print(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)))
  21. #print(PYTHONINC)
  22. #print(PYTHONLIB)
  23. d = "setuppy_build"
  24. PROJECT_PYTHON_DIR = "stormpy"
  25. PROJECT_PYTHON_FILES = os.path.join(os.path.dirname(os.path.realpath(__file__)), PROJECT_PYTHON_DIR)
  26. PROJECT_PYTHON_TMP_DESTINATION = os.path.join(os.path.realpath(d), PROJECT_PYTHON_DIR)
  27. print(d)
  28. if not os.path.exists(d):
  29. os.makedirs(d)
  30. class MyEggInfo(egg_info):
  31. def run(self):
  32. try:
  33. src = PROJECT_PYTHON_FILES
  34. print(src)
  35. dst = PROJECT_PYTHON_TMP_DESTINATION
  36. print(dst)
  37. distutils.dir_util.copy_tree(src, dst)
  38. egg_info.run(self)
  39. except:
  40. print("Exception occurred")
  41. egg_info.run(self)
  42. class MyInstall(install):
  43. def run(self):
  44. 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)
  45. if ret != 0:
  46. raise RuntimeError("Cmake exited with return code {}".format(ret))
  47. ret = call(["make", "stormpy"], cwd=d)
  48. if ret != 0:
  49. raise RuntimeError("Make exited with return code {}".format(ret))
  50. install.run(self)
  51. class MyDevelop(develop):
  52. def run(self):
  53. 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)
  54. if ret != 0:
  55. raise RuntimeError("Cmake exited with return code {}".format(ret))
  56. ret = call(["make", "stormpy"], cwd=d)
  57. if ret != 0:
  58. raise RuntimeError("Make exited with return code {}".format(ret))
  59. develop.run(self)
  60. setup(cmdclass={'install': MyInstall, 'develop': MyDevelop, 'egg_info': MyEggInfo},
  61. name="stormpy",
  62. version="0.2",
  63. description="Stormpy - Python Bindings for Storm",
  64. package_dir={'':d},
  65. packages=['stormpy', 'stormpy.core', 'stormpy.info', 'stormpy.logic'],
  66. package_data={'stormpy.core': ['_core.so'],
  67. 'stormpy.logic': ['_logic.so'],
  68. 'stormpy.info' : ['_info.so'] ,
  69. 'stormpy': ['*.so', '*.dylib', '*.a']},
  70. include_package_data=True)