Skip to content

Commit

Permalink
Use CMake as primary build system via scikit-build (#215)
Browse files Browse the repository at this point in the history
* general except clause in module_available
* switched to scikit-build as build system
* update versioneer
* remove legacy dependency specifiers from setup.py
* use pytest xdist with 2 jobs
  • Loading branch information
clonker authored Mar 3, 2022
1 parent 0898081 commit b3efe88
Show file tree
Hide file tree
Showing 53 changed files with 834 additions and 614 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
build
_skbuild
*.so
*.egg-info
cmake-build-*
Expand Down
47 changes: 38 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.15...3.19)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(DEEPTIME_VERSION "0.0.0" CACHE STRING "The version without commit offset. Defaults to 0.0.0")
set(DEEPTIME_VERSION_INFO "0.0.0" CACHE STRING "The full version. Defaults to 0.0.0")
set(DEEPTIME_BUILD_CPP_TESTS OFF CACHE BOOL "Whether to build the c++ unit tests")

if(DEFINED PROJECT_NAME)
set(DEEPTIME_IS_SUBPROJECT ON)
endif()
project(deeptime LANGUAGES C CXX VERSION 0.0.0)
project(deeptime LANGUAGES C CXX VERSION ${DEEPTIME_VERSION})
set(DEEPTIME_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")

if(SKBUILD)
# Scikit-Build does not add your site-packages to the search path
# automatically, so we need to add it _or_ the pybind11 specific directory
# here.
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
endif()

find_package(OpenMP 4)
if(OpenMP_FOUND)
Expand All @@ -18,19 +34,32 @@ if(MSVC)
add_compile_options(/W3 /EHsc /bigobj /permissive- /std:c++17)
endif()

find_package(pybind11 REQUIRED)
# use cmake 3.12+ FindPython
# find_package(Python COMPONENTS Interpreter Development) # this doesn't work with conda, picks up the wrong python interpreter on OSX
# now find pybind
find_package(pybind11 REQUIRED CONFIG)

function(register_pybind_module name)
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "")
pybind11_add_module(${name} ${ARG_UNPARSED_ARGUMENTS})
target_link_libraries(${name} PUBLIC deeptime::deeptime)
if (OpenMP_FOUND)
target_link_libraries(${name} PUBLIC OpenMP::OpenMP_CXX)
endif()
file(RELATIVE_PATH REL_PATH "${DEEPTIME_ROOT_DIRECTORY}/deeptime" "${CMAKE_CURRENT_LIST_DIR}")
install(TARGETS ${name} DESTINATION ${REL_PATH})
if(NOT SKBUILD)
set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif()
endfunction()

add_subdirectory(deeptime/src)
add_subdirectory(deeptime/numeric/_bindings)
add_subdirectory(deeptime/numeric)
add_subdirectory(deeptime/data)
add_subdirectory(deeptime/covariance/util/covar_c)
add_subdirectory(deeptime/clustering)
add_subdirectory(deeptime/basis)
add_subdirectory(deeptime/markov/_bindings)
add_subdirectory(deeptime/markov/hmm/_bindings)
add_subdirectory(deeptime/markov/msm/tram/_bindings)
add_subdirectory(deeptime/markov/tools/estimation/dense/_bindings)
add_subdirectory(deeptime/markov/tools/estimation/sparse/_bindings)
add_subdirectory(deeptime/markov)

add_subdirectory(examples/clustering_custom_metric)

Expand Down
1 change: 0 additions & 1 deletion deeptime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ._version import get_versions

__version__ = get_versions()['version']
del get_versions

Expand Down
Loading

0 comments on commit b3efe88

Please sign in to comment.