File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -508,6 +508,8 @@ package root.
508
508
To get the root directory of the package that implements the current module
509
509
the form `pkgdir(@__MODULE__)` can be used.
510
510
511
+ If an extension module is given, the root of the parent package is returned.
512
+
511
513
```julia-repl
512
514
julia> pkgdir(Foo)
513
515
"/path/to/Foo.jl"
@@ -525,7 +527,23 @@ function pkgdir(m::Module, paths::String...)
525
527
rootmodule = moduleroot (m)
526
528
path = pathof (rootmodule)
527
529
path === nothing && return nothing
528
- return joinpath (dirname (dirname (path)), paths... )
530
+ original = copy (path)
531
+ path = dirname (path)
532
+ if endswith (path, " src" )
533
+ path = dirname (path)
534
+ elseif contains (path, " ext" )
535
+ # extensions can reside at `../ext/FooExt.jl` or `../ext/FooExt/FooExt.jl`
536
+ if endswith (path, " ext" )
537
+ path = dirname (path)
538
+ else
539
+ path = dirname (path)
540
+ endswith (path, " ext" ) || error (" Unexpected path structure for extension module: $original " )
541
+ path = dirname (path)
542
+ end
543
+ else
544
+ error (" Unexpected path structure for modul source: $original " )
545
+ end
546
+ return joinpath (path, paths... )
529
547
end
530
548
531
549
function get_pkgversion_from_path (path)
You can’t perform that action at this time.
0 commit comments