Browse Source

fixed destination for extension modules

refactoring
Sebastian Junges 8 years ago
parent
commit
e571266b8b
  1. 54
      CMakeLists.txt
  2. 24
      setup.py

54
CMakeLists.txt

@ -8,57 +8,33 @@ add_subdirectory(resources/pybind11)
file(GLOB_RECURSE STORM_CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/core/*.cpp)
pybind11_add_module(stormpy.core ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_core.cpp ${STORM_CORE_SOURCES})
target_include_directories(stormpy.core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(stormpy.core PRIVATE storm)
pybind11_add_module(core ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_core.cpp ${STORM_CORE_SOURCES})
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(core PRIVATE storm)
file(GLOB_RECURSE STORM_INFO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/info/*.cpp)
pybind11_add_module(stormpy.info ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_info.cpp ${STORM_INFO_SOURCES})
target_include_directories(stormpy.info PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(stormpy.info PRIVATE storm)
pybind11_add_module(info ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_info.cpp ${STORM_INFO_SOURCES})
target_include_directories(info PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(info PRIVATE storm)
file(GLOB_RECURSE STORM_EXPRESSIONS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/expressions/*.cpp)
pybind11_add_module(stormpy.expressions ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_expressions.cpp ${STORM_EXPRESSIONS_SOURCES})
target_include_directories(stormpy.expressions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(stormpy.expressions PRIVATE storm)
pybind11_add_module(expressions ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_expressions.cpp ${STORM_EXPRESSIONS_SOURCES})
target_include_directories(expressions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(expressions PRIVATE storm)
file(GLOB_RECURSE STORM_LOGIC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/logic/*.cpp)
pybind11_add_module(stormpy.logic ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_logic.cpp ${STORM_LOGIC_SOURCES})
target_include_directories(stormpy.logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(stormpy.logic PRIVATE storm)
pybind11_add_module(logic ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_logic.cpp ${STORM_LOGIC_SOURCES})
target_include_directories(logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(logic PRIVATE storm)
file(GLOB_RECURSE STORM_STORAGE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/storage/*.cpp)
pybind11_add_module(stormpy.storage ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_storage.cpp ${STORM_STORAGE_SOURCES})
target_include_directories(stormpy.storage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(stormpy.storage PRIVATE storm)
#set(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy")
#set(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/stormpy")
#
#if(STORM_HAVE_CLN)
# set(STORMPY_USE_CLN 1)
#else()
# set(STORMPY_USE_CLN 0)
#endif()
#
## Set configuration file
#get_directory_property(STORMPY_INCLUDE_DIRS_PROP INCLUDE_DIRECTORIES)
#foreach(arg ${STORMPY_INCLUDE_DIRS_PROP})
# set(STORMPY_INCLUDE_DIRS "${STORMPY_INCLUDE_DIRS}${sep}${arg}")
# set(sep ":")
#endforeach()
#set(STORMPY_COMPILE_ARGS ${CMAKE_CXX_FLAGS})
#set(STORMPY_LIBRARY_DIRS "${PROJECT_BINARY_DIR}/src/storm")
#set(STORMPY_RPATH "${PROJECT_BINARY_DIR}/src/storm")
#configure_file (
# "${PROJECT_SOURCE_DIR}/stormpy/setup.cfg.in"
# "${PROJECT_SOURCE_DIR}/stormpy/setup.cfg"
#)
#
pybind11_add_module(storage ${CMAKE_CURRENT_SOURCE_DIR}/src/mod_storage.cpp ${STORM_STORAGE_SOURCES})
target_include_directories(storage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${storm_INCLUDE_DIR})
target_link_libraries(storage PRIVATE storm)

24
setup.py

@ -11,11 +11,11 @@ from distutils.version import LooseVersion
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
def __init__(self, name, sourcedir='', subdir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
self.subdir = subdir
class CMakeBuild(build_ext):
user_options = build_ext.user_options + [
@ -43,10 +43,10 @@ class CMakeBuild(build_ext):
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + os.path.join(extdir, ext.subdir),
'-DPYTHON_EXECUTABLE=' + sys.executable]
cfg = 'Debug' if self.debug else 'Release'
cfg = 'Release'# if self.debug else 'Release'
build_args = ['--config', cfg]
@ -60,15 +60,9 @@ class CMakeBuild(build_ext):
self.distribution.get_version())
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
try:
subprocess.check_call(['cmake', '--build', '.', '--target', ext.name] + build_args, cwd=self.build_temp)
except subprocess.CalledProcessError as e:
if e.output:
raise RuntimeError("CMake build returned with an error: " + e.output)
print(e.stdout)
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.', '--target', ext.name] + build_args, cwd=self.build_temp)
setup(
name="stormpy",
version="0.9",
@ -81,7 +75,7 @@ setup(
packages=['stormpy', 'stormpy.info', 'stormpy.expressions', 'stormpy.logic', 'stormpy.storage'],
package_dir={'':'lib'},
ext_package='stormpy',
ext_modules=[CMakeExtension('stormpy.core'), CMakeExtension('stormpy.info'),CMakeExtension('stormpy.expressions'), CMakeExtension('stormpy.logic'), CMakeExtension('stormpy.storage')],
ext_modules=[CMakeExtension('core', subdir=''), CMakeExtension('info', subdir='info'),CMakeExtension('expressions', subdir='expressions'), CMakeExtension('logic', subdir='logic'), CMakeExtension('storage', subdir='storage')],
cmdclass=dict(build_ext=CMakeBuild),
zip_safe=False
)
Loading…
Cancel
Save