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

Avoid loading libopenfhe_julia_jll when using a custom library #46

Closed
sloede opened this issue Apr 17, 2024 · 1 comment · Fixed by #50
Closed

Avoid loading libopenfhe_julia_jll when using a custom library #46

sloede opened this issue Apr 17, 2024 · 1 comment · Fixed by #50
Assignees
Labels
enhancement New feature or request

Comments

@sloede
Copy link
Member

sloede commented Apr 17, 2024

By making the loading of the JLL package conditional on it being actually used, I was able to avoid the error we encountered in hpsc-lab/openfhe-julia#35 (specifically in hpsc-lab/openfhe-julia#35 (comment)):

--- a/src/OpenFHE.jl
+++ b/src/OpenFHE.jl
@@ -1,13 +1,17 @@
 module OpenFHE

 using CxxWrap # need to use everything to avoid `UndefVarError`s
-using Preferences: @load_preference, set_preferences!, delete_preferences!
+using Preferences: @has_preference, @load_preference, set_preferences!, delete_preferences!
 using UUIDs: UUID
-using openfhe_julia_jll: libopenfhe_julia


-# Load library path from preferences and wrap OpenFHE module
-const libopenfhe_julia_path = @load_preference("libopenfhe_julia", libopenfhe_julia)
+# Load library path from preferences or JLL package and wrap OpenFHE module
+if @has_preference("libopenfhe_julia")
+    const libopenfhe_julia_path = @load_preference("libopenfhe_julia")
+else
+    using openfhe_julia_jll: libopenfhe_julia
+    const libopenfhe_julia_path = libopenfhe_julia
+end
 @wrapmodule(() -> libopenfhe_julia_path)

 function __init__()

@ArseniyKholod It would be great if you could try this out and check if it has other downsides - if not, maybe this is useful for the future.

@sloede sloede added the enhancement New feature or request label Apr 17, 2024
@ArseniyKholod ArseniyKholod self-assigned this Apr 17, 2024
@ArseniyKholod
Copy link
Collaborator

Thanks for taking the time for dealing with this problem! I will figure out if this approach has downsides!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants