kludg
kludg

Reputation: 27493

How to create project in Julia and Juno?

I've installed Julia, Atom and Juno. I used to think that before you start coding anything you should create a project, but I can't find "New Project" item in Juno IDE.

Does Julia support the notion of project? If yes, how could I create a simple project, add Julia files to it, run it, etc?

Upvotes: 7

Views: 5886

Answers (2)

J. Blauvelt
J. Blauvelt

Reputation: 785

If you're just looking for a simple way to get the equivalent of a Python virtual environment, where all your packages are contained to a project, here's how I'm currently doing it:

Setting up a new environment:

  1. mkdir myproject
  2. cd myproject
  3. julia
  4. ]
  5. activate . # Now it should say (myproject) pkg> as the prompt
  6. add DataFrames # (for example)
  7. Now two files will appear in myproject/
    1. Project.toml - lists all packages installed. Kind of like a requirements.txt file in Python
    2. Manifest.toml - lists all packages required/available in the project. More intense and complete than Project.toml.

Initializing an environment based on a Project.toml file:

  1. using Pkg
  2. Pkg.activate(".")
  3. Pkg.instantiate() # this will install the packages listed in Project.toml

(You can also use the ] method at the REPL)

Note that if you just do Pkg.activate() (no "."), then it activates the base environment. Usually you won't want to activate the base environment if you're trying to set up an environment specific to a certain project folder.

Upvotes: 22

Michael K. Borregaard
Michael K. Borregaard

Reputation: 8044

Yes - in Julia the concepts "project" and "package" are essentially synonymous - you'll follow the same folder structure, assign a license etc. Currently, the best way of starting a new project is to use the PkgTemplates.jl package (https://github.com/invenia/PkgTemplates.jl). To work with projects in Julia I'd greatly recommend reading the project documentation: https://julialang.github.io/Pkg.jl/v1/

None of this is unfortunately implemented in Juno yet, but there is an open issue for it: https://github.com/JunoLab/Juno.jl/issues/175

Upvotes: 5

Related Questions