Adding non-source files to a package

Is it possible to access non-source files in a package git?
specifically, I would like a text file used for testing the package to be available to users of the package.
When I just placed the text file in the root directory of the package, I saw that it ended up in .julia/packages/<package_name>/<generic_name>/<file.txt>
Where should I place the file, and how can I access it from Julia?

How are the users supposed to interact with it?

Anyway, you can place it wherever you want in your git repository and a function in the package can find its own directory with the macro @__DIR__ and then use joinpath to construct a path to your text file.

1 Like

thanks
Is there an option to access the file without adding code to the package?
consider a typical package structure:

package
  |-- Manifest.toml
  |-- Project.toml 
  |-- README.md
  |-- src
     |-- main.jl
  |-- file.txt

is it possible to access file.txt from the REPL after importing the package?

Yes, pathof can help you there.

julia> using Example

julia> print(read(joinpath(dirname(pathof(Example)), "../README.md"), String))
Example Julia package repo.
[...]
2 Likes

thanks @GunnarFarneback , the pathof function is what I was looking for.
In my case the syntax is:

julia> lines = readlines(joinpath(dirname(pathof(package_name)), "../file.txt"));

Consider also placing it under a test folder…