I’d like to write a script that installs a few packages, does using to trigger compilation, and replies yes to all questions. Is there a way to do this? What I’d like to do is something like
for pack in [FFTW, SparseSuite, PyPlot, IJulia]
Pkg.add(string(pack))
using pack
replay "y" to all questions
end
I have no idea how to begin. Even without the reply "y" part, I’m having trouble with looping over a list of packages and doing both add (which uses a string) and using (which does not).
I’m still a confused. I’d like to do this in the default environment. Do I write a script to do this? I’d like the user to have to do as little as possible.
My target user will be reading instructions from a web page and not local to my workplace, so I can’t do this myself and send them a .julia tarball.
OK. So when my customer puts the .toml files into a newly created .julia directory and starts Juila, will the packages automatically be added? Do I still have to tell them to do
using XXX
for all packages and reply “y” to any questions?
They will need to run Pkg.instantiate(). Notice that you can easily test these scenarios yourself. This gives you a pristine Julia depot unrelated to whatever you have in your .julia:
$ mkdir /tmp/testdepot
$ JULIA_DEPOT_PATH=/tmp/testdepot julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.8.0 (2022-08-17)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(@v1.8) pkg> st
Installing known registries into `/tmp/testdepot`
Status `/tmp/testdepot/environments/v1.8/Project.toml` (empty project)
import Pkg
Pkg.activate("project_for_ctkelley_tutorial", shared=true)
for pack in [:FFTW, :SuiteSparse, :PyPlot, :IJulia]
Pkg.add(string(pack))
@eval using $pack
end
I took the liberty of adding Pkg.activate("project_for_ctkelley_tutorial", shared=true) so that your users won’t have to deal with a default environment with long precompile times down the line.