From a16ae229eb94318be9820a9351d182f9bee113dc Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 May 2023 09:22:12 -0500 Subject: [PATCH 1/4] Add symbolic link --- apis/r/src/libtiledbsoma | 1 + 1 file changed, 1 insertion(+) create mode 120000 apis/r/src/libtiledbsoma diff --git a/apis/r/src/libtiledbsoma b/apis/r/src/libtiledbsoma new file mode 120000 index 0000000000..17b032e837 --- /dev/null +++ b/apis/r/src/libtiledbsoma @@ -0,0 +1 @@ +../../../libtiledbsoma/ \ No newline at end of file From 6101892148a08180c5740fd29e83eb90efc5a215 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 May 2023 15:17:16 -0500 Subject: [PATCH 2/4] Build libtiledbsoma if needed off soft-link / expanded directory R CMD build does the right thing too --- apis/r/.Rbuildignore | 5 +++- apis/r/DESCRIPTION | 2 +- apis/r/cleanup | 6 ++-- apis/r/configure | 25 ++++++++++++++-- apis/r/src/Makevars.in | 9 +++--- apis/r/tools/build_libtiledbsoma.sh | 23 --------------- apis/r/tools/build_libtiledbsoma.sh.in | 28 ++++++++++++++++++ apis/r/tools/check_cmake_and_git.R | 19 ++++++++++++ apis/r/tools/get_tarball.R | 31 ++++++++++++++++++++ apis/r/tools/get_tarballs.R | 40 -------------------------- apis/r/tools/r-ci.sh | 1 + 11 files changed, 113 insertions(+), 76 deletions(-) delete mode 100755 apis/r/tools/build_libtiledbsoma.sh create mode 100644 apis/r/tools/build_libtiledbsoma.sh.in create mode 100644 apis/r/tools/check_cmake_and_git.R create mode 100644 apis/r/tools/get_tarball.R delete mode 100755 apis/r/tools/get_tarballs.R diff --git a/apis/r/.Rbuildignore b/apis/r/.Rbuildignore index 133177a4ef..253261ecb1 100644 --- a/apis/r/.Rbuildignore +++ b/apis/r/.Rbuildignore @@ -17,11 +17,14 @@ # build artifacts with libtiledbsoma src/include -src/libtiledbsoma tiledbsoma/libtiledbsoma.tar.gz.current tiledb.tar.gz tiledbsoma.tar.gz +# subdirectories of soft-linked libtiledbsoma +src/libtiledbsoma/build +src/libtiledbsoma/test + # vscode ^\.vscode$ ^\.devcontainer$ diff --git a/apis/r/DESCRIPTION b/apis/r/DESCRIPTION index 6524a8f082..d80f6613f2 100644 --- a/apis/r/DESCRIPTION +++ b/apis/r/DESCRIPTION @@ -4,7 +4,7 @@ Title: TileDB SOMA Description: Interface for working with 'TileDB'-based Stack of Matrices, Annotated ('SOMA'): an open data model for representing annotated matrices, like those commonly used for single cell data analysis. -Version: 0.0.0.9023 +Version: 0.0.0.9023.1 Authors@R: c( person(given = "Aaron", family = "Wolen", diff --git a/apis/r/cleanup b/apis/r/cleanup index 5de8bba98f..b3f5ff5ccf 100755 --- a/apis/r/cleanup +++ b/apis/r/cleanup @@ -12,6 +12,6 @@ rm -r -f \ src/include/ \ src/lib \ src/cmake_log.txt \ - src/build \ - src/libtiledbsoma \ - src/bin + src/libtiledbsoma/build-lib \ + src/bin \ + tools/build_libtiledbsoma.sh diff --git a/apis/r/configure b/apis/r/configure index 3d14475245..65690c9103 100755 --- a/apis/r/configure +++ b/apis/r/configure @@ -26,11 +26,30 @@ if [ $? -eq 0 ]; then src/Makevars.in > src/Makevars echo "** updated src/Makevars for system library via pkg-config" + + ## we can exit now as we have a working setup, re exit 0 fi fi ## If we are still here `pkg-config` alone did not work. -## So download tiledb (pre-made) and tiledbsoma (source, for now; then build) -## This -${R_HOME}/bin/Rscript tools/get_tarballs.R + +## Download tiledb pre-made +${R_HOME}/bin/Rscript tools/get_tarball.R + +## Check for cmake and git +${R_HOME}/bin/Rscript tools/check_cmake_and_git.R + +## Make libtiledbsoma library using cmake (and an added git dependency) +tools/build_libtiledbsoma.sh + +pkgincl="-I../inst/tiledb/include -I../inst/tiledbsoma/include" +pkglibs="-ltiledb -L../inst/tiledb/lib -ltiledbsoma -L../inst/tiledbsoma/lib" +rpath="-Wl,-rpath,'\$\$ORIGIN/../tiledb/lib' -Wl,-rpath,'\$\$ORIGIN/../tiledbsoma/lib'" +macosver=`${R_HOME}/bin/Rscript -e 'if (Sys.info()["machine"] == "x86_64" && Sys.info()["sysname"] == "Darwin") cat("-mmacosx-version-min=10.14") else cat("")'` + +sed -e "s|@tiledb_include@|$pkgincl |" \ + -e "s|@tiledb_libs@|$pkglibs|" \ + -e "s|@tiledb_rpath@|$rpath|" \ + -e "s|@cxx17_macos@|$macosver|" \ + src/Makevars.in > src/Makevars diff --git a/apis/r/src/Makevars.in b/apis/r/src/Makevars.in index 0958521257..b383d6fff1 100644 --- a/apis/r/src/Makevars.in +++ b/apis/r/src/Makevars.in @@ -4,16 +4,15 @@ CXX_STD = CXX17 PKG_CPPFLAGS = -I. -I../inst/include/ @tiledb_include@ @cxx17_macos@ -Iinclude ## When this becomes a CRAN package we may have to remove this. For now it keeps the noise down -PKG_CXX17FLAGS = -Wno-deprecated-declarations +PKG_CXXFLAGS = -Wno-deprecated-declarations ## We also need the TileDB library PKG_LIBS = @cxx17_macos@ @tiledb_libs@ @tiledb_rpath@ all: $(SHLIB) - # If we are: - # - on macOS aka Darwin which needs this - # - the library is present (implying non-system library use) - # then let us call install_name_tool + # On macOS aka Darwin we call install_name_tool + # Case one: If we had a downloaded TileDB Core artifact, adjust zlib path and add to @rpath + # Case two: If we see the system libraries (on macOS) ensure /usr/local/lib rpath is considered if [ `uname -s` = 'Darwin' ] && [ -f tiledbsoma.so ]; then \ if [ -f ../inst/tiledb/lib/libtiledb.dylib ] ; then \ install_name_tool -change libz.1.dylib @rpath/libz.1.dylib ../inst/tiledb/lib/libtiledb.dylib; \ diff --git a/apis/r/tools/build_libtiledbsoma.sh b/apis/r/tools/build_libtiledbsoma.sh deleted file mode 100755 index e20a11c18c..0000000000 --- a/apis/r/tools/build_libtiledbsoma.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -## This script is invoked from the tarball-getting script `get_tarballs.R` which -## itself is called from `configure`. - -cwd=`pwd` - -## This helps a little -mv inst/tiledbsoma/TileDB-SOMA-* inst/tiledbsoma/TileDB-SOMA - -## Now make build/ and call cmake; make; make install -mkdir inst/tiledbsoma/TileDB-SOMA/libtiledbsoma/build && \ - cd inst/tiledbsoma/TileDB-SOMA/libtiledbsoma/build && \ - cmake -DDOWNLOAD_TILEDB_PREBUILT=ON \ - -DTILEDBSOMA_BUILD_CLI=OFF \ - -DTILEDBSOMA_ENABLE_TESTING=OFF \ - -DOVERRIDE_INSTALL_PREFIX=OFF \ - -DCMAKE_INSTALL_PREFIX=${cwd}/inst/tiledbsoma .. && \ - make && \ - make install-libtiledbsoma && \ - cd - - -rm -rf inst/tiledbsoma/TileDB-SOMA diff --git a/apis/r/tools/build_libtiledbsoma.sh.in b/apis/r/tools/build_libtiledbsoma.sh.in new file mode 100644 index 0000000000..d2ba93029a --- /dev/null +++ b/apis/r/tools/build_libtiledbsoma.sh.in @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ ! -d src/libtiledbsoma ]; then + echo "No 'src/libtiledbsoma' directory. Exiting." + exit 1 +fi + +if [ ! -d src/libtiledbsoma/build-lib ]; then + mkdir src/libtiledbsoma/build-lib +fi + +cwd=`pwd` + +cd src/libtiledbsoma/build-lib + +## The placeholder is filled in by check_cmake_and_git.R +@cmake@ \ + -DDOWNLOAD_TILEDB_PREBUILT=ON \ + -DTILEDBSOMA_BUILD_CLI=OFF \ + -DTILEDBSOMA_ENABLE_TESTING=OFF \ + -DOVERRIDE_INSTALL_PREFIX=OFF \ + -DCMAKE_INSTALL_PREFIX=${cwd}/inst/tiledbsoma .. + +make + +make install-libtiledbsoma + +rm -rf src/libtiledbsoma/build-lib diff --git a/apis/r/tools/check_cmake_and_git.R b/apis/r/tools/check_cmake_and_git.R new file mode 100644 index 0000000000..8307d0d7c7 --- /dev/null +++ b/apis/r/tools/check_cmake_and_git.R @@ -0,0 +1,19 @@ + + +cmake_bin <- Sys.which("cmake") +if (cmake_bin == "" && file.exists("/Applications/CMake.app/Contents/bin/cmake")) + cmake_bin <- "/Applications/CMake.app/Contents/bin/cmake" + +if (cmake_bin == "") { + stop("No 'cmake' binary found", call. = FALSE) +} + +git_bin <- Sys.which("git") +if (git_bin == "") { + stop("No 'git' binary found", call. = FALSE) +} + +lines <- readLines("tools/build_libtiledbsoma.sh.in") +lines <- gsub("@cmake@", cmake_bin, lines) +writeLines(lines, "tools/build_libtiledbsoma.sh") +Sys.chmod("tools/build_libtiledbsoma.sh", mode="0755") diff --git a/apis/r/tools/get_tarball.R b/apis/r/tools/get_tarball.R new file mode 100644 index 0000000000..0ae1aecd22 --- /dev/null +++ b/apis/r/tools/get_tarball.R @@ -0,0 +1,31 @@ +#!/usr/bin/env Rscript + +## version pinning info +tiledb_core_version <- "2.15.2" +tiledb_core_sha1 <- "90f30eb" + +if ( ! dir.exists("inst/") ) { + stop("No 'inst/' directory. Exiting.", call. = FALSE) +} + +makeUrl <- function(arch, ver=tiledb_core_version, sha1=tiledb_core_sha1) { + sprintf("https://github.com/TileDB-Inc/TileDB/releases/download/%s/tiledb-%s-%s-%s.tar.gz", ver, arch, ver, sha1) +} + +isX86 <- Sys.info()["machine"] == "x86_64" +isMac <- Sys.info()["sysname"] == "Darwin" +isLinux <- Sys.info()["sysname"] == "Linux" + +if (isMac && isX86) { + url <- makeUrl("macos-x86_64") +} else if (isMac && !isX86) { + url <- makeUrl("macos-arm64") +} else if (isLinux) { + url <- makeUrl("linux-x86_64") +} else { + stop("Unsupported platform for downloading artifacts. Please have TileDB Core installed locally.") +} + +tarball <- "tiledb.tar.gz" +if (!file.exists(tarball)) download.file(url, tarball, quiet=TRUE) +if (!dir.exists("inst/tiledb")) untar(tarball, exdir="inst/tiledb") diff --git a/apis/r/tools/get_tarballs.R b/apis/r/tools/get_tarballs.R deleted file mode 100755 index 3c2ec45fa2..0000000000 --- a/apis/r/tools/get_tarballs.R +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env Rscript - -isX86 <- Sys.info()["machine"] == "x86_64" -isMac <- Sys.info()['sysname'] == "Darwin" -isLinux <- Sys.info()[["sysname"]] == "Linux" -macosver <- "" - -if (isMac) { - if (isX86) { - url <- "https://github.com/TileDB-Inc/TileDB/releases/download/2.15.2/tiledb-macos-x86_64-2.15.2-90f30eb.tar.gz" - macosver <- "-mmacosx-version-min=10.14" - } else { - url <- "https://github.com/TileDB-Inc/TileDB/releases/download/2.15.2/tiledb-macos-arm64-2.15.2-90f30eb.tar.gz" - } -} else if (isLinux) { - url <- "https://github.com/TileDB-Inc/TileDB/releases/download/2.15.2/tiledb-linux-x86_64-2.15.2-90f30eb.tar.gz" -} else { - stop("Unsupported platform for downloading artifacts. Please have TileDB Core installed locally.") -} - -if (any(Sys.which(c("cmake", "git")) == "")) - stop("The 'cmake' and 'git' commands are required.") - -tarball <- "tiledb.tar.gz" -if (!file.exists(tarball)) download.file(url, tarball, quiet=TRUE) -if (!dir.exists("inst/tiledb")) untar(tarball, exdir="inst/tiledb") - -soma_url <- "https://github.com/single-cell-data/TileDB-SOMA/archive/refs/tags/1.2.3.tar.gz" -soma_tarball <- "tiledbsoma.tar.gz" -if (!file.exists(soma_tarball)) download.file(soma_url, soma_tarball, quiet=TRUE) -if (!dir.exists("inst/tiledbsoma")) untar(soma_tarball, exdir="inst/tiledbsoma") -cat("** building libtiledbsoma\n") -system("tools/build_libtiledbsoma.sh") - -mkvar <- readLines("src/Makevars.in") -mkvar <- gsub("@cxx17_macos@", macosver, mkvar) -mkvar <- gsub("@tiledb_include@", "-I../inst/tiledb/include -I../inst/tiledbsoma/include", mkvar) -mkvar <- gsub("@tiledb_libs@", "-ltiledb -L../inst/tiledb/lib -ltiledbsoma -L../inst/tiledbsoma/lib", mkvar) -mkvar <- gsub("@tiledb_rpath@", "-Wl,-rpath,'$$ORIGIN/../tiledb/lib' -Wl,-rpath,'$$ORIGIN/../tiledbsoma/lib'", mkvar) -writeLines(mkvar, "src/Makevars") diff --git a/apis/r/tools/r-ci.sh b/apis/r/tools/r-ci.sh index 2e31267288..71b2493a7b 100755 --- a/apis/r/tools/r-ci.sh +++ b/apis/r/tools/r-ci.sh @@ -195,6 +195,7 @@ BootstrapLinuxOptions() { # InstallPandoc 'linux/debian/x86_64' #fi if [[ "${USE_BSPM}" != "FALSE" ]]; then + echo "options(bspm.sudo = TRUE)" | sudo tee --append /etc/R/Rprofile.site >/dev/null echo "suppressMessages(bspm::enable())" | sudo tee --append /etc/R/Rprofile.site >/dev/null echo "options(bspm.version.check=FALSE)" | sudo tee --append /etc/R/Rprofile.site >/dev/null fi From b5ff86fff1f6f4965cb86c8d0992539b0c6c97d5 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 May 2023 16:24:53 -0500 Subject: [PATCH 3/4] Correct stray characters in comment [ci skip] --- apis/r/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/r/configure b/apis/r/configure index 65690c9103..2fa8a32b6f 100755 --- a/apis/r/configure +++ b/apis/r/configure @@ -27,7 +27,7 @@ if [ $? -eq 0 ]; then echo "** updated src/Makevars for system library via pkg-config" - ## we can exit now as we have a working setup, re + ## we can exit now as we have a working setup exit 0 fi fi From 5e213153106b7d6bf55e4cdf84f78a1a4ff508f2 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sat, 13 May 2023 07:56:06 -0500 Subject: [PATCH 4/4] Roll micro-version [ci skip] --- apis/r/DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/r/DESCRIPTION b/apis/r/DESCRIPTION index d80f6613f2..1a00a6217b 100644 --- a/apis/r/DESCRIPTION +++ b/apis/r/DESCRIPTION @@ -4,7 +4,7 @@ Title: TileDB SOMA Description: Interface for working with 'TileDB'-based Stack of Matrices, Annotated ('SOMA'): an open data model for representing annotated matrices, like those commonly used for single cell data analysis. -Version: 0.0.0.9023.1 +Version: 0.0.0.9024 Authors@R: c( person(given = "Aaron", family = "Wolen",