Skip to content

Commit

Permalink
Move Adapt to a weak dependency (#331)
Browse files Browse the repository at this point in the history
* Move Adapt to a weak-dependency

* rename extension module
  • Loading branch information
jishnub authored Dec 20, 2023
1 parent 62e0bd8 commit 6090bf4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name = "OffsetArrays"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.12.10"
version = "1.13.0"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

[extensions]
OffsetArraysAdaptExt = "Adapt"

[compat]
Adapt = "2, 3, 4"
Aqua = "0.8"
Expand All @@ -20,6 +26,7 @@ Test = "<0.0.1, 1"
julia = "0.7, 1"

[extras]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CatIndices = "aafaddc9-749c-510e-ac4f-586e18779b91"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand All @@ -32,4 +39,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "CatIndices", "DistributedArrays", "DelimitedFiles", "Documenter", "Test", "LinearAlgebra", "EllipsisNotation", "StaticArrays", "FillArrays"]
test = ["Adapt", "Aqua", "CatIndices", "DistributedArrays", "DelimitedFiles", "Documenter", "EllipsisNotation", "FillArrays", "LinearAlgebra", "StaticArrays", "Test"]
11 changes: 11 additions & 0 deletions ext/OffsetArraysAdaptExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module OffsetArraysAdaptExt

using OffsetArrays, Adapt

##
# Adapt allows for automatic conversion of CPU OffsetArrays to GPU OffsetArrays
##
import Adapt
Adapt.adapt_structure(to, O::OffsetArray) = OffsetArrays.parent_call(x -> Adapt.adapt(to, x), O)

end
8 changes: 3 additions & 5 deletions src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,9 @@ if VERSION <= v"1.7.0-DEV.400"
Base._to_linear_index(A::OffsetArray) = first(LinearIndices(A))
end

##
# Adapt allows for automatic conversion of CPU OffsetArrays to GPU OffsetArrays
##
import Adapt
Adapt.adapt_structure(to, O::OffsetArray) = parent_call(x -> Adapt.adapt(to, x), O)
if !isdefined(Base, :get_extension)
include("../ext/OffsetArraysAdaptExt.jl")
end

if Base.VERSION >= v"1.4.2"
include("precompile.jl")
Expand Down

2 comments on commit 6090bf4

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/97464

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.13.0 -m "<description of version>" 6090bf49114ef86d122fc131a8bdb251d19aea3b
git push origin v1.13.0

Please sign in to comment.