-
-
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
add pathof(::Module) #28310
add pathof(::Module) #28310
Conversation
Should this really be a |
@fredrikekre, it doesn't work for arbitrary modules, since it only makes sense for modules that come from a standard |
True, but the answer to the question from a package will be loaded has nothing to do with the implementation of the package manager. Forcing a dependency on Pkg for something that it just directly asks Base code loading about seems unfortunate? |
Sure, it's easy to move this to base. What should the function be called, and should it be exported? |
How about |
That feels like a little bit of a pun but I kind of like it. |
I would expect this to return |
Yes I believe so, especially because AFAIK there's nothing that says a package has to have a particular directory structure, so it may be the case for example that a module is defined in |
Maybe every module should just know what source file it was defined in with |
Yes, there is, look for "src" in |
Implicit |
Oh. 😐 Alright then. Well, I still think returning the file is useful. 😛 |
Changed to |
CI is looking good. |
Marking as triage as otherwise there is no non-deprecated way of getting this info without mucking around in Base internals. |
@StefanKarpinski and/or @KristofferC will have to decide this one. |
I'm a little uneasy about overloading abspath(m, paths...) = joinpath(dirname(abspath(m)), paths...) |
@StefanKarpinski, I removed the |
stdlib/Pkg/src/API.jl
Outdated
@@ -430,7 +430,7 @@ function clone(url::String, name::String = "") | |||
end | |||
|
|||
function dir(pkg::String, paths::AbstractString...) | |||
@warn "`Pkg.dir(pkgname, paths...)` is deprecated; instead, do `import $pkg; abspath($pkg, \"..\", \"..\", paths...)`." maxlog=1 | |||
@warn "`Pkg.dir(pkgname, paths...)` is deprecated; instead, do `import $pkg; joinpath(dirname(abspath($pkg)), \"..\", paths...)`." maxlog=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the dirname
call you don't want the ..
anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need ..
, because dirname
will return the src
directory, while Pkg.dir
returns the parent directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha.
It does feel like a bit of a pun. Packages are loaded based on |
|
Maybe |
I don't particularly like |
Having |
My problem with |
A nice thing about |
I think |
I don't like |
Isn't this a new feature, and thus can be designed after 1.0? |
@JeffBezanson, it is and it isn't — the problem is that an old feature, |
Yes, but it makes things like documentation deployment and coverage submission much easier in CI, since currently scripts have to call edit: 3 second ninja'd by Steven. |
Changed to |
For this particular case you shouldn't need |
CI is green and we're waiting on a couple of other things before tagging RC1, and with any luck that will be tagged before this week's triage. So can we make a decision here in short order? |
Well that's a decision if I've ever seen one 😛 |
build LCM in release mode
Closes #27592.
abspath(FooModule)
returns the path ofFooModule.jl
. The package directory can be obtained fromabspath(FooModule, "..", "..")
.