Skip to content

Commit 3a3f0e4

Browse files
authored
put chainrules core in a requires block, rm it from deps (#107)
* put chainrules core in a requires block, rm it from deps * test conditional loading of CRC
1 parent 09d703a commit 3a3f0e4

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@ uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
33
version = "1.3.1"
44

55
[deps]
6-
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
76
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8-
9-
[weakdeps]
10-
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
11-
12-
[extensions]
13-
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
7+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
148

159
[compat]
1610
ChainRulesCore = "1"
1711
julia = "^1.0"
1812

13+
[extensions]
14+
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
15+
1916
[extras]
2017
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
2118
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
@@ -25,3 +22,6 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2522

2623
[targets]
2724
test = ["ChainRulesCore", "ChainRulesTestUtils", "Random", "Test", "Unitful"]
25+
26+
[weakdeps]
27+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/AbstractFFTs.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ export fft, ifft, bfft, fft!, ifft!, bfft!,
77

88
include("definitions.jl")
99

10-
if !isdefined(Base, :get_extension)
11-
include("../ext/AbstractFFTsChainRulesCoreExt.jl")
10+
@static if !isdefined(Base, :get_extension)
11+
import Requires
12+
end
13+
14+
@static if !isdefined(Base, :get_extension)
15+
function __init__()
16+
Requires.@require ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" begin
17+
include("../ext/AbstractFFTsChainRulesCoreExt.jl")
18+
end
19+
end
1220
end
1321

1422
end # module

test/runtests.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using AbstractFFTs
44
using AbstractFFTs: Plan
5-
using ChainRulesTestUtils
65

76
using LinearAlgebra
87
using Random
@@ -241,6 +240,19 @@ end
241240
end
242241

243242
@testset "ChainRules" begin
243+
244+
if isdefined(Base, :get_extension)
245+
CRCEXT = Base.get_extension(AbstractFFTs, :AbstractFFTsChainRulesCoreExt)
246+
@test isnothing(CRCEXT)
247+
end
248+
249+
using ChainRulesTestUtils
250+
251+
if isdefined(Base, :get_extension)
252+
CRCEXT = Base.get_extension(AbstractFFTs, :AbstractFFTsChainRulesCoreExt)
253+
@test !isnothing(CRCEXT)
254+
end
255+
244256
@testset "shift functions" begin
245257
for x in (randn(3), randn(3, 4), randn(3, 4, 5))
246258
for dims in ((), 1, 2, (1,2), 1:2)

0 commit comments

Comments
 (0)