Skip to content

Commit 61f459e

Browse files
committed
use package extensions
1 parent 775fa9d commit 61f459e

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,16 @@ version = "0.1.0"
66
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
77

88
[compat]
9+
LazySets = "1, 2, 3"
910
Requires = "0.5, 1"
1011
julia = "1.2"
12+
13+
[extensions]
14+
LazySetsExt = "LazySets"
15+
16+
[extras]
17+
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
18+
19+
[weakdeps]
20+
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
21+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
module LazySetsExt
2+
3+
using MathematicalPredicates
4+
15
export contains, is_contained_in, is_disjoint_from, intersects
2-
import .LazySets: dim, project
36

47
@static if VERSION >= v"1.5"
58
import Base: contains
69
end
710

8-
using .LazySets: LazySet, , isdisjoint
11+
@static if isdefined(Base, :get_extension)
12+
import LazySets: dim, project
13+
using LazySets: LazySet, , isdisjoint
14+
else
15+
import ..LazySets: dim, project
16+
using ..LazySets: LazySet, , isdisjoint
17+
end
918

1019
const SetAtom = CurryAtom{<:Any,<:LazySet}
1120

@@ -77,3 +86,5 @@ end
7786
function intersects(X::LazySet)
7887
return Negation(is_disjoint_from(X))
7988
end
89+
90+
end # module

src/MathematicalPredicates.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ include("Negation.jl")
99
include("Conjunction.jl")
1010
include("Disjunction.jl")
1111
include("CurryAtom.jl")
12-
13-
# optional dependencies
14-
using Requires
1512
include("init.jl")
1613

1714
end # module

src/init.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
function __init__()
2-
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
1+
@static if !isdefined(Base, :get_extension)
2+
using Requires
3+
end
4+
5+
@static if !isdefined(Base, :get_extension)
6+
function __init__()
7+
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("../ext/LazySetsExt.jl")
8+
end
39
end

test/Aqua.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ using MathematicalPredicates, Test
22
import Aqua
33

44
@testset "Aqua tests" begin
5-
Aqua.test_all(MathematicalPredicates;
5+
# Requires is only used in old versions
6+
@static if VERSION >= v"1.9"
7+
stale_deps = (ignore=[:Requires],)
8+
else
9+
stale_deps = true
10+
end
11+
12+
Aqua.test_all(MathematicalPredicates; stale_deps=stale_deps,
613
# `contains` is a known piracy
714
piracies=(treat_as_own=Function[contains],))
815
end

0 commit comments

Comments
 (0)