Skip to content

Commit

Permalink
Adding shortcut to change the name of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Oct 17, 2023
1 parent 4c912a4 commit f799249
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 374 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: epiworldRfaster
Package: epiworldRdev
Type: Package
Title: Fast Agent-Based Epi Models
Version: 0.0-3.9000
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ docker-debug:
EPI_CONFIG="-DEPI_DEBUG -Wall -pedantic -g" R CMD INSTALL \
--no-docs --build .

install: build
which R
cd ../ && R CMD INSTALL epiworldR_*.tar.gz
install-dev: clean
sed -i -E 's/^Package:.+/Package: epiworldRdev/g' DESCRIPTION
sed -i -E 's/^library\([a-zA-Z]+\)/library(epiworldRdev)/g' README.*
EPI_DEV=yes R CMD INSTALL .

install: clean
sed -i -E 's/^Package:.+/Package: epiworldR/g' DESCRIPTION
sed -i -E 's/^library\([a-zA-Z]+\)/library(epiworldR)/g' README.*
R CMD INSTALL .


README.md: README.Rmd
Rscript --vanilla -e 'rmarkdown::render("README.Rmd")'
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ importFrom(stats,aggregate)
importFrom(stats,quantile)
importFrom(stats,sd)
importFrom(utils,read.table)
useDynLib(epiworldRfaster, .registration = TRUE)
useDynLib(epiworldRdev, .registration = TRUE)
214 changes: 107 additions & 107 deletions R/cpp11.R

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions R/epiworldR-package.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' epiworldRfaster
#' @useDynLib epiworldRfaster, .registration = TRUE
#' epiworldRdev
#' @useDynLib epiworldRdev, .registration = TRUE
#' @importFrom graphics boxplot plot
"_PACKAGE"

5 changes: 5 additions & 0 deletions R/epiworldR-package.R.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#' @EPIWORLD_NAME@
#' @useDynLib @EPIWORLD_NAME@, .registration = TRUE
#' @importFrom graphics boxplot plot
"_PACKAGE"

6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This R package includes several popular epidemiological models including
This Susceptible-Infected-Recovered model features a population of 100,000 agents simulated in a small-world network. Each agent is connected to ten other agents. One percent of the population has the virus, with a 70% chance of transmission. Infected individuals recover at a 0.3 rate:

```{r example}
library(epiworldRfaster)
library(epiworldRdev)
# Creating a SIR model
sir <- ModelSIR(
Expand Down Expand Up @@ -204,8 +204,8 @@ sir <- ModelSIR(
net <- get_transmissions(sir)
# Plotting
library(netplot)
library(igraph)
library(epiworldRdev)
library(epiworldRdev)
x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1)
nplot(x, edge.curvature = 0, edge.color = "gray", skip.vertex=TRUE)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ virus, with a 70% chance of transmission. Infected individuals recover
at a 0.3 rate:

``` r
library(epiworldRfaster)
library(epiworldRdev)

# Creating a SIR model
sir <- ModelSIR(
Expand Down Expand Up @@ -345,9 +345,9 @@ sir <- ModelSIR(
net <- get_transmissions(sir)

# Plotting
library(netplot)
library(epiworldRdev)
#> Loading required package: grid
library(igraph)
library(epiworldRdev)
#>
#> Attaching package: 'igraph'
#> The following object is masked from 'package:netplot':
Expand Down
28 changes: 27 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ PACKAGE_URL=''

ac_subst_vars='LTLIBOBJS
LIBOBJS
EPIWORLD_NAME
OPENMP_FLAG
CXXCPP
OBJEXT
Expand Down Expand Up @@ -3365,11 +3366,29 @@ printf "%s\n" "found and suitable" >&6; }
fi
fi
# Checking if the development version is being built
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build the dev version" >&5
printf %s "checking whether to build the dev version... " >&6; }
epiworldname="epiworldR"
if test x"${EPI_DEV}" != x"" ; then
epiworldname="epiworldRdev"
fi
## now use all these
OPENMP_FLAG="${openmp_flag}"
ac_config_files="$ac_config_files src/Makevars"
EPIWORLD_NAME="${epiworldname}"
ac_config_files="$ac_config_files src/Makevars R/epiworldR-package.R"
# Use sed to replace the line useDynLib\([a-zA-Z]+ in the NAMESPACE
# file with useDynLib(${epiworldname}
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -4072,6 +4091,7 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;;
"R/epiworldR-package.R") CONFIG_FILES="$CONFIG_FILES R/epiworldR-package.R" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
Expand Down Expand Up @@ -4495,6 +4515,12 @@ ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
sed -i -E 's/^useDynLib\([a-zA-Z]+/useDynLib('"${epiworldname}"'/g' NAMESPACE
sed -i -E 's/^Package:.+/Package: '"${epiworldname}"'/g' DESCRIPTION
sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{'"${epiworldname}"'/g' man/epiworldRfaster-package.Rd
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
Expand Down
24 changes: 23 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,30 @@ if test x"${can_use_openmp}" = x"yes"; then
fi
fi

# Checking if the development version is being built
AC_MSG_CHECKING([whether to build the dev version])
epiworldname="epiworldR"
if test x"${EPI_DEV}" != x"" ; then
epiworldname="epiworldRdev"
fi

## now use all these
AC_SUBST([OPENMP_FLAG], ["${openmp_flag}"])
AC_CONFIG_FILES([src/Makevars])
AC_SUBST([EPIWORLD_NAME], ["${epiworldname}"])
AC_CONFIG_FILES([src/Makevars R/epiworldR-package.R])

# Use sed to replace the line useDynLib\([a-zA-Z]+ in the NAMESPACE
# file with useDynLib(${epiworldname}
AC_CONFIG_COMMANDS_POST(
[sed -i -E 's/^useDynLib\([[a-zA-Z]]+/useDynLib('"${epiworldname}"'/g' NAMESPACE]
)

AC_CONFIG_COMMANDS_POST(
[sed -i -E 's/^Package:.+/Package: '"${epiworldname}"'/g' DESCRIPTION]
)

AC_CONFIG_COMMANDS_POST(
[sed -i -E 's/^\\(name|alias|title)\{[[a-zA-Z]]+/\\\1{'"${epiworldname}"'/g' man/epiworldRfaster-package.Rd]
)

AC_OUTPUT
37 changes: 0 additions & 37 deletions man/epiworldRfaster-package.Rd

This file was deleted.

Loading

0 comments on commit f799249

Please sign in to comment.