Skip to content

Commit

Permalink
fix: load Requires.jl only if needed (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal authored Aug 26, 2024
1 parent cc0f67d commit 8be7671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LossFunctions"
uuid = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7"
version = "0.11.1"
version = "0.11.2"

[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand Down
15 changes: 10 additions & 5 deletions src/LossFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ using Markdown

import Base: sum
import Statistics: mean
import Requires: @init, @require

if !isdefined(Base, :get_extension)
import Requires: @require
end

# trait functions
include("traits.jl")
Expand All @@ -20,10 +23,12 @@ include("losses.jl")
include("io.jl")

# Extensions
if !isdefined(Base, :get_extension)
@init @require CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" include(
"../ext/LossFunctionsCategoricalArraysExt.jl"
)
@static if !isdefined(Base, :get_extension)
function __init__()
@require CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" include(
"../ext/LossFunctionsCategoricalArraysExt.jl"
)
end
end

export
Expand Down

2 comments on commit 8be7671

@juliohm
Copy link
Member

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/113899

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 v0.11.2 -m "<description of version>" 8be7671571b536b6f3705b6e1bbc7af29b0beb2c
git push origin v0.11.2

Please sign in to comment.