-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
move LinearAlgebra and Dates to package extensions #790
Conversation
Codecov Report
@@ Coverage Diff @@
## master #790 +/- ##
=======================================
Coverage 91.92% 91.92%
=======================================
Files 2 2
Lines 260 260
=======================================
Hits 239 239
Misses 21 21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
I think this is fine for the Dates
part, but the dependency on LinearAlgebra
is to provide Compat.get_num_threads
and Compat.set_num_threads
(even if deprecated). It would be funny if these needed LinearAlgebra
to be loaded to be present (though probably not too bad), but AFAIU, these would be hidden away in the CompatLinearAlgebraExt
module?
As I understand it, (and correct me if I'm wrong), on recent versions this functionality is |
Uh, yes, new code should be using julia> using Compat
julia> Compat.get_num_threads()
WARNING: Compat.get_num_threads is deprecated, use LinearAlgebra.BLAS.get_num_threads instead.
likely near REPL[1]:1
2 With this PR: julia> using Compat, LinearAlgebra
julia> Compat.get_num_threads()
ERROR: UndefVarError: `get_num_threads` not defined For that effect, we could just remove the |
hmm that's supposed to work. I think I have a typo |
Thinking about this some more, How is the |
ext/CompatLinearAlgebraExt.jl
Outdated
module CompatLinearAlgebraExt | ||
using LinearAlgebra | ||
|
||
Base.@deprecate_binding Compat.set_num_threads LinearAlgebra.BLAS.set_num_threads false |
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.
Even if you properly bind Compat
before, this fails with
ERROR: LoadError: cannot assign variables in other modules
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.
I was considering something like
Compat.eval(quote
Base.@deprecate_binding set_num_threads $LinearAlgebra.BLAS.set_num_threads false
Base.@deprecate_binding get_num_threads $LinearAlgebra.BLAS.get_num_threads false
end)
but of course, that yields
ERROR: LoadError: Evaluation into the closed module `Compat` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `Compat` with `eval` during precompilation - don't do this.
Maybe we declare the functions in Compat
without body and then add a method to them in CompatLinearAlgebraExt
doing the deprecation?
Actually, it looks to me as though package extensions don't work with stdlibs - I don't think |
It should yes. Could be a bug. |
Ah, I was confused because at the REPL, |
I've taken the liberty to
The behavior now is slightly different depending on whether you use Julia version that support package extensions or not. julia> Compat.get_num_threads
WARNING: Compat.get_num_threads is deprecated, use LinearAlgebra.BLAS.get_num_threads instead.
likely near REPL[2]:1
get_num_threads (generic function with 1 method)
julia> Compat.get_num_threads()
WARNING: Compat.get_num_threads is deprecated, use LinearAlgebra.BLAS.get_num_threads instead.
likely near REPL[3]:1
2 Julia 1.10: julia> Compat.get_num_threads
get_num_threads (generic function with 1 method)
julia> Compat.get_num_threads()
┌ Warning: `Compat.get_num_threads` is deprecated, use `LinearAlgebra.BLAS.get_num_threads` instead.
│ caller = top-level scope at REPL[6]:1
└ @ Core REPL[6]:1
2 They both give a deprecation warning when calling the deprecated functions, but on older Julia, the binding itself is deprecated. I don't think anyone will notice, so this should be ok. |
Oh, and with the new approach, in an environment without julia> Compat.get_num_threads
get_num_threads (generic function with 0 methods)
julia> Compat.get_num_threads()
ERROR: MethodError: no method matching get_num_threads() So this might technically be considered breaking, but who would be calling those methods if not wanting to use |
Would be nice to have another pair of eyes on this one... |
Lacking further feedback, I think I'll merge this soonish and tag a new patch-version to see whether anyone comes complaining afterwards. Objections? |
This is a no-op for <1.9, but for 1.9 and above mean that you don't automatically bring in
Dates
andLinearAlgebra
from bringing inCompat
. This is mainly useful for people compiling custom sysimages.