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

https://github.com/Nosferican/DependenciesParser.jl

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?

2 Likes

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]
https://github.com/JuliaData/DataFrames.jl/blob/master/Project.toml
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. GitHub - daschw/DirectDependents.jl: List all registered Julia packages depending on a package.

5 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 !

2 Likes

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).

It seems probable that a PR for that would be welcome, Iā€™d certainly appreciate it :slight_smile:

Not a Julia command, but this is available on JuliaHub
https://juliahub.com/ui/Packages/ExtendedDates/t4jDC/0.1.2?page=2