Skip to content

Commit

Permalink
initial setup.py
Browse files Browse the repository at this point in the history
- depends on SyneRBI/SIRF#161
- fixes (partially) #107
- TODO: alias p(Gadgetron|STIR|Utilities) -> sirf.p*
- perhaps use `setup.py install` not `pip install`?
  - or drop `-e` argument in `pip install`?
  • Loading branch information
casperdcl committed Apr 19, 2018
1 parent 86dfe8b commit ed2c6a1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
31 changes: 25 additions & 6 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,14 @@ if(PYTHONINTERP_FOUND)

set (ENV_PYTHON_CSH "\
if $?PYTHONPATH then \n\
setenv PYTHONPATH ${PYTHON_DEST}:$PYTHONPATH \n\
#setenv PYTHONPATH ${PYTHON_DEST}:$PYTHONPATH \n\
else \n\
setenv PYTHONPATH ${PYTHON_DEST} \n\
#setenv PYTHONPATH ${PYTHON_DEST} \n\
setenv SIRF_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}")

set (ENV_PYTHON_BASH "\
PYTHONPATH=${PYTHON_DEST}:$PYTHONPATH \n\
export PYTHONPATH \n\
SIRF_PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} \n\
export SIRF_PYTHON_EXECUTABLE")
#export PYTHONPATH=${PYTHON_DEST}:$PYTHONPATH \n\
export SIRF_PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")

endif()

Expand All @@ -219,6 +217,27 @@ endif()
configure_file(env_ccppetmr.sh.in ${CCPPETMR_INSTALL}/bin/env_ccppetmr.sh)
configure_file(env_ccppetmr.csh.in ${CCPPETMR_INSTALL}/bin/env_ccppetmr.csh)

if(PYTHONINTERP_FOUND)
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild/setup.py.in")
set(SETUP_PY "${PYTHON_DEST}/setup.py")
set(SETUP_PY_INIT "${PYTHON_DEST}/sirf/__init__.py")
message(STATUS "setup.py: ${SETUP_PY}")

configure_file("${SETUP_PY_IN}" "${SETUP_PY}")

add_custom_command(OUTPUT "${SETUP_PY_INIT}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PYTHON_DEST}/sirf"
COMMAND "${CMAKE_COMMAND}" -E touch "${SETUP_PY_INIT}"
COMMAND "${PYTHON_EXECUTABLE}" setup.py build
DEPENDS "${SETUP_PY_IN}"
WORKING_DIRECTORY "${PYTHON_DEST}")

add_custom_target(pybuild_stir ALL DEPENDS ${SETUP_PY_INIT})

install(CODE "execute_process(COMMAND\n\
\"${PYTHON_EXECUTABLE}\" -m pip install -U -e \"${CCPPETMR_INSTALL}\")")
endif(PYTHONINTERP_FOUND)


# add tests
enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions SuperBuild/External_SIRF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr

message(STATUS "HDF5_ROOT in External_SIRF: " ${HDF5_ROOT})
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${SUPERBUILD_INSTALL_DIR})

ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
GIT_REPOSITORY ${${proj}_URL}
Expand Down Expand Up @@ -87,7 +87,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY=${PYTHON_LIBRARIES}
-DPYTHON_DEST=${PYTHON_DEST}
-DPYTHON_DEST=${PYTHON_DEST}/sirf
INSTALL_DIR ${SIRF_Install_Dir}
DEPENDS
${${proj}_DEPENDENCIES}
Expand Down
39 changes: 39 additions & 0 deletions SuperBuild/setup.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
from setuptools import setup
except ImportError:
from distutils.core import setup

__author__ = "Casper da Costa-Luis <[email protected]>"
__version__ = "1.0.0"


setup(
name='sirf',
version=__version__,
description='CCP PET-MR SIRF',
license='Apache 2.0',
author='CCP PET-MR',
author_email='[email protected]',
url='https://github.com/CCPPETMR/SIRF',
platforms=['any'],
packages=['sirf'],
long_description='',
classifiers=[
# Trove classifiers
# (https://pypi.python.org/pypi?%3Aaction=list_classifiers)
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
keywords='image reconstruction pet mr medical imaging',
)

0 comments on commit ed2c6a1

Please sign in to comment.