let’s say I have a package, which in its main directory contain a file “some_file.jl”. if I run
using MyPackage
is it possible to somehow run
include("MyPackage.some_file.jl")
I.e. run some file contained in the package?
let’s say I have a package, which in its main directory contain a file “some_file.jl”. if I run
using MyPackage
is it possible to somehow run
include("MyPackage.some_file.jl")
I.e. run some file contained in the package?
That worked, thanks a lot
Note, though, that there are contexts — particularly compiled contexts — where you won’t have access to that directory or file.
This kinda looks like eval
-laundering to me — there’s lots of guidance about not using eval
, but that’s effectively what it seems you’re wanting to do here. And it’s effectively what include
does. You could alternatively parse that file into the module as a const value, and then just have folks explicitly eval(MyPackage.SOME_FILE)
, where that was just defined in the module as a const SOME_FILE = parse(read("some_file.jl", String))
.
If I can guess at your root use-case, many packages implement similar functionality with a zero-argument macro.