-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Base.find_package? #27592
Comments
I plus one this, and to justify further: I typically use the cd(dirname(find_package("Example"))*"../test") Other users ( |
Could we just replace the current |
As it is, this is almost guaranteed to be used incorrectly. Yes, it works fine when called from Main and gives the right answer, but people will use from other packages, at which point it will be wrong since the same name there might load a different package entirely since the names that are visible from Main and their meanings are different from the names that are visible from packages. The correct usage is generally, |
|
It doesn't return a directory, so that would be a little confusing. But of course, we could have a macro that returns that instead. |
|
In #25720 I just suggested that the API for source_file(m::Module) = Base.locate_package(Base.PkgId(m))
julia> source_file(UUIDs)
"/Users/stefan/projects/julia/usr/share/julia/stdlib/v0.7/UUIDs/src/UUIDs.jl" Does that do what people need? The tricky |
On discourse I gave the examples of Documenter.jl and Coverage.jl, both of which need to find (or be given) the source directory of another package that may not have been loaded yet. But I think these could both be modified to ask the user to do |
As another example, one of the tests for NLopt.jl uses the test problem defined in |
That specific use case seems kinda iffy though? What if MathProgBase changes the name of their files? Is the name of files in your test folder a part of the API? Shouldn't MathProgBase provide a |
What about non Julia files? I often want to go to the test directory of MIDI.jl because I know there is a midi file there I want to load. |
From where do you want to load it? Relying on absolute paths in other packages seems very brittle to me. Just have a function in MIDI? |
I am not sure I have understood the question: I typically want to load the midi file when developing. I know there is a midi file in the MIDI package test folders so that is an awesome shortcut.
Yes, I could (and seems like I will have to). But why would you believe that the correct approach is that every single package should define single individual functions, instead of this veeeeery useful function I mean what about the suggestion
? Julia has to know where this |
The whole reason I opened this issue is because there are cases where it is useful. But |
If a particular file is part of the package API it makes sense to add an access function for it, or a function that return a directory containing things for example (like test problems or whatever). |
Once you've loaded a package, there's always a unique place on disk that it came from, so a |
Yes, that's the correct way to refactor all of these APIs. If someone wants to take a crack at that now for this and |
I'm putting together a PR now. |
Base.find_package
is similar toPkg.dir
except that it reports the actual path that would be loaded instead of just joinpathing things.Could be useful to expose.
The text was updated successfully, but these errors were encountered: