Well, but I cannot:
- launch a Julia script just by typing its name
- launch Julia with multiple threads from a script that runs on one thread
Well, but I cannot:
Sure you can. At least on Unix, you can put #!/path/to/julia
at the top, exactly as you would with a shell script (to avoid having to do bash foo.sh
).
Otherwise, you have to type julia foo.jl
, but why is a few extra characters a big deal for a script like this?
Sure you can. As I said above, you can launch additional julia
processes from a Julia script, just as you would launch julia
processes from a bash
script.
Well, on Linux you can do that, but - as far as I know - not on Windows.
Furthermore the path to Julia is system dependent, and if you want to write generic code I would not know what to put there.
And as I said, it is not only about the script that creates a system image, but also about the script that launches julia and loads the correct system image…
Created a feature request: Julia should read a config file when launching · Issue #45455 · JuliaLang/julia · GitHub
Sure, on Windows you could instead write a one-line foo.bat
script that runs julia foo.jl
. A lot easier than porting a complicated shell script to .bat
and maintaining both.
Why is easier to find the path to a .bat
or .sh
script than a path to Julia? Why not just put julia
in your path, or a link to Julia in the directory of your script, or…?
Suggested here → How to write a program as a Julia package? - #26 by MA_Laforge
repo here → GitHub - ma-laforge/JuliaScripting.jl
In short, Windows allows you to register a file type, say *.jl_script
to be executed with Julia in order to run. A sample file could be:
#!JLScript -iq --startup-file=no --project=@SomeGlobalEnvironment
using ModuleFrom_SomeGlobalEnvironment
result = ModuleFrom_SomeGlobalEnvironment.run_important_tasks()
display(result)
:DONE
#!JLScript
and pass the remaining arguments to the julia command.#!/path/to/julia
pattern instead to match what @stevengj suggested to make julia scripts runnable on Unix/Linux.JULIA_LOAD_PATH
- see install_files/launch_julia_script.ps1
.)..jl_script
files using RMB from explorer.*auto-registers: when you call JuliaScripting.install()
.jl_script
file from PowerShell or cmd will automatically run the script as intended.Try it out for yourself: You can launch any .txt
file from Windows PowerShell by typing in its the file name at the prompt. Doing so gets windows to figure out which “default program/action” to use to launch the .txt
file.