Last active
November 10, 2025 22:09
-
-
Save vjcitn/4f6ce522ccb88362d2ee8a1ab6bf56dd to your computer and use it in GitHub Desktop.
create one zip file for a source package on windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| make1zip = function(pname, target="zips322") { | |
| if (!dir.exists(target)) dir.create(target) | |
| target = file.path(getwd(), target) | |
| ins = try(BiocManager::install(pname, ask=FALSE, update=FALSE, type="binary", | |
| dependencies=TRUE, force=TRUE)) # acquire dependencies as needed | |
| if (inherits(ins, "try-error")) stop(sprintf("can't install %s with BiocManager", pname)) | |
| #real_inst = try(install.packages(pname, type="source", repos=NULL)) # this uses native windows build tools from Rtools | |
| bpath = pkgbuild::build(pname) | |
| if (inherits(bpath, "try-error")) stop(sprintf("can't build %s from source", pname)) | |
| install.packages(bpath, type="source", repos=NULL) | |
| pardir = .libPaths()[1] | |
| od = getwd() | |
| on.exit(setwd(od)) | |
| setwd(pardir) | |
| insfld = file.path(pname) | |
| zip(lkf <- file.path(target, paste0(pname, "_", packageVersion(pname), ".zip")), insfld) | |
| unzip(lkf, list=TRUE) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment