Skip to content

Commit

Permalink
add comments + precompile statement
Browse files Browse the repository at this point in the history
  • Loading branch information
lcontento committed Nov 4, 2024
1 parent b62184d commit fb2f095
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/TZJData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ using Artifacts

artifact_dir() = artifact"tzjdata"
Base.@deprecate_binding ARTIFACT_DIR artifact_dir() false
# Why not simply use `const ARTIFACT_DIR = artifact"tzjdata"`?
# The problem is that `ARTIFACT_DIR` would be set to the artifact path at the time of precompilation.
# If the Julia depot is afterwards relocated,
# ARTIFACT_DIR will continue to point to the old no-longer-valid location.
# This occurs for example if TimeZones.jl is included inside a system image.

const TZDATA_VERSION = let
artifact_dict = Artifacts.parse_toml(joinpath(@__DIR__, "..", "Artifacts.toml"))
Expand All @@ -12,4 +17,10 @@ const TZDATA_VERSION = let
m !== nothing ? m[:version] : error("Unable to determine tzdata version")
end

precompile(artifact_dir, ())
# `@deprecate_binding ARTIFACT_DIR artifact_dir()`
# will have already precompiled `artifact_dir()`
# but once the deprecated binding is removed
# an explicit precompile statement will be necessary.

end

0 comments on commit fb2f095

Please sign in to comment.