From 48798ba7e0ce46350fa6a36f5af274a1d43d8395 Mon Sep 17 00:00:00 2001 From: andres Date: Thu, 23 Nov 2023 10:12:35 -0500 Subject: [PATCH 1/3] Eliminates creation of files in $HOME/.cargo --- .Rbuildignore | 1 + src/Makevars | 27 +++++++-------------- src/Makevars.win | 62 ++++++++++++++++-------------------------------- 3 files changed, 30 insertions(+), 60 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index fdc863c..4f76359 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,6 +11,7 @@ ^src/rust/.cargo$ ^src/rust/.vscode$ ^src/rust/vendor$ +^src/rust/target$ ^_pkgdown\.yml$ ^docs$ diff --git a/src/Makevars b/src/Makevars index 1518fd7..04a26ae 100644 --- a/src/Makevars +++ b/src/Makevars @@ -6,35 +6,26 @@ TARGET_DIR = ./rust/target LIBDIR = $(TARGET_DIR)/release STATLIB = $(LIBDIR)/liborbweaver.a PKG_LIBS = -L$(LIBDIR) -lorbweaver +CARGOTMP = ./rust/.cargo/tmp all: C_clean $(SHLIB): $(STATLIB) $(STATLIB): - # vendoring (Note: to avoid NOTE of "Found the following hidden files and - # directories", .cargo needs to be created here) if [ "$(VENDORING)" = "yes" ]; then \ $(TAR) --extract --xz -f ./rust/vendor.tar.xz -C ./rust && \ mkdir -p ./rust/.cargo && \ cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \ - fi - - # In some environments, ~/.cargo/bin might not be included in PATH, so we need - # to set it here to ensure cargo can be invoked. It is appended to PATH and - # therefore is only used if cargo is absent from the user's PATH. - if [ "$(NOT_CRAN)" != "true" ]; then \ - export CARGO_HOME=$(CARGOTMP); \ fi && \ - export PATH="$(PATH):$(HOME)/.cargo/bin" && \ - cd ./rust && \ - cargo build --lib --release \ - $(OFFLINE_OPTION) \ - --jobs 1 - if [ "$(NOT_CRAN)" != "true" ]; then \ - rm -Rf $(CARGOTMP) && \ - rm -Rf $(LIBDIR)/build; \ - fi + export CARGO_HOME=$(CARGOTMP); \ + export PATH="$(PATH):$(HOME)/.cargo/bin" && \ + cd ./rust && \ + cargo build --lib --release \ + $(OFFLINE_OPTION) \ + --jobs 1; \ + rm -Rf $(CARGOTMP) && \ + rm -Rf $(LIBDIR)/build; \ C_clean: rm -Rf $(SHLIB) $(OBJECTS) ./rust/.cargo $(STATLIB) diff --git a/src/Makevars.win b/src/Makevars.win index 3cf05bf..6fb383a 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,61 +1,39 @@ -TARGET = x86_64-pc-windows-gnu - -# Rtools42 doesn't have the linker in the location that cargo expects, so we -# need to overwrite it via configuration. -CARGO_LINKER = x86_64-w64-mingw32.static.posix-gcc.exe - -# TODO -VENDORING = yes OFFLINE_OPTION = --offline +VENDORING = yes + +TARGET = $(subst 64,x86_64,$(subst 32,i686,$(WIN)))-pc-windows-gnu TARGET_DIR = ./rust/target LIBDIR = $(TARGET_DIR)/$(TARGET)/release STATLIB = $(LIBDIR)/liborbweaver.a PKG_LIBS = -L$(LIBDIR) -lorbweaver -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll +CARGOTMP = ./rust/.cargo/tmp +TAR=tar all: C_clean $(SHLIB): $(STATLIB) -$(STATLIB): - mkdir -p $(LIBDIR)/libgcc_mock && touch $(LIBDIR)/libgcc_mock/libgcc_eh.a +CARGOTMP = $(CURDIR)/.cargo - # vendoring (Note: to avoid NOTE of "Found the following hidden files and - # directories", .cargo needs to be created here) +$(STATLIB): + mkdir -p $(TARGET_DIR)/libgcc_mock && \ + touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a && \ if [ "$(VENDORING)" = "yes" ]; then \ $(TAR) --extract --xz -f ./rust/vendor.tar.xz -C ./rust && \ - mkdir -p ./rust/.cargo && \ - cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \ - fi - - mkdir -p $(TARGET_DIR)/libgcc_mock - # `rustc` adds `-lgcc_eh` flags to the compiler, but Rtools' GCC doesn't have - # `libgcc_eh` due to the compilation settings. So, in order to please the - # compiler, we need to add empty `libgcc_eh` to the library search paths. - # - # For more details, please refer to - # https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316 - touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a - - # CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2 - if [ "$(NOT_CRAN)" != "true" ]; then \ - export CARGO_HOME=$(CARGOTMP); \ + mkdir -p ./rust/.cargo && \ + cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \ fi && \ - export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \ - export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \ - cd ./rust && \ - cargo build --target=$(TARGET) --lib --release \ - $(OFFLINE_OPTION) \ - --jobs 1 - if [ "$(NOT_CRAN)" != "true" ]; then \ - rm -Rf $(CARGOTMP) && \ - rm -Rf $(LIBDIR)/build; \ - fi + export CARGO_HOME=$(CARGOTMP); \ + export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \ + export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \ + cd ./rust && \ + cargo build --target=$(TARGET) --lib --release $(OFFLINE_OPTION) --jobs 1; \ + rm -Rf $(CARGOTMP) && \ + rm -Rf $(LIBDIR)/build; \ C_clean: - rm -Rf $(SHLIB) $(OBJECTS) ./rust/.cargo $(STATLIB) + rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) clean: - rm -Rf $(SHLIB) $(OBJECTS) $(STATLIB) ./rust/.cargo ./rust/vendor ./rust/target - -.PHONY: all C_clean clean + rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(TARGET_DIR) From 13e68ea37f94bb4024c1d0ca5bff57d3127dc540 Mon Sep 17 00:00:00 2001 From: andres Date: Thu, 23 Nov 2023 12:06:08 -0500 Subject: [PATCH 2/3] Updates documentation and description --- DESCRIPTION | 10 +++++++++- R/graph.R | 11 ++++++----- man/add_child.Rd | 2 +- man/add_node.Rd | 2 +- man/as_graph.Rd | 2 +- man/as_graph.data.frame.Rd | 2 +- man/clone_graph.Rd | 2 +- man/new_graph.Rd | 3 +++ 8 files changed, 23 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0840507..b2b93da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,15 @@ Authors@R: person(given = "The authors of the dependency Rust crates", role = c("ctb"), comment = "see inst/AUTHORS file for details")) -Description: A set of optimized tools and abstractions for processing graph data structures. +Description: Empower your data analysis with 'orbweaver', an R package + designed for effortless construction and analysis of graph data + structures. With 'orbweaver', you can seamlessly build and manipulate + graph structures, leveraging its high-performance methods for + filtering, joining, and mutating data within the R environment. + Drawing inspiration from the efficiency of the 'data.table' + package, 'orbweaver' ensures that mutations and changes to + the graph are performed in place, streamlining your + workflow for optimal productivity. URL: https://github.com/ixpantia/orbweaver BugReports: https://github.com/ixpantia/orbweaver/issues License: MIT + file LICENSE diff --git a/R/graph.R b/R/graph.R index 5fdd0bb..009a2d8 100644 --- a/R/graph.R +++ b/R/graph.R @@ -4,6 +4,7 @@ #' Initializes a new graph with the given type. #' @param type The type of graph to create. Currently only `acyclic` is #' supported. +#' @return A new graph of the given type. #' @export new_graph <- function(type) { switch( @@ -21,7 +22,7 @@ new_graph <- function(type) { #' @param type The type of graph to convert to. Currently only `acyclic` is #' supported. #' @param ... Additional arguments passed to the method. -#' @return A graph. +#' @return A graph of the given type. #' @export as_graph <- function(x, type, ...) { UseMethod("as_graph") @@ -35,7 +36,7 @@ as_graph <- function(x, type, ...) { #' @param type The type of graph to convert to. Currently only `acyclic` is #' supported. #' @param ... Ignored. -#' @return A graph. +#' @return A graph of the given type. #' @export as_graph.data.frame <- function(x, type, ...) { switch( @@ -55,7 +56,7 @@ as_graph.data.frame <- function(x, type, ...) { #' similar way to the `data.table` package. #' @param graph The graph to add the node to. #' @param node The ID of the node to add. -#' @return The graph. +#' @return A reference to the graph passed in. #' @export add_node <- function(graph, node) { graph$add_node(node) @@ -74,7 +75,7 @@ add_node <- function(graph, node) { #' @param graph The graph to add the child to. #' @param parent The ID of the parent node. #' @param child The ID of the child node. -#' @return The graph. +#' @return A reference to the graph passed in. #' @export add_child <- function(graph, parent, child) { graph$add_child(parent, child) @@ -163,7 +164,7 @@ find_roots <- function(graph) { #' @description #' Creates a copy of the graph. #' @param graph The graph to clone. -#' @return A new graph. +#' @return A new graph that is a copy of the original. #' @export clone_graph <- function(graph) { graph$graph_clone() diff --git a/man/add_child.Rd b/man/add_child.Rd index 7e21b91..0ac55a5 100644 --- a/man/add_child.Rd +++ b/man/add_child.Rd @@ -14,7 +14,7 @@ add_child(graph, parent, child) \item{child}{The ID of the child node.} } \value{ -The graph. +A reference to the graph passed in. } \description{ Adds a child to a node. If the child already exists, nothing happens. diff --git a/man/add_node.Rd b/man/add_node.Rd index f6db765..dfbed1e 100644 --- a/man/add_node.Rd +++ b/man/add_node.Rd @@ -12,7 +12,7 @@ add_node(graph, node) \item{node}{The ID of the node to add.} } \value{ -The graph. +A reference to the graph passed in. } \description{ Adds a node to the graph. If the node already exists, nothing happens. diff --git a/man/as_graph.Rd b/man/as_graph.Rd index 30392b6..ce1b530 100644 --- a/man/as_graph.Rd +++ b/man/as_graph.Rd @@ -15,7 +15,7 @@ supported.} \item{...}{Additional arguments passed to the method.} } \value{ -A graph. +A graph of the given type. } \description{ Attempts to convert the object to a graph. diff --git a/man/as_graph.data.frame.Rd b/man/as_graph.data.frame.Rd index 00209c1..de3cb9e 100644 --- a/man/as_graph.data.frame.Rd +++ b/man/as_graph.data.frame.Rd @@ -15,7 +15,7 @@ supported.} \item{...}{Ignored.} } \value{ -A graph. +A graph of the given type. } \description{ Converts a data.frame to a graph. diff --git a/man/clone_graph.Rd b/man/clone_graph.Rd index 1981266..1aca5ce 100644 --- a/man/clone_graph.Rd +++ b/man/clone_graph.Rd @@ -10,7 +10,7 @@ clone_graph(graph) \item{graph}{The graph to clone.} } \value{ -A new graph. +A new graph that is a copy of the original. } \description{ Creates a copy of the graph. diff --git a/man/new_graph.Rd b/man/new_graph.Rd index 3d3dc66..ecbb19c 100644 --- a/man/new_graph.Rd +++ b/man/new_graph.Rd @@ -10,6 +10,9 @@ new_graph(type) \item{type}{The type of graph to create. Currently only \code{acyclic} is supported.} } +\value{ +A new graph of the given type. +} \description{ Initializes a new graph with the given type. } From 6bb969501a574e5f85c79ccb6fba8c2c7590d243 Mon Sep 17 00:00:00 2001 From: andres Date: Fri, 24 Nov 2023 09:31:42 -0500 Subject: [PATCH 3/3] Adds badges to README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 253cf14..2bb5f69 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # orbweaver + +[![CRAN status](https://www.r-pkg.org/badges/version/orbweaver)](https://cran.r-project.org/package=orbweaver) +[![R-CMD-check](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml/badge.svg)](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml) + + +## Overview + A fast R library for working with Nodes in a graph. This library modifies graphs in place, similar to how [data.table](https://github.com/Rdatatable/data.table) modifies data.frames in place. This allows for fast and memory efficient