Skip to content

Commit a411f9a

Browse files
CLEANUP: Remove 'digest' as a hard dependency - based on what was just done in 'progressr'
1 parent c910b7d commit a411f9a

4 files changed

Lines changed: 42 additions & 11 deletions

File tree

‎DESCRIPTION‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Package: future
2-
Version: 1.80.0-9001
2+
Version: 1.80.0-9002
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)
66
Imports:
7-
digest,
87
globals (>= 0.18.0),
98
listenv (>= 0.8.0),
109
parallel,
1110
parallelly (>= 1.44.0),
1211
tools,
1312
utils
1413
Suggests:
14+
digest,
1515
methods,
1616
RhpcBLASctl,
1717
R.rsp,
@@ -119,4 +119,4 @@ Collate:
119119
'utils_api-sessionDetails.R'
120120
'utils_api-tweak.R'
121121
'zzz.R'
122-
Config/roxygen2/version: 8.1.0
122+
Config/roxygen2/version: 8.1.1

‎NAMESPACE‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ if (getRversion() >= "4.4") export(FUTURE)
210210
if (getRversion() >= "4.4") export(makeClusterFuture)
211211
if (getRversion() >= "4.4") importFrom(parallel,recvData)
212212
if (getRversion() >= "4.4") importFrom(parallel,sendData)
213-
importFrom(digest,digest)
214213
importFrom(globals,
215214
Globals,
216215
as.Globals,

‎NEWS.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Version (development version)
22

3+
## Significant Changes
4+
5+
* `digest` is no longer a hard dependency. The package now uses
6+
`tools::md5sum(bytes = ...)`, which is available in R (>= 4.5.0), to
7+
generate unique IDs for R objects. For older versions of R, it uses
8+
`tools::md5sum(files = ...)` via a temporary file, which does not add
9+
much overhead because these internal IDs are not generated
10+
frequently. For the time being, `digest::digest()` is still used for
11+
older versions of R, if **digest** is installed.
12+
313
# Version 1.80.0 [2026-10-15]
414

515
## Significant Changes

‎R/utils-uuid.R‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
## Create a universally unique identifier (UUID) for an R object
22
#' @importFrom tools md5sum
3-
#' @importFrom digest digest
43
uuid <- local({
5-
## Use tools::md5sum(), if R (>= 4.5.0). Fall back to digest::digest().
6-
if ("bytes" %in% names(formals(md5sum))) {
7-
md5 <- function(x) md5sum(bytes = serialize(x, connection = NULL))
8-
} else {
9-
md5 <- function(x) digest(x, algo = "md5", serialize = TRUE, skip = 0L)
4+
## We need to trick 'R CMD check' that 'md5' is a function already,
5+
## because with md5 <- NULL, 'codetools' triggers a check NOTE.
6+
md5 <- function(x) {
7+
## 1. Use the native tools::md5sum(bytes = ...), if R (>= 4.5.0).
8+
if ("bytes" %in% names(formals(md5sum))) {
9+
impl <- function(x) md5sum(bytes = serialize(x, connection = NULL))
10+
} else if (requireNamespace("digest", quietly = TRUE)) {
11+
## 2. On R (< 4.5.0), use digest::digest(), if the 'digest' package
12+
## is available.
13+
impl <- function(x) {
14+
digest::digest(x, algo = "md5", serialize = TRUE, skip = 0L)
15+
}
16+
} else {
17+
## 3. On R (< 4.5.0), fall back to tools::md5sum(files = ...)
18+
impl <- function(x) {
19+
bytes <- serialize(x, connection = NULL)
20+
tmp <- tempfile()
21+
on.exit(unlink(tmp))
22+
writeBin(bytes, tmp)
23+
unname(md5sum(tmp))
24+
}
25+
}
26+
27+
## Memoize md5() function, which will replace it for future calls
28+
md5 <<- impl
29+
30+
## But for this first call, we need to call it
31+
impl(x)
1032
}
11-
33+
1234
function(source, keep_source = FALSE) {
1335
uuid <- md5(source)
1436
if (keep_source) attr(uuid, "source") <- source

0 commit comments

Comments
 (0)