kyoo0000

startup.jl

Oct 10th, 2020 (edited)
5,523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.20 KB | None | 0 0
  1. using Pkg
  2.  
  3. startup_packages = [:OhMyREPL, :DataStructures]
  4. for pack in startup_packages
  5.    try
  6.       eval(:(using $(pack)))
  7.       printstyled("$(pack) is loaded.\n"; color=:light_green)
  8.    catch e
  9.       if isa(e, ArgumentError)
  10.          printstyled("The $(pack) isn't installed loaded.\nIntalling $(pack).\n"; color=:light_blue)
  11.          Pkg.add("$(pack)")
  12.       end
  13.          eval(:(using $(pack)))
  14.    end
  15. end
  16.  
  17. println()
  18.  
  19. # Check whether any package at 'needed_packages' are installed.
  20. # Case it's not installed, install them.
  21.  
  22. data_science = [:Plots, :DataFrames, :ScikitLearn, :IJulia, :CSV, :Spark, :JDBC, :ODBC]
  23. machine_learning = [:MLJ, :Flux, :Lux, :Metalhead, :ObjectDetector, :TextAnalysis, :Turing]
  24. web = [:Genie]
  25.  
  26. needed_packages = vcat(data_science, machine_learning, web)
  27.  
  28. for pack in needed_packages
  29.    try
  30.       printstyled("Checking if package $(pack) is installed: "; color=:light_cyan)
  31.       isdir(Pkg.dir("$(pack)"))
  32.       printstyled("Ok\n"; color=:light_green)
  33.    catch e
  34.       if isa(e, MethodError)
  35.          printstyled("The $(pack) isn't installed loaded.\nIntalling $(pack).\n"; color=:light_magenta)
  36.          Pkg.add("$pack")
  37.       end
  38.    end
  39. end
  40.  
  41. println()
  42.  
Advertisement
Add Comment
Please, Sign In to add comment