How to get the directory of an indirect dependency

I’m trying to write a script that analyzes all of the dependencies of a Julia project, including the indirect dependencies. I see how I can use pathof to get the path to the direct dependencies, but how can I do this for the indirect dependencies? Since they aren’t direct dependencies, they can’t be imported, so I can’t get access to the module to be able to pass it to pathof.

Thanks!

Not directly equivalent, since it will give you the project directory instead of the entrypoint file, but:

julia> for (uuid, info) in Pkg.dependencies()
           println("$(uuid) $(info.name) $(info.source)")
       end
29816b5a-b9ab-546f-933c-edad1886dfa8 LibSSH2_jll /home/david/.bin/julia-1.6.0/share/julia/stdlib/v1.6/LibSSH2_jll
4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5 Unicode /home/david/.bin/julia-1.6.0/share/julia/stdlib/v1.6/Unicode
6462fe0b-24de-5631-8697-dd941f90decc Sockets /home/david/.bin/julia-1.6.0/share/julia/stdlib/v1.6/Sockets
ca575930-c2e3-43a9-ace4-1e988b2c1908 NetworkOptions /home/david/.bin/julia-1.6.0/share/julia/stdlib/v1.6/NetworkOptions
deac9b47-8bc7-5906-a0fe-35ac56dc84c0 LibCURL_jll /home/david/.bin/julia-1.6.0/share/julia/stdlib/v1.6/LibCURL_jll
bd369af6-aec1-5ad0-b16a-f7cc5008161c Tables /home/david/.julia/packages/Tables/UxLRG
...

More info here: 12. API Reference · Pkg.jl

Curious as to what analysis you are doing, if you can share :grin:

2 Likes

I wanted to write a script to summarize the licenses of all of the dependencies, by looking for a LICENSE file in each package directory. I think your solution will do the trick, thanks!

2 Likes

https://github.com/ericphanson/LicenseCheck.jl and https://github.com/JuliaEcosystem/PkgDeps.jl might be useful for that task (and maybe https://github.com/JuliaEcosystem/PackageAnalyzer.jl too).

3 Likes