Do you have a Julia package that provides standalone functionality which you would like to share with folks who do not use Julia? This is for you.
Make a Julia package with a main()
function, put it in a public github repo, and put this this in your README.md
# Installation using [Quickdraw](https://github.com/LilithHafner/Quickdraw)
To install this software on Linux or Mac, run the following command:
```
curl -fLsS https://lilithhafner.com/quickdraw | sh -s https://github.com/MyUsernameOrOrg/MyPackage.jl
```
To install this software on Windows, install Julia and then run the following command:
```
(echo julia -e "import Pkg; Pkg.activate(\"MyPackage\", shared=true); try Pkg.add(url=\"https://github.com/MyUsernameOrOrg/MyPackage.jl\"); catch; println(\"Warning: update failed\") end; using MyPackage: main; main()" %0 %* && echo pause) > MyPackage.bat
```
In both cases, the command will create an executable called `MyPackage` that can be double clicked to run.
Things to remember
- Change
MyUserNameOrOrg
to yor github username or the name of your the github organization that hosts the package being deployed. For exampleLilithHafner
orJuliaCollections
. - Change
MyPackage
to your package name (excluding.jl
). For exampleMinesweeper
orBouncingBall
. - Unlike in a REPL, the application will exit when your main function exits. You can put
wait()
at the end of yourmain()
function to prevent it from exiting. - Quickdraw automatically installs Julia if it is not already installed on Mac and Linux systems. On Windows systems, the user must ensure that Julia is installed before running the Quickdraw command.
The following is found in the README of ManualImageCoding.jl:
Installation using Quickdraw
To install this software on Linux or Mac, run the following command:
curl -fLsS https://lilithhafner.com/quickdraw | sh -s https://github.com/LilithHafner/ManualImageCoding.jl
To install this software on Windows, install Julia and then run the following command:
(echo julia -e "import Pkg; Pkg.activate(\"ManualImageCoding\", shared=true); try Pkg.add(url=\"https://github.com/LilithHafner/ManualImageCoding.jl\"); catch; println(\"Warning: update failed\") end; using ManualImageCoding: main; main()" %0 %* && echo pause) > ManualImageCoding.bat
In both cases, the command will create an executable called ManualImageCoding
that can be double clicked to run.
- MacOS is supported and tested
- Linux is supported and lightly tested
- Windows is supported and lightly tested, but you need to install Julia separately from the windows store.
You can specify a local path instead of a URL with, for example,
curl -fLsS https://lilithhafner.com/quickdraw | sh -s ~/.julia/dev/MyExample
This will use the latest commit of the default branch of the package at ~/.julia/dev/MyExample
,
assuming the file ~/.julia/dev/MyExample/src/MyExample.jl
exists and defines a main()
function.
The command above downloads this script and runs it with the locator of the
package as an argument. The script checks if Julia is installed, and if not, guides the user
through the installation process with juliaup.
Then, the script creates a new shared environment at @PackageName
, adds the package, and
loads the package, ensuring it has a main function. Finally, the script creates a second
script which will remain on the user's computer. The second script is as follows
julia -e 'import Pkg; Pkg.activate("PackageName", shared=true); Pkg.update(); using PackageName: main; main()' $0 $@
It launches julia, activates the shared environment, loads the package, and runs the main function. This script is relocatable to anywhere within the user's computer.
The command creates a batch file that invokes julia, installs or updates the requested package, and runs the package's main function.
The package may access the path of the double-clickable app with ARGS[1]
. If the app is
invoked from the command line, then ARGS[2:end]
will reflect the command line arguments.
You may deploy registered packages just like unregistered packages using a full URL.