#MonthOfJulia Day 13: Packages

By: Andrew Collier

Re-posted from: http://www.exegetic.biz/blog/2015/09/monthofjulia-day-13-packages/

Julia-Logo-Packages

A lot of Julia’s functionality is implemented as add on packages (or “modules”). An extensive (though possibly not exhaustive) list of available packages can be found at http://pkg.julialang.org/. If you browse through that list I can guarantee that you will find a number of packages that pique your curiosity. How to install them? Read on.

Package management is handled via Pkg. Pkg.dir() will tell you where the installed packages are stored on your file system. Before installing any new packages, always call Pkg.update() to update your local metadata and repository (it will update any installed packages to the their most recent version).

julia-package-management

Adding a Package

Installing a new package is done with Pkg.add(). Any dependencies are handled automatically during the install process.

julia> Pkg.add("VennEuler")
INFO: Cloning cache of VennEuler from git://github.com/HarlanH/VennEuler.jl.git
INFO: Installing VennEuler v0.0.1
INFO: Building NLopt
INFO: Building Cairo
INFO: Package database updated

Pkg.available() generates a complete list of all available packages while Pkg.installed() or Pkg.status() can be used to find the versions of installed packages.

julia> Pkg.installed()["VennEuler"]
v"0.0.1"
julia> Pkg.installed("VennEuler")
v"0.0.1"

Pkg.pin() will fix a package at a specific version (no updates will be applied). Pkg.free() releases the effects of Pkg.pin().

Package Contents

The using directive loads the functions exported by a package into the global namespace. You can get a view of the capabilities of a package by typing its name followed by a period and then hitting the Tab key. Alternatively, names() will give a list of symbols exported by a package.

julia> using VennEuler
julia> names(VennEuler)
9-element Array{Symbol,1}:
 :optimize            
 :render              
 :optimize_iteratively
 :VennEuler           
 :EulerObject         
 :EulerState          
 :make_euler_object   
 :EulerSpec           
 :random_state 

The package manager provides a host of other functionality which you can read about here. Check out the videos below to find out more about Julia’s package ecosystem. From tomorrow I’ll start looking at specific packages. To get yourself prepared for that, why not go ahead and install the following packages: Cpp, PyCall, DataArrays, DataFrames and RCall.


The post #MonthOfJulia Day 13: Packages appeared first on Exegetic Analytics.