diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..fb55edf7f --- /dev/null +++ b/setup.py @@ -0,0 +1,72 @@ +from setuptools import setup, find_packages +from setuptools.command.install import install +from setuptools.command.develop import develop +from setuptools.command.egg_info import egg_info +from subprocess import call, STDOUT +import distutils.sysconfig +import os +import os.path +import tempfile +import glob +import shutil +import distutils +print(os.getcwd()) + + +PYTHONINC = distutils.sysconfig.get_python_inc() +PYTHONLIB = distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=True) +PYTHONLIBDIR = distutils.sysconfig.get_config_var("LIBDIR") +PYTHONLIBS = glob.glob(os.path.join(PYTHONLIBDIR, "*.dylib")) +PYTHONLIBS.extend(glob.glob(os.path.join(PYTHONLIBDIR, "*.so"))) +PYTHONLIB = PYTHONLIBS[0] + + +#print(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))) +#print(PYTHONINC) +#print(PYTHONLIB) + +d = "setuppy_build" + +PROJECT_PYTHON_DIR = "stormpy" +PROJECT_PYTHON_FILES = os.path.join(os.path.dirname(os.path.realpath(__file__)), PROJECT_PYTHON_DIR) +PROJECT_PYTHON_TMP_DESTINATION = os.path.join(os.path.realpath(d), PROJECT_PYTHON_DIR) + +print(d) +if not os.path.exists(d): + os.makedirs(d) + +class MyEggInfo(egg_info): + def run(self): + try: + src = PROJECT_PYTHON_FILES + print(src) + dst = PROJECT_PYTHON_TMP_DESTINATION + print(dst) + distutils.dir_util.copy_tree(src, dst) + egg_info.run(self) + except: + print("Exception occurred") + egg_info.run(self) + + +class MyInstall(install): + def run(self): + call(["cmake", "-DSTORM_PYTHON=ON", "-DPYTHON_LIBRARY="+PYTHONLIB, "-DPYTHON_INCLUDE_DIR="+PYTHONINC, os.path.abspath(os.path.dirname(os.path.realpath(__file__)))], cwd=d) + call(["make", "stormpy"], cwd=d) + install.run(self) +class MyDevelop(develop): + def run(self): + call(["cmake", "-DSTORM_PYTHON=ON", "-DPYTHON_LIBRARY="+PYTHONLIB, "-DPYTHON_INCLUDE_DIR="+PYTHONINC, os.path.abspath(os.path.dirname(os.path.realpath(__file__)))], cwd=d) + call(["make", "stormpy"], cwd=d) + develop.run(self) + + +setup(cmdclass={'install': MyInstall, 'develop': MyDevelop, 'egg_info': MyEggInfo}, + name="stormpy", + version="0.2", + description="Stormpy - Python Bindings for Storm", + package_dir={'':d}, + packages=['stormpy', 'stormpy.core', 'stormpy.info'], + package_data={'stormpy.core': ['_core.so'], 'stormpy.info' : ['_info.so'] , 'stormpy': ['*.so', '*.dylib', '*.a']}, + + include_package_data=True) \ No newline at end of file diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 72a1ab63b..0ec2c2e08 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -24,7 +24,5 @@ if(STORM_PYTHON) add_custom_target(stormpy DEPENDS stormpy-info stormpy-core) - add_custom_command(TARGET stormpy PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${STORMPY_SOURCE_DIR} ${STORMPY_OUTPUT_DIR}) + endif() diff --git a/src/python/storm-core.cpp b/src/python/storm-core.cpp index bca8bf57c..5dedac120 100644 --- a/src/python/storm-core.cpp +++ b/src/python/storm-core.cpp @@ -51,7 +51,9 @@ BOOST_PYTHON_MODULE(_core) def("parseProgram", storm::parseProgram); def("buildModelFromPrismProgram", storm::buildSymbolicModel); - - + + + def("exportMatrixFromModel", storm::exportMatrixToFile) + } \ No newline at end of file