Skip to content

Commit

Permalink
Allow access to the artifact path in a relocatable way (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Curtis Vogt <[email protected]>
  • Loading branch information
lcontento and omus authored Dec 20, 2024
1 parent 9498d00 commit 3ef632e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TZJData"
uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7"
authors = ["Curtis Vogt <[email protected]>"]
version = "1.3.0+2024b"
version = "1.3.1+2024b"

[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ julia> using TimeZones: TZJFile

julia> function load(tzname)
rel_path = joinpath(split(tzname, '/'))
return open(TZJFile.read, joinpath(TZJData.ARTIFACT_DIR, rel_path), "r")(tzname)
return open(TZJFile.read, joinpath(TZJData.artifact_dir(), rel_path), "r")(tzname)
end
load (generic function with 1 method)

Expand Down
11 changes: 10 additions & 1 deletion src/TZJData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ module TZJData

using Artifacts

const ARTIFACT_DIR = artifact"tzjdata"
# Avoid using a constant to define the artifact directory as this will hardcode the path
# to the location used during pre-compilation which can be problematic if the Julia depot
# relocated afterwards. One scenario where this can occur is when this package is used
# within a system image.
artifact_dir() = artifact"tzjdata"

# Deprecation for TZJData.jl v1
Base.@deprecate_binding ARTIFACT_DIR artifact_dir() false

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

precompile(artifact_dir, ())

end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function sha256sum(tarball_path)
end

@testset "TZJData.jl" begin
@test isdir(TZJData.ARTIFACT_DIR)
@test isdir(TZJData.artifact_dir())
@test occursin(r"^\d{4}[a-z]$", TZJData.TZDATA_VERSION)

@testset "validate unpublished artifact" begin
Expand All @@ -69,7 +69,7 @@ end

@testset "load compiled" begin
cache = Dict{String,Tuple{TimeZone,Class}}()
_reload_cache!(cache, TZJData.ARTIFACT_DIR)
_reload_cache!(cache, TZJData.artifact_dir())
@test !isempty(cache)
end

Expand Down

4 comments on commit 3ef632e

@omus
Copy link
Member

@omus omus commented on 3ef632e Dec 20, 2024

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

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.3.1+2024b -m "<description of version>" 3ef632e06316de4d04a3cfee62e23b2b3b0e2398
git push origin v1.3.1+2024b

Also, note the warning: Version 1.3.1+2024b skips over 1.3.1
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@omus
Copy link
Member

@omus omus commented on 3ef632e Dec 20, 2024

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 updated: JuliaRegistries/General/121724

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.3.1+2024b -m "<description of version>" 3ef632e06316de4d04a3cfee62e23b2b3b0e2398
git push origin v1.3.1+2024b

Also, note the warning: Version 1.3.1+2024b skips over 1.3.1
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.