This Julep discusses support for "apps" in the Julia package manager. Text in blue could potentially be left out from a first implementation. In this Julep, an app is defined as a Julia package with a @main
function, intended to be run by the user as appname args to app
. It should feel opaque to the user that the app is written in Julia. It's assumed that Julia is installed and serves as the "driver" to start up the app. This type of app thus differs from:
juliac
/StaticCompiler) that run without a runtime. It should however be possible to incorporate static apps into the system presented here as later work.Package.main
Package.SubModule.main
app/app.jl
or app/App/app.jl
with module app function @main ... end end
in it.
ext/Ext.jl
or ext/Ext/Ext.jl
.apps/Project.toml
+ apps/Manifest.toml
.
AppDeps.toml
).julia/environments/apps/PackageName
)..julia/bin
, which needs to be in the user's PATH
.Project.toml
AdditionsFor packages exposing an app to users, a new [app]
section lists the apps of the package. For example, a package (Rot13.jl) providing the app rot13
:
# Project.toml
name = "Rot13"
uuid = "..."
version = "..."
[deps]
...
[compat]
...
ArgParse = "1"
[apps]
rot13 = {}
# This means rot13 -> Rot13.@main(ARGS)
[apps]
[apps.invrot13]
entry = "Rot13.InvRot13" # submodule of package
[apps.rot26]
entry = "rot13.jl" # file in Rot13/apps/
# or entry = "rot13/rot13.jl"
A new submodule App(s)
is added to Pkg
as well as new REPL commands pkg> app command
. The section only describes the new "REPL" commands but the "API"-versions are straightforward to derive from it:
add
pkg> app add Rot13
Rot13, a registered package, is downloaded. The project file is examined for an app section.
An environment is created in .julia/environments/apps/Rot13
:
bundle_manifest
is false
resolve with Rot13
as the only dependency.bundle_manifest
is true
, copy the manifest and do an instantiate
.Update the .julia/environments/apps/AppManifest.toml
(which is a manifest file containing metadata for all the apps). It should be possible to generate all the shims in .julia/bin
from the AppManifest.toml
file.
AppManifest.toml
is similar to a normal manifest but instead of each package having a list of deps
they have a list of apps
. It would look something like:julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "622b0771..."
[[deps.Rot13]]
uuid = "..."
git-tree-sha1 = "8eb7b4d..."
[[deps.Rot13.apps]]
name = "rot13"
julia = "dev"
[[deps.lld_jll.apps]]
name = "lld"
#
The Julia path could either be an absolute path to the julia executable or alternatively a juliaup julia version specificer.
For each app
, a "shim" bash/batch file is created in .julia/bin
that launches the app. An example shim:
# julia_app_version = "1.0" (version of the shim generator)
# Check if $julia_executable_path exists; if not, throw a warning
JULIA_LOAD_PATH=$(homedir)/.julia/environments/apps/Rot13
exec $julia_executable_path \\
--startup-file=no \\
-m $(pkgname) \\
"$@"
The app is here run in an unstacked environment and the -m
flag to start the entry point for a package is used (https://github.com/JuliaLang/julia/pull/52103).
Either automatically put .julia/bin
in the users .bashrc
etc or check that Sys.which
returns the installed app, if not, warn the user about their PATH
.
rm
pkg> app rm Rot13
: Remove all shims for the Rot13 package (findable from the AppManifest.toml
file) and the .julia/environments/apps/Rot13
folderpkg> app rm rot13
: Remove the rot13
shim. If all apps for Rot13
are removed, remove the environment folder.status
pkg> app status
: For each package with app, for each app, show some info about the app e.g:
Rot13
=====
rot13: {julia = "/path/to/executable/julia", ...}
...
pkg> app status Rot13
: Show info for all apps of Rot13 and show all the dependencies. Almost equivalent to pkg> activate "~/.julia/environments/apps/Rot13"; status
pkg> app status rot13
same as above but only show info for rot13
app.update
pkg app update Rot13
, activate "~/.julia/environments/apps/Rot13"
and run an update
on it.pkg app update
Run the above on all packages in AppManifest.toml
pkg app update Rot13 julia
set the julia
variable (the julia executable) to the current julia path.dev
pkg> app dev Rot13
, download Rot13 in the same way as pkg> dev Rot13
does, set the path
entry for Rot13
in AppManifest.toml
and point the JULIA_LOAD_PATH
to the package folder in the shim.precompile
pkg> app precompile Rot13
There are strictly no needed registry changes for the proposal here to function. For things like auto-complete (e.g. app add Fo<TAB>
) it could be good to have a bit in the registry to know if a package has any apps in it so that only those are auto-completed once you are tab-completing inside an app
command. An error could also quicker be given if one does app add
on a package with no apps if that information is present in the registry.
With the exception of allowing apps/app.jl
in a package, there should be no need for any changes to loading.jl
, everything is built on top of the existing code-loading system.
If apps/app.jl
is allowed, there needs to be some code (which will look very similar to the package extension code) that maps an app to a UUID etc so it can be precompiled.
Environment variables controlling app behavior start with JULIA_APP_
(similar to e.g. JULIA_PKG_
).
This environment variable takes precedence over the app-specific one.
JULIA_APP_ARGS
: Extra arguments that are passed to the Julia executable that runs the app, for example, JULIA_APP_ARGS="--optimize=3 --threads=2"
JULIA_APP_JULIA
: Path to a julia executable to run the app with.
JULIA_APP_JULIA="julia +1.9"
worked for nice compat with juliaup
.DEPOT_PATH
Rot13
library and the rot13
app. On the other hand, there is no need for an arg parser dependency in Rot13
-library but the app probably wants on so if those are forced to share a module the library would probably need to load the arg parser.rot13 ARGS
-> juliaup launchapp rot13 ARGS
-> launch julia -m Rot13 ARGS
.julia/compiled/apps/...
? Or _app.ji
which is not kicked out by loading.pkg> app add lld_jll
?bash-completion