Is there any way to build package dependency tree in julia-lang?
I don't think there's a simple function, but it shouldn't be too hard to do with these two functions:
julia> Pkg.dependents("Cairo")
10-element Array{AbstractString,1}:
"Tk"
"Gtk"
"Mamba"
"Drawing"
"GtkUtilities"
"ProfileView"
"Brim"
"Winston"
"EcologicalNetwork"
"VennEuler"
julia> Pkg.installed()
Dict{ASCIIString,VersionNumber} with 119 entries:
"Libz" => v"0.0.2"
"Gtk" => v"0.9.3"
"Interact" => v"0.3.0"
"ForwardDiff" => v"0.1.4"
"Benchmark" => v"0.1.0"
"AxisAlgorithms" => v"0.1.4"
"Cairo" => v"0.2.31+"
"HttpParser" => v"0.1.1"
"DataFrames" => v"0.6.10"
"Requests" => v"0.3.4"
"QuartzImageIO" => v"0.1.0+"
"Markdown" => v"0.3.0"
"Requires" => v"0.2.2"
"ArgParse" => v"0.3.0"
⋮ => ⋮
simple code bellow will printout the requires-by result for a package:
whorequires(pkgname) = whorequires(pkgname, 0);
function whorequires(pkgname, i)
deps = Pkg.dependents(pkgname);
[print('-') for j=1:i];
println(pkgname);
length(deps) > 0 && [whorequires(dep,i+1) for dep in deps];
end
julia> whorequires("JuliaParser");
JuliaParser
-CodeTools
--Atom
-ASTInterpreter
--Gallium
-Jewel
EDIT (to cover issue commented by @amrods)
whorequires(pkgname) = whorequires(pkgname, 0, Dict{ASCIIString,Vector{ASCIIString}}());
function whorequires(pkgname, i, m)
[print('-') for j=1:i];
if (haskey(m,pkgname))
println("$pkgname *[duplicated]* is required by ", length(m[pkgname]), " packages");
else
println(pkgname);
m[pkgname] = Pkg.dependents(pkgname);
if (length(m[pkgname]) > 0)
for dep in m[pkgname]
whorequires(dep,i+1,m);
end
end
end
end