Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass on filters argument to pkgAvail() in makeRepo() #156

Open
hturner opened this issue May 14, 2024 · 2 comments
Open

Pass on filters argument to pkgAvail() in makeRepo() #156

hturner opened this issue May 14, 2024 · 2 comments
Assignees
Labels
Milestone

Comments

@hturner
Copy link

hturner commented May 14, 2024

pkgAvail() has a filters argument that is passed on to utils::available.packages() L182. However makeRepo() calls pkgAvail() without this argument L62.

This means that, unless the available_packages_filters option is set, makeRepo() uses the default filters: c("R_version", "OS_type", "subarch", "duplicates"). It would be helpful if makeRepo() could take and pass on the filters argument.

This issue came up when making a repo with binaries for different platforms: carpentriesoffline/offlinedatasci#135 - the "subarch" filter excluded packages compiled for different platforms. It is possible to work round this by setting the available_packages_filters option, but enabling the argument in makeRepo would be more direct and consistent with pkgAvail().

@andrie andrie self-assigned this May 14, 2024
@andrie andrie added the bug label May 14, 2024
@andrie andrie added this to the v0.3.1 milestone May 14, 2024
andrie added a commit that referenced this issue May 14, 2024
@andrie
Copy link
Owner

andrie commented May 14, 2024

Thank you for this report.

I have pushed a change to the dev branch (without any changes to tests).

Could you please check out dev and let me know if this is what you need?

@hturner
Copy link
Author

hturner commented May 16, 2024

Thanks for the quick fix! It is working as I expect. Here's an example run on Windows that demonstrates my original issue before and after:

> repos <- "https://cloud.r-project.org"
> type <- "mac.binary.big-sur-arm64"
>
> dir.create(pth <- file.path(tempdir(), "miniCRAN"))
> makeRepo("fs", pth, repos, type, "4.4")
Created new folder: C:/Users/Heather/AppData/Local/Temp/RtmpUZOSav/miniCRAN/bin/macosx/big-sur-arm64/contrib/4.4
Warning in utils::download.packages(pkgs = pkgs, destdir = destdir, available = available,  :
  no package ‘fs’ at the repositories
character(0)
> list.files(pth, recursive = TRUE)
character(0)
> makeRepo("fs", pth, repos, type, "4.4", filters = "duplicates")
trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.4/fs_1.6.4.tgz'
Content type 'application/x-gzip' length 625516 bytes (610 KB)
downloaded 610 KB

[1] "C:/Users/Heather/AppData/Local/Temp/RtmpUZOSav/miniCRAN/bin/macosx/big-sur-arm64/contrib/4.4/fs_1.6.4.tgz"
> list.files(pth, recursive = TRUE)
[1] "bin/macosx/big-sur-arm64/contrib/4.4/fs_1.6.4.tgz"
[2] "bin/macosx/big-sur-arm64/contrib/4.4/PACKAGES"    
[3] "bin/macosx/big-sur-arm64/contrib/4.4/PACKAGES.gz" 
[4] "bin/macosx/big-sur-arm64/contrib/4.4/PACKAGES.rds"
> unlink(pth, recursive = TRUE)

But for testing you could do something non-OS-specific, e.g.

> repos <- "https://cloud.r-project.org"
> type <- "source"
> dir.create(pth <- file.path(tempdir(), "miniCRAN"))
> makeRepo("tripack", pth, repos, type) 
Created new folder: C:/Users/Heather/AppData/Local/Temp/RtmpUZOSav/miniCRAN/src/contrib
trying URL 'https://cloud.r-project.org/src/contrib/tripack_1.3-9.1.tar.gz'
Content type 'application/x-gzip' length 127697 bytes (124 KB)
downloaded 124 KB

[1] "C:/Users/Heather/AppData/Local/Temp/RtmpUZOSav/miniCRAN/src/contrib/tripack_1.3-9.1.tar.gz"
> makeRepo("tripack", pth, repos, type, filters = "license/restricts_use")
Warning in utils::download.packages(pkgs = pkgs, destdir = destdir, available = available,  :
  no package ‘tripack’ at the repositories
character(0)
> unlink(pth, recursive = TRUE)

{tripack} has been on CRAN since 1998, so is a reasonable test candidate, but of course it could disappear from CRAN so best to make any such test not run on CRAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants