Browse Source

Use CMake to generate setup.cfg for include and library paths

Former-commit-id: 45f1e210d4
tempestpy_adaptions
hbruintjes 9 years ago
committed by Matthias Volk
parent
commit
697c30e048
  1. 22
      CMakeLists.txt
  2. 3
      stormpy/setup.cfg
  3. 5
      stormpy/setup.cfg.in
  4. 56
      stormpy/setup.py

22
CMakeLists.txt

@ -40,6 +40,7 @@ mark_as_advanced(STORM_COMPILE_WITH_CCACHE)
option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF) option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF)
option(STORM_USE_CLN_NUMBERS "Sets whether CLN or GMP numbers should be used" ON) option(STORM_USE_CLN_NUMBERS "Sets whether CLN or GMP numbers should be used" ON)
option(BUILD_SHARED_LIBS "Build the Storm library dynamically" OFF) option(BUILD_SHARED_LIBS "Build the Storm library dynamically" OFF)
option(CONFIGURE_STORMPY "Generate setup.cfg for stormpy" ON)
set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).") set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).")
set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).") set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).")
set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).") set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).")
@ -335,8 +336,27 @@ set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/storm/utility/storm-versi
include_directories("${PROJECT_BINARY_DIR}/include") include_directories("${PROJECT_BINARY_DIR}/include")
include(CTest) include(CTest)
# Configure python binding setup file
if(CONFIGURE_STORMPY)
if(STORM_HAVE_CLN)
set(STORMPY_USE_CLN 1)
else()
set(STORMPY_USE_CLN 0)
endif()
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_LIBRARY_DIRS "${PROJECT_BINARY_DIR}/src")
set(STORMPY_RPATH "${PROJECT_BINARY_DIR}/src")
configure_file (
"${PROJECT_SOURCE_DIR}/stormpy/setup.cfg.in"
"${PROJECT_SOURCE_DIR}/stormpy/setup.cfg"
)
endif()
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(test)
include(StormCPackConfig.cmake) include(StormCPackConfig.cmake)

3
stormpy/setup.cfg

@ -1,3 +0,0 @@
[build_ext]
use-cln=0
carl_src=../../carl/src/

5
stormpy/setup.cfg.in

@ -0,0 +1,5 @@
[build_ext]
use-cln=@STORMPY_USE_CLN@
include_dirs=@STORMPY_INCLUDE_DIRS@
library_dirs=@STORMPY_LIBRARY_DIRS@
rpath=@STORMPY_RPATH@

56
stormpy/setup.py

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from setuptools import setup from setuptools import setup
from distutils.core import Extension from distutils.core import Extension
from distutils.command.build_ext import build_ext
from distutils.command.build_ext import build_ext as orig_build_ext
import os.path import os.path
import platform import platform
from glob import glob from glob import glob
@ -15,36 +15,13 @@ logic_sources = glob(os.path.join('src', 'logic', '*.cpp'))
storage_sources = glob(os.path.join('src', 'storage', '*.cpp')) storage_sources = glob(os.path.join('src', 'storage', '*.cpp'))
# Configuration shared between external modules follows # Configuration shared between external modules follows
# To help along, if storm and/or pybind is not system installed, retrieve from storm distribution
include_dirs = ['.', 'src', 'resources/pybind11/include/']
# Add more include dirs
# TODO handle by cmake
include_dirs.extend(['../build/include/', '../resources/3rdparty/sylvan/src/', '../resources/3rdparty/exprtk/', '../resources/3rdparty/gmm-5.0/include/'])
boost_dir = '/usr/local/include/'
include_dirs.append(boost_dir)
cudd_dirs = ['../resources/3rdparty/cudd-3.0.0/cplusplus/', '../resources/3rdparty/cudd-3.0.0/mtr/', '../resources/3rdparty/cudd-3.0.0/cudd/']
include_dirs.extend(cudd_dirs)
log4cplus_dirs = ['../resources/3rdparty/log4cplus-1.1.3-rc1/include/', '../build/resources/3rdparty/log4cplus-1.1.3-rc1/include/']
include_dirs.extend(log4cplus_dirs)
local_storm_path = os.path.join(PROJECT_DIR, '..')
if os.path.exists(local_storm_path):
include_dirs.append(local_storm_path)
# Like includes, also add local path for library, assuming made in 'build'
include_dirs = [PROJECT_DIR, os.path.join(PROJECT_DIR, 'src'),
os.path.join(PROJECT_DIR, 'resources', 'pybind11', 'include')]
library_dirs = [] library_dirs = []
local_storm_lib_path = os.path.join(PROJECT_DIR, '..', 'build/src')
if os.path.exists(local_storm_lib_path):
library_dirs.append(local_storm_lib_path)
libraries = ['storm'] libraries = ['storm']
extra_compile_args = ['-std=c++11'] extra_compile_args = ['-std=c++11']
define_macros = [] define_macros = []
extra_link_args = [] extra_link_args = []
if platform.system() == 'Darwin':
extra_link_args.append('-Wl,-rpath,'+library_dirs[0])
ext_core = Extension( ext_core = Extension(
name='core', name='core',
@ -101,27 +78,22 @@ ext_storage = Extension(
extra_link_args=extra_link_args extra_link_args=extra_link_args
) )
class stormpy_build_ext(build_ext):
class build_ext(orig_build_ext):
"""Extend build_ext to provide CLN toggle option """Extend build_ext to provide CLN toggle option
""" """
user_options = build_ext.user_options + [
user_options = orig_build_ext.user_options + [
('use-cln', None, ('use-cln', None,
"use cln numbers instead of gmpxx"), "use cln numbers instead of gmpxx"),
('carl_src', None,
"path to src directory of CaRL"),
] ]
def __init__(self, *args, **kwargs):
build_ext.__init__(self, *args, **kwargs)
boolean_options = orig_build_ext.boolean_options + ['use-cln']
def initialize_options (self): def initialize_options (self):
build_ext.initialize_options(self)
super(build_ext, self).initialize_options()
self.use_cln = None self.use_cln = None
self.carl_src = None
def finalize_options(self): def finalize_options(self):
build_ext.finalize_options(self)
super(build_ext, self).finalize_options()
if self.use_cln: if self.use_cln:
self.libraries += ['cln'] self.libraries += ['cln']
@ -136,12 +108,14 @@ class stormpy_build_ext(build_ext):
self.undef = [] self.undef = []
self.undef += ['STORMPY_USE_CLN'] self.undef += ['STORMPY_USE_CLN']
if library_dirs:
if self.library_dirs:
# Makes local storm library lookup that much easier # Makes local storm library lookup that much easier
self.rpath += library_dirs
self.rpath += self.library_dirs
print("Add carl_src: {}".format(self.carl_src))
include_dirs.append(self.carl_src)
if platform.system() == 'Darwin' and len(self.rpath) > 0:
for e in self.extensions:
# If rpath is used on OS X, set this option
e.extra_link_args.append('-Wl,-rpath,'+self.rpath[0])
setup(name="stormpy", setup(name="stormpy",
version="0.9", version="0.9",
@ -157,6 +131,6 @@ setup(name="stormpy",
ext_modules=[ext_core, ext_info, ext_expressions, ext_logic, ext_storage ext_modules=[ext_core, ext_info, ext_expressions, ext_logic, ext_storage
], ],
cmdclass={ cmdclass={
'build_ext': stormpy_build_ext,
'build_ext': build_ext,
} }
) )
Loading…
Cancel
Save