-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add the ability to read files from Starlark #1045
Merged
Merged
Conversation
This file contains 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
rohansingh
force-pushed
the
rohan/bundle
branch
2 times, most recently
from
April 18, 2024 17:47
34c290f
to
ac842a5
Compare
rohansingh
changed the title
runtime: Add the ability to read files from Starlark
Add the ability to read files from Starlark
Apr 18, 2024
Starlark scripts can now load arbitrary files from their bundle and read them using a Python-like `open()` and `read()` API. A `readall()` convenience function is also provided. The examples have been updated to use this functionality where relevant. For example: ``` load("icon.png", icon = "file") BTC_ICON = icon.readall() ``` The `pixlet render` command can now accept an entire directory containing multiple Starlark files and static resources.
Remove the `open()` and `read()` functions, so the only way to read a file is `readall()`. If there is demand for the other methods, we can add them back later.
rohansingh
force-pushed
the
rohan/bundle
branch
from
April 23, 2024 14:22
ac842a5
to
22a4c2c
Compare
Holy smokes @rohansingh When is this going live? Could be game changer for apps that need to render a lot of images. |
@jmanske Ideally this week. Agreed, it will be great for images and other assets. The primary motivation is to be able to include audio files for Tidbyt Gen 2. |
rohansingh
force-pushed
the
rohan/bundle
branch
from
April 24, 2024 02:20
5279aaa
to
5ec7f0a
Compare
Offline review from @matslina:
Deferred for future PR's:
|
`fs.FS` always uses slash-separated paths, even on Windows. So we should be manipulating those paths with `path`, not `filepath`.
It appears that `nlepage/go-tarfs` correctly supports Windows by [using `path` instead of `filepath`][1]. [1]: nlepage/go-tarfs#7
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Starlark scripts can now load arbitrary files from their bundle and read them using a Python-like
open()
andread()
API. Areadall()
convenience function is also provided.The examples have been updated to use this functionality where relevant. For example:
Supporting changes:
The
pixlet render
command can now accept an entire directory containing multiple Starlark files and static resources.The
pixlet private bundle
command can now accept an entire directory. It will load the applet contained in the directory, and bundle any files that the applet itself loads. Not that "private" is a misnomer, this command is used by both private and community apps.App manifests no longer contain a
fileName
attribute, since an app may contain multiple files.packageName
has been removed as well, since it is no longer used for anything.