Skip to content

Commit

Permalink
refactor R installation
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed Jan 19, 2018
1 parent 2a30079 commit 080ec4a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 37 deletions.
8 changes: 4 additions & 4 deletions examples/meta/generator/targets/r.json
Expand Up @@ -28,12 +28,12 @@
},
"Element": {
"Access": {
"Vector": "$identifier[$indices]",
"Matrix": "$identifier[$indices]"
"Vector": "$identifier$$get_element($indices)",
"Matrix": "$identifier$$get_element($indices)"
},
"Assign": {
"Vector": "$identifier[$indices] = $expr",
"Matrix": "$identifier[$indices] = $expr"
"Vector": "$identifier$$set_element($expr, $indices)",
"Matrix": "$identifier$$set_element($expr, $indices)"
},
"ZeroIndexed": false
},
Expand Down
26 changes: 26 additions & 0 deletions src/interfaces/r/CMakeLists.txt
Expand Up @@ -11,6 +11,28 @@ ENDIF()
GENERATE_INTERFACE_TARGET(r ${CMAKE_CURRENT_SOURCE_DIR} ${R_LIBRARIES})
set_target_properties(interface_r PROPERTIES PREFIX "")

EXECUTE_PROCESS(COMMAND ${R_EXECUTABLE} --slave -e "with(R.version, cat(sprintf('%s.%s', major, minor)))"
OUTPUT_VARIABLE R_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

EXECUTE_PROCESS(COMMAND ${R_EXECUTABLE} --slave -e "cat(R.version\$platform)"
OUTPUT_VARIABLE PLATFORM
OUTPUT_STRIP_TRAILING_WHITESPACE
)

EXECUTE_PROCESS(COMMAND ${R_EXECUTABLE} --slave -e "cat(.Platform\$OS.type)"
OUTPUT_VARIABLE OSTYPE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from time import gmtime, strftime; print(strftime(\"%Y-%m-%d %H:%M:%S\", gmtime()))"
OUTPUT_VARIABLE DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/DESCRIPTION.in ${CMAKE_CURRENT_BINARY_DIR}/DESCRIPTION @ONLY)

ADD_CUSTOM_COMMAND(TARGET interface_r
POST_BUILD
COMMAND echo 'wd="${CMAKE_CURRENT_BINARY_DIR}" \; setwd( wd ) \; f="shogun.R" \; fdata="shogun.RData" \; source( f ) \; save( list=ls( all=TRUE ) , file=fdata , compress=TRUE ) \; q( save="no" ) \;' | ${R_EXECUTABLE} --silent --no-save
Expand All @@ -26,6 +48,10 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/shogun.RData
DESTINATION ${R_COMPONENT_LIB_PATH}/shogun/R
COMPONENT r)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DESCRIPTION ${CMAKE_CURRENT_SOURCE_DIR}/NAMESPACE
DESTINATION ${R_COMPONENT_LIB_PATH}/shogun
COMPONENT r)

install(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${R_COMPONENT_LIB_PATH}/shogun/Meta)")

install(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/r-install.sh \$ENV{DESTDIR}/${R_COMPONENT_LIB_PATH} shogun so saveRDS WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
26 changes: 26 additions & 0 deletions src/interfaces/r/DESCRIPTION.in
@@ -0,0 +1,26 @@
Package: shogun
Version: @VERSION@
Date: @DATE@
Title: The SHOGUN Machine Learning Toolbox
Author: Shogun Team
Maintainer: Shogun Team <shogun-team@shogun-toolbox.org>
Depends: R (>= 2.10.0)
Suggests:
Description: SHOGUN - is a new machine learning toolbox with focus on large
scale kernel methods and especially on Support Vector Machines (SVM) with focus
to bioinformatics. It provides a generic SVM object interfacing to several
different SVM implementations. Each of the SVMs can be combined with a variety
of the many kernels implemented. It can deal with weighted linear combination
of a number of sub-kernels, each of which not necessarily working on the same
domain, where an optimal sub-kernel weighting can be learned using Multiple
Kernel Learning. Apart from SVM 2-class classification and regression
problems, a number of linear methods like Linear Discriminant Analysis (LDA),
Linear Programming Machine (LPM), (Kernel) Perceptrons and also algorithms to
train hidden markov models are implemented. The input feature-objects can be
dense, sparse or strings and of type int/short/double/char and can be converted
into different feature types. Chains of preprocessors (e.g. substracting the
mean) can be attached to each feature object allowing for on-the-fly
pre-processing.
License: GPL Version 3 or later.
URL: http://www.shogun-toolbox.org
Built: @R_VERSION@; @PLATFORM@; @OSTYPE@;
1 change: 1 addition & 0 deletions src/interfaces/r/NAMESPACE
@@ -0,0 +1 @@
useDynLib(shogun, .registration = TRUE)
33 changes: 0 additions & 33 deletions src/interfaces/r/r-install.sh
Expand Up @@ -9,35 +9,6 @@ DATE="`date '+%Y-%m-%d %H:%M:%S'`"
PKGFILE="$1/$2/Meta/package.rds"
SAVERDS="$4"

cat >"$1/$2/DESCRIPTION" <<EOF
Package: $2
Version: $VERSION
Date: $DATE
Title: The SHOGUN Machine Learning Toolbox
Author: Shogun Team
Maintainer: Shogun Team <shogun-team@shogun-toolbox.org>
Depends: R (>= 2.10.0)
Suggests:
Description: SHOGUN - is a new machine learning toolbox with focus on large
scale kernel methods and especially on Support Vector Machines (SVM) with focus
to bioinformatics. It provides a generic SVM object interfacing to several
different SVM implementations. Each of the SVMs can be combined with a variety
of the many kernels implemented. It can deal with weighted linear combination
of a number of sub-kernels, each of which not necessarily working on the same
domain, where an optimal sub-kernel weighting can be learned using Multiple
Kernel Learning. Apart from SVM 2-class classification and regression
problems, a number of linear methods like Linear Discriminant Analysis (LDA),
Linear Programming Machine (LPM), (Kernel) Perceptrons and also algorithms to
train hidden markov models are implemented. The input feature-objects can be
dense, sparse or strings and of type int/short/double/char and can be converted
into different feature types. Chains of preprocessors (e.g. substracting the
mean) can be attached to each feature object allowing for on-the-fly
pre-processing.
License: GPL Version 3 or later.
URL: http://www.shogun-toolbox.org
Built: $RVERSION; $PLATFORM; $OSTYPE;
EOF

echo "x=structure(list(DESCRIPTION = c(Package='$2',\
Version=\"$VERSION\",\
Date=\"$DATE\",\
Expand All @@ -58,10 +29,6 @@ echo "x=structure(list(DESCRIPTION = c(Package='$2',\
# R-MODULAR
echo "Installing modular shogun interface for R"

cat >"$1/$2/NAMESPACE" <<EOF
useDynLib(shogun, .registration = TRUE)
EOF

cat >"$1/$2/R/$2" <<EOF
.packageName <- "$2"
#$2 <- function(...) .External("$2",...,PACKAGE="$2")
Expand Down

0 comments on commit 080ec4a

Please sign in to comment.