-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup: use scikit-build for building cmatrices and cshape C extensions
See #283 This commit introduces new dependencies: "scikit-built" and "cmake". scikit-build is a drop-in replacement to setuptools.setup function allowing to easily compile and package extensions (C/C++/Cython) by bridging CMake and setuptools. See http://scikit-build.org CMake is is an open-source, cross-platform family of tools designed to build, test and package software. See https://cmake.org Currently, scikit-build and cmake have to be explicitly (see [1]) installed on the system. This could be done by simply doing: pip install -U scikit-build cmake How does it work ? ------------------ In addition to simplifying setup.py, two new file have been added: <root> | |---- CMakeLists.txt (1) . . . |--- ...src | |--- CMakeLists.txt (2) . . The first CMakeLists.txt specifies requirements for * Python interpreter, * the associated python libraries * and a "PythonExtension" modules containing convenience CMake functions allowing to easily build extension by encapsulating system introspection and platform specific logic. and include the subdirectory associated with the other CMakeLists.txt. The second CMakeLists.txt is specific to "cmatrices" and "cshape" extensions and it specifies: * requirement for NumPy Then, it declares: * libraries for each extension, associate python extension specific properties * and finally add an install rule specifying where in the package hierarchy the extension should be installed. Et voila, [1] Note that improvement to python packaging will be available shortly and it will be possible to include scikit-build and cmake directly in pyproject.toml See here for more details: https://www.python.org/dev/peps/pep-0518/
- Loading branch information
Showing
5 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,7 @@ docs/_build/ | |
|
||
# PyBuilder | ||
target/ | ||
|
||
# scikit-build | ||
_skbuild | ||
MANIFEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.7) | ||
|
||
project(radiomics) | ||
|
||
find_package(PythonInterp REQUIRED) | ||
find_package(PythonLibs REQUIRED) | ||
find_package(PythonExtensions REQUIRED) | ||
|
||
add_subdirectory(radiomics/src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
find_package(NumPy REQUIRED) | ||
|
||
add_library(_cmatrices MODULE _cmatrices.c cmatrices.c) | ||
python_extension_module(_cmatrices) | ||
target_include_directories(_cmatrices PRIVATE ${NumPy_INCLUDE_DIR}) | ||
|
||
add_library(_cshape MODULE _cshape.c cshape.c) | ||
python_extension_module(_cshape) | ||
target_include_directories(_cshape PRIVATE ${NumPy_INCLUDE_DIR}) | ||
|
||
install(TARGETS _cmatrices _cshape LIBRARY DESTINATION radiomics) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters