JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.4k stars 186 forks source link

Bundle preferences with apps/libraries #852

Closed sloede closed 9 months ago

sloede commented 10 months ago

This PR attempts to address those parts of #840 that were not covered by #848. It adds a new function bundle_preferences that will create a LocalPreferences.toml file with all preferences that can be seen by the package or project for which an app/library is compiled. The preferences will will be included in the app/library bundle under PREFIX/share/julia (which is the default LOAD_PATH), such that they get picked up automatically.

@staticfloat Do you think that this would adequately address your original issue in #840?

sloede commented 10 months ago

I see that Base.get_preferences() was not available in Julia v1.6. Is there an alternative way to achieve the same thing, i.e., to get a Dict with all preferences and their values? Or would I have to copy the relevant parts from https://github.com/JuliaLang/julia/blob/master/base/loading.jl to make it work for older Julia versions?

codecov[bot] commented 10 months ago

Codecov Report

Merging #852 (19b1236) into master (a83df58) will increase coverage by 0.20%. Report is 1 commits behind head on master. The diff coverage is 93.75%.

:exclamation: Current head 19b1236 differs from pull request most recent head 4eb7420. Consider uploading reports for the commit 4eb7420 to get more accurate results

@@            Coverage Diff             @@
##           master     #852      +/-   ##
==========================================
+ Coverage   84.15%   84.35%   +0.20%     
==========================================
  Files           3        3              
  Lines         751      767      +16     
==========================================
+ Hits          632      647      +15     
- Misses        119      120       +1     
Files Coverage Δ
src/PackageCompiler.jl 93.12% <93.75%> (+0.01%) :arrow_up:
staticfloat commented 10 months ago

I see that Base.get_preferences() was not available in Julia v1.6.

You.... could. I think preference loading and whatnot should probably work on older Julia versions, the main piece of functionality that is missing is the invalidation of compile-time preferences, but that's not an issue in this case as you're compiling only once. In general though, we don't usually encourage people to use preferences on Julia versions earlier than v1.6, as it can get a little confusing when things don't work the same across all versions.

sloede commented 10 months ago

I removed the limitation to Julia >= v1.8 in 19b1236.

Since most tests pass (I am never sure which are expected/OK to fail), this PR should be ready for review now

cc @KristofferC

sloede commented 10 months ago

@KristofferC I've been using this PR successfully for the past week. Thus it would be great to get a review 🙂

sloede commented 10 months ago

@KristofferC @staticfloat if there are no objections, I will merge this within the next few days.