Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup: use scikit-build for building cmatrices and cshape C extensions #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ jobs:
name: Install pyradiomics in Python 2 and 3
command: |
source activate python2
python -m pip install -U cmake
python -m pip install -U scikit-build
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements-dev.txt
python setup.py install
source activate root
python -m pip install -U cmake
python -m pip install -U scikit-build
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements-dev.txt
python setup.py install
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ docs/_build/

# PyBuilder
target/

# scikit-build
_skbuild
MANIFEST
9 changes: 9 additions & 0 deletions CMakeLists.txt
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)
11 changes: 11 additions & 0 deletions radiomics/src/CMakeLists.txt
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)
5 changes: 2 additions & 3 deletions scikit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ install:
commands:
- python --version
- python -m pip install --disable-pip-version-check --upgrade pip
- $<RUN_ENV> pip install wheel>=0.29.0
- $<RUN_ENV> pip install setuptools>=38.6.0
- $<RUN_ENV> pip install numpy>=1.9.2
- $<RUN_ENV> pip install -U scikit-build
- $<RUN_ENV> pip install -U cmake
- $<RUN_ENV> pip install --trusted-host www.itk.org -f https://itk.org/SimpleITKDoxygen/html/PyDownloadPage.html SimpleITK>=0.9.1
- $<RUN_ENV> python -c "import SimpleITK; print('SimpleITK Version:' + SimpleITK.Version_VersionString())"
- $<RUN_ENV> pip install -r requirements.txt
Expand Down
22 changes: 11 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/usr/bin/env python

from distutils import sysconfig
from __future__ import print_function

import platform
import sys

import numpy
from setuptools import Extension, setup
from setuptools.command.test import test as TestCommand
import versioneer

try:
from skbuild import setup
except ImportError:
print('scikit-build is required to build from source.', file=sys.stderr)
print('Please run:', file=sys.stderr)
print('', file=sys.stderr)
print(' python -m pip install scikit-build')
sys.exit(1)

# Check if current PyRadiomics is compatible with current python installation (> 2.6, 64 bits)
if sys.version_info < (2, 6, 0):
raise Exception("pyradiomics > 0.9.7 requires python 2.6 or later")
Expand Down Expand Up @@ -55,13 +63,6 @@ def run_tests(self):
commands = versioneer.get_cmdclass()
commands['test'] = NoseTestCommand

incDirs = [sysconfig.get_python_inc(), numpy.get_include()]

ext = [Extension("radiomics._cmatrices", ["radiomics/src/_cmatrices.c", "radiomics/src/cmatrices.c"],
include_dirs=incDirs),
Extension("radiomics._cshape", ["radiomics/src/_cshape.c", "radiomics/src/cshape.c"],
include_dirs=incDirs)]

setup(
name='pyradiomics',

Expand All @@ -80,7 +81,6 @@ def run_tests(self):
cmdclass=commands,

packages=['radiomics', 'radiomics.scripts'],
ext_modules=ext,
zip_safe=False,
package_data={'radiomics': ['schemas/paramSchema.yaml', 'schemas/schemaFuncs.py']},

Expand Down