Replacement for Pkg.dependents() in 1.0?

I was using Pkg.dependents("PkgName") to get data for these force directed graphs of the Julia ecosystem last year. Now I need to actually use them and Pkg.dependents() is gone! any ideas how to build a list of all packages and their dependencies in 1.0?

1 Like

That information is available in the manifest file of each package. In lack of a better alternative, maybe you could parse this, preferably using the already existing functionality to parse the manifest file that I guess exists in Pkg

2 Likes

Thanks, parsing seems to be the way… Any comments on how to use it to get the dependencies of a single package?

There should probably be a tool in Pkg for this, it’s just gone from being much easier than R to much harder than R.

You can choose whether you want all dependencies or just direct dependencies. From the docs,

julia> installable("DataFrames")[2]
38-element Array{String,1}:
 "Base64"           
 "CategoricalArrays"
 "Compat"           
 "DataStructures"   
 "Dates"            
 "DelimitedFiles"   
 ⋮                  
 "StatsBase"        
 "TableTraits"      
 "Tables"           
 "Test"             
 "UUIDs"            
 "Unicode"

julia> installable("DataFrames", direct = true)[2]
36-element Array{String,1}:
 "Base64"           
 "CategoricalArrays"
 "Compat"           
 "DataStructures"   
 "Dates"            
 "DelimitedFiles"   
 ⋮                  
 "Statistics"       
 "StatsBase"        
 "TableTraits"      
 "Tables"           
 "Test"             
 "UUIDs"

Oh sorry I didn’t see the docs!

Wait, I thought that Pkg.dependents("X") showed which packages depended on X. DependenciesParser.jl seems to just show the inverse: what are the dependencies of X. Right?

1 Like

Both are fine for building a graph, but you could be right.

Is there any solution for this case. Specifically: determining all packages that directly depend on Package X? I.e. all children of a package in a dependency tree

You can get that information in a few lines.

using DependenciesParser
pkgs = DependenciesParser.data
pkgs_deps = getindex.(installable.(pkgs, direct = true), 2)
revdeps = [ pkgs[findall(dep_pkg -> pkg ∈ dep_pkg, deps)] for pkg in pkgs ]

or for a single package,

pkgs[findall(dep_pkg -> "MyPkgName" ∈ dep_pkg, deps)]
1 Like

Might be relevant, the registry will be purged of packages not compatible with Julia 1.0 within a month or so it will be nicer afterwards.

This is tool comes in really handy.
What I don’t understand however is: installable(“DataFrames”, direct=true)[2] currently returns 39 elements/dependencies. The project.toml file of DataFrames only lists 16 dependencies in [deps]


I’m new to julia, so this might be obvious to someone else, but where do those additional 23 dependencies come from?

I believe the issues on how the standard libraries are being handled. During the transition, all projects had implied stdlib dependencies. I am probably going to update the package to get rid of some transition legacy code such as (METADATA_compatible_uuid in favor of better access to the metadata in the registry). The purge should have helped a lot in simplifying the code as well to handle deleted repositories. However, I am low-key also waiting for Julia 1.4 pre-releases so I may use the native functionality and maybe the focus of the package would change to providing things on top of that API

Pkg.dependencies # feature in Julia 1.4

I made a really basic package to list the packages directly depending on a package as a vector of strings that works on Julia 1.4. https://github.com/daschw/DirectDependents.jl

4 Likes

DirectDependents.jl or something like it really needs to be added to Pkg. the need and question as to how to query the packages that depend on package X comes up quite frequently. thanks for this @daschw !

1 Like

FWIW, there’s also some code for this in DocumentationGenerator.jl which also gives version-specific dependency information (and should support multiple packages with the same name).