Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define exports to throw informative error in Julia DEV versions #688

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/JET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ const JET_DEV_MODE = Preferences.@load_preference("JET_DEV_MODE", false)

const JET_LOADABLE = JET_DEV_MODE || (get(VERSION.prerelease, 1, "") != "DEV")

# exports
# =======

export
# jetanalyzer
@report_call, report_call, @test_call, test_call,
report_file, test_file, report_package, test_package, report_text, reportkey, test_text,
watch_file,
# optanalyzer
@report_opt, report_opt, @test_opt, test_opt,
# configurations
LastFrameModule, AnyFrameModule

# Pre-release Julia versions are not supported, and we don't expect JET to even
# precompile in pre-release versions. So, instead of having JET fail to precompile, we
# simply make JET an empty module so that failure is delayed until the first time JET is
Expand All @@ -21,6 +34,7 @@ else
If you want to load JET on a nightly version, set the `JET_DEV_MODE` Preferences.jl
configuration to `true` and reload it.
"""
include("JETEmpty.jl")
end

end # module
13 changes: 0 additions & 13 deletions src/JETBase.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# exports
# =======

export
# jetanalyzer
@report_call, report_call, @test_call, test_call,
report_file, test_file, report_package, test_package, report_text, reportkey, test_text,
watch_file,
# optanalyzer
@report_opt, report_opt, @test_opt, test_opt,
# configurations
LastFrameModule, AnyFrameModule

let README = normpath(dirname(@__DIR__), "README.md")
s = read(README, String)
s = replace(s,
Expand Down
37 changes: 37 additions & 0 deletions src/JETEmpty.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Empty stubs for the exported functions/macros of JET.jl, to provide a more informative
# error message when JET.jl is used with a pre-release version of Julia.

const err_msg = strip("""
JET.jl does not guarantee compatibility with pre-release versions of Julia and
is not be loaded on this versions by default.
Julia VERSION = $VERSION
We recommend using a stable version of Julia in order to use JET.jl.
Or to try JET with this pre-release Julia version use Preferences.jl to enable
`JET_DEV_MODE`, and then reload JET. For example create a file named
`LocalPreferences.toml` which contains the line:
JET_DEV_MODE = true
Note that JET.jl may not function properly with a pre-release versions of Julia
even with `JET_DEV_MODE` enabled.
""")

for exported_func in (
:report_call, :test_call,
:report_file, :test_file, :report_package, :test_package, :report_text, :reportkey, :test_text,
:watch_file,
# optanalyzer
:report_opt, :test_opt,
# configurations
:LastFrameModule, :AnyFrameModule
)
@eval $exported_func(args...; kws...) = error($err_msg)

Check warning on line 26 in src/JETEmpty.jl

View check run for this annotation

Codecov / codecov/patch

src/JETEmpty.jl#L26

Added line #L26 was not covered by tests
end
for exported_macro in (
:report_call, :test_call,
:report_opt, :test_opt
)
@eval begin
macro $exported_macro(args...)
error($err_msg)
end
end
end
Loading