Skip to content

(Sources-3) oak_scan::set_package_sources()#1288

Open
DavisVaughan wants to merge 1 commit into
sources/2-workspace-dependenciesfrom
sources/3-set-package-sources
Open

(Sources-3) oak_scan::set_package_sources()#1288
DavisVaughan wants to merge 1 commit into
sources/2-workspace-dependenciesfrom
sources/3-set-package-sources

Conversation

@DavisVaughan

Copy link
Copy Markdown
Contributor

Progress towards #1234
Branched from #1287

This PR teaches oak_scan how to update an installed Package's files and scripts from an external on disk directory.

The idea is that some external source provider will return a flat directory of R files that correspond to the source files for a Package. The new oak_scan::set_package_sources() helper iterates over that directory, collecting the R files (but not reading them!), sorting and splitting them in accordance with collate, and stashes them in files and scripts of the Package.

Caution

This PR has an important side effect. Since package.files() now live in a totally separate directory outside any LiveRoot, the File::package backpointer is now a load bearing feature.

Consider File::root(). It switches on self.package(). If there is no package backpointer, it would go through either:

  • root_by_file(), which looks inside LiveRoot::Workspace and LiveRoot::Library root paths for the file's path, neither of which would hold it
  • root_by_path(), which is for orphaned files, and also uses paths contained within WorkspaceRoots

So we need to instead detect self.package() and go through root_by_package(), which doesn't do a path check, it just detects that the Package backpointer is contained within a LiveRoot (by equality, not by path containment). We already do all this, it is just important to point it out now.

File::imports() is similar

Comment on lines +218 to +219
/// The `directory` is not walked recursively. We expect that this is a flat directory of
/// `.R` files.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important to support right now or ever, but in principle a package might install .R files in inst and source them at run time?

@DavisVaughan DavisVaughan force-pushed the sources/2-workspace-dependencies branch from aee7077 to 251a097 Compare June 24, 2026 15:43
@DavisVaughan DavisVaughan force-pushed the sources/3-set-package-sources branch 3 times, most recently from f4da925 to fa6959a Compare June 24, 2026 16:04
@DavisVaughan DavisVaughan force-pushed the sources/2-workspace-dependencies branch from 41e96ce to 8c166c5 Compare June 24, 2026 16:04
@DavisVaughan DavisVaughan force-pushed the sources/3-set-package-sources branch from fa6959a to c7590de Compare June 24, 2026 17:37
As a way to ingest a directory of R files provided by an external source generation tool and set them as the `files` (or `scripts`) of a `Package`
@DavisVaughan DavisVaughan force-pushed the sources/2-workspace-dependencies branch from a1a4bce to 8fb644d Compare June 24, 2026 17:45
@DavisVaughan DavisVaughan force-pushed the sources/3-set-package-sources branch from c7590de to 135018f Compare June 24, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants