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

Ensure PACKAGES are discovered via available.packages() #88

Open
dgkf opened this issue May 2, 2024 · 5 comments
Open

Ensure PACKAGES are discovered via available.packages() #88

dgkf opened this issue May 2, 2024 · 5 comments
Labels
theme:repo Repository

Comments

@dgkf
Copy link
Collaborator

dgkf commented May 2, 2024

Following on #74,

@borgmaan had mentioned that the modified PACKAGES file is not getting picked up by available.packages(repos = "file:.").

@llrs suggested a few helpers from the tools package that might be able to help with this.

@llrs
Copy link
Member

llrs commented May 4, 2024

The tools::*_PACKAGES doesn't place automatically the files where they should be. This is responsibility of the repository organization (and maybe of available.packages to find it), and they are usually place in <repo_url>/src/contrib/{PACKAGES,PACKAGES.in,PACKAGES.rds,PACKAGES.tar.gz} (This is for both CRAN and Bioconductor).

Instead of <OS>/<R-version>/<pkg>/src/contrib/PACKAGES as in the POC it should be in the top level of the repository (the src/contrib/PACKAGE* part).
However, available.packages if used with a local file repos = "file:...." searches it on that directory : .../PACKAGES. See the source code of utils::available.packages around line 22.

@dgkf
Copy link
Collaborator Author

dgkf commented May 4, 2024

Ah, of course.

This snippet from @borgmaan's script

https://github.com/pharmaR/repos/blob/21fae7094a72a0f7863f66352455b9ea19e5a5ed/dev/merge-riskscore.R#L26-L28

Should instead be

- setwd(file.path(here::here(), "ubuntu-22.04/4.4"))
+ setwd(file.path(here::here(), "ubuntu-22.04/4.4/riskscore"))
  options(repos = c("Local Repo" = "file:."))

Such that available.packages() can append /src/contrib and discover the PACKAGES file.

I'll need to test it out, but I'm confident this is at least part of the issue here.

@llrs
Copy link
Member

llrs commented May 4, 2024

I am not sure I explained myself well: If a file:. is provided it will search for PACKAGES in that folder without appending /src/contrib.

There are two options:

  1. The PACKAGES file should be in a different location:

Instead of /ubuntu-22.04/4.4/src/contrib/PACKAGES it should be in /src/contrib/PACKAGES.
It is assumed that a package in a repository will be build/delivered for all the OS (but that is another discussion):

+ file.rename(file.path(here::here(), "ubuntu-22.04/4.4/riskscore/src/contrib/PACKAGES"), 
+             file.path(here::here(), "PACKAGES"))
- setwd(file.path(here::here(), "ubuntu-22.04/4.4"))
+ setwd(file.path(here::here())
  options(repos = c("Local Repo" = "file:."))
  1. If using available.packages locally it should point to the folder where PACKAGES is.

    So it either change the working directory to where it is executed:

    - setwd(file.path(here::here(), "ubuntu-22.04/4.4"))
    + setwd(file.path(here::here(), "ubuntu-22.04/4.4/riskscore/src/contrib/"))
      options(repos = c("Local Repo" = "file:."))

    Or it points to where the file is:

      setwd(file.path(here::here(), "ubuntu-22.04/4.4"))
    - options(repos = c("Local Repo" = "file:."))
    + options(repos = c("Local Repo" = "file:./riskscore/src/contrib/"))

Of course this needs to be tested.

@dgkf
Copy link
Collaborator Author

dgkf commented May 4, 2024

Ah, I see. You explained it perfectly fine, I just failed to grasp that detail. Thanks for the emphasizing the part I misunderstood.

@llrs
Copy link
Member

llrs commented May 21, 2024

Going back to this after the pharmapkgs package.
Being the working directory the https://github.com/pharmaR/pharmapkgs/ package, this works:

path <- file.path(package = getwd(), repo = "inst/repos/ubuntu-22.04/4.4")
ap2 <- available.packages(
  repos = c(pharmapkgs = file.path("file://", path)), 
  fields = readLines(file.path(path, "src", "contrib", "RISKFIELDS"))
)

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

No branches or pull requests

2 participants