Shayan
Shayan

Reputation: 6295

Check a function belongs to which package in Julia

Sometimes I wonder if a function belongs to which package. So I can use the @which macro for this purpose according to [1], [2]. But today, I was confronted with a strange case I provided here:

julia> @which Not
InvertedIndices

(@v1.7) pkg> st
      Status `C:\Users\Shayan\.julia\environments\v1.7\Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [336ed68f] CSV v0.10.4
  [8f4d0f93] Conda v1.7.0
  [a93c6f00] DataFrames v1.3.4
  [864edb3b] DataStructures v0.18.13
  [85a47980] Dictionaries v0.3.21
  [31c24e10] Distributions v0.25.64
  [38e38edf] GLM v1.8.0
  [09f84164] HypothesisTests v0.10.10
  [7073ff75] IJulia v1.23.3
  [70c4c096] Indicators v0.8.1
  [8ef0a80b] Languages v0.4.3
  [bdcacae8] LoopVectorization v0.12.119
  [945b72a4] MarketData v0.13.12
  [4f8c86c6] MarketTechnicals v0.6.0
  [2774e3e8] NLsolve v4.5.1
  [47be7bcc] ORCA v0.5.0
  [5fb14364] OhMyREPL v0.5.12
  [f0f68f2c] PlotlyJS v0.15.0
  [91a5bcdd] Plots v1.31.1
  [438e738f] PyCall v1.93.1
  [d330b81b] PyPlot v2.10.0
  [3646fa90] ScikitLearn v0.6.4
  [2913bbd2] StatsBase v0.33.18
  [f3b207a7] StatsPlots v0.14.34
  [22787eb5] Term v1.0.2
  [f8ef4a19] VirtualEnv v1.0.0
  [a945a9ba] WordNet v0.2.2
  [fdbf4ff8] XLSX v0.7.10
  [f43a241f] Downloads

The macro said, Not belongs to InvertedIndices. But as you can see, I don't have any package with that name. So I'm confused and can't understand the problem.

Upvotes: 3

Views: 153

Answers (2)

Elias Carvalho
Elias Carvalho

Reputation: 296

You can create a function to see the dependencies of a package that is in the current environment:

using Pkg

function pkgdeps(pkg::AbstractString)
    uuid = Pkg.project().dependencies[pkg]
    pkginfo = Pkg.dependencies()[uuid]
    return pkginfo.dependencies
end

Example:

pkgdeps function

Upvotes: 2

Bogumił Kamiński
Bogumił Kamiński

Reputation: 69829

The issue is that you have Not introduced into your Main module by using DataFrames, and DataFrames.jl re-exports it from InvertedIndices.jl, as you can see here.

You do not have to have InvertedIndices.jl in your Project.toml, but it is present in your Manifest.toml.

Upvotes: 2

Related Questions