Skip to content

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

Merged
DavisVaughan merged 1 commit into
mainfrom
sources/3-set-package-sources
Jun 25, 2026
Merged

(Sources-3) oak_scan::set_package_sources()#1288
DavisVaughan merged 1 commit into
mainfrom
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
@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 2 times, most recently from 135018f to c471cee Compare June 25, 2026 19:54
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch 2 times, most recently from 569ab10 to ea95626 Compare June 25, 2026 20:06
Base automatically changed from sources/2-workspace-dependencies to main June 25, 2026 20:06
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/3-set-package-sources branch from c471cee to 25f23cd Compare June 25, 2026 20:07
@DavisVaughan
DavisVaughan merged commit 01f5d51 into main Jun 25, 2026
17 checks passed
@DavisVaughan
DavisVaughan deleted the sources/3-set-package-sources branch June 25, 2026 20:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants