Skip to content

wip: add a create_distribution entry point#1073

Open
KristofferC wants to merge 17 commits intomasterfrom
kc/distro
Open

wip: add a create_distribution entry point#1073
KristofferC wants to merge 17 commits intomasterfrom
kc/distro

Conversation

@KristofferC
Copy link
Copy Markdown
Member

@KristofferC KristofferC commented Nov 19, 2025

This creates basically a new julia "distribution" with a custom set of packages in it.

Right now:

  • packages get added to the sysimage
  • packages are treated as stdlibs so they can be loaded via using Package without a corresponding project file
  • packages are also treated as stdlibs by Pkg
  • package's source code is not copied, shims are added so that Pkg will properly treat it as an stdlib

TODO:

  • test
  • see how extensions are treated

this creates basically a new julia "distribution" with a custom set of packages in it.

Right now:

- packages get added to the sysimage
- packages are treated as stdlib so they can be loaded via `using Package` without a corresponding project file
- packages are also treated as stdlibs by Pkg
- packages source code is not copied, shims are added so that Pkg will properly treat it as an stdlib
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 0% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.86%. Comparing base (c1e37c4) to head (4cc409b).

Files with missing lines Patch % Lines
src/PackageCompiler.jl 0.00% 64 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1073      +/-   ##
==========================================
- Coverage   86.21%   79.86%   -6.35%     
==========================================
  Files           3        3              
  Lines         805      869      +64     
==========================================
  Hits          694      694              
- Misses        111      175      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/PackageCompiler.jl Outdated
Comment on lines +1016 to +1018
- `copy_globs::Vector{String}=String[]`: Glob patterns for copying package files to the stdlib directory.
Patterns are relative to each package root and apply to all packages in the distribution.
Example: `["assets/**", "data/**"]` copies assets and data directories for all packages.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When specifying globs, if one forgets to include "src/**", you end up with a distribution that does not work because none of the packages can be loaded. I'm not 100% sure if this is true in general, but in my testing when I messed this up nothing would work.

I'm wondering if making the stub generation conditional on whether the src folder was copied over. That way there is no extra configuration to be done, although I guess there could be an argument to explicitly disable it, and when someone forgets to add "src/**" to the globs the distribution still ends up working.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the stub generation is even conditional on whether the package entrypoint is already in the target location or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true unless the package somehow reads file during runtime from src. Otherwise, packages should be in the sysimage and not require any bundled sources. Do you have an example of this with some simple packages (Example.jl or Plots.jl etc?).

@pankgeorg
Copy link
Copy Markdown

Just noting that on

see how extensions are treated

Extensions are treated badly, as the code for the packages in the distribution are lost, unless they are copied over with copy_globs=["ext/**"].

@pankgeorg
Copy link
Copy Markdown

Could we also customize the versioninfo() information?

Basically this text:

image

Comment thread src/PackageCompiler.jl Outdated
- `include_transitive_dependencies::Bool=true`: If `true`, include transitive dependencies in the sysimage.
- `include_preferences::Bool=true`: Bundle package preferences into `share/julia/LocalPreferences.toml`.
- `script::Union{Nothing,String}=nothing`: Optional script executed while generating the sysimage.
- `copy_globs::Vector{String}=String[]`: Glob patterns for copying package files to the stdlib directory.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we extend this to allow an array of anything that glob accepts as a pattern, i.e. "strings, GlobMatches, a vector of strings or objects which implement occursin, including RegEx and Glob.FilenameMatch objects"?

In particular, I have the case where I need case insensitive matching which as far as I can tell I cannot express using a regular string converted into a GlobMatch under the hood. Writing all the possible scenarios out is also a bit cumbersome/noisy.

If the array/fn inputs for glob would be supported the following would be able to find both files with a single matcher.

julia> glob("license*", "$(homedir())/.julia/packages/ModelingToolkit/5RGAg/")
String[]

julia> glob([fn"license*"i], "$(homedir())/.julia/packages/ModelingToolkit/5RGAg/")
1-element Vector{String}:
 "~/.julia/packages/ModelingToolkit/5RGAg/LICENSE.md"

julia> glob("license*", "$(homedir())/.julia/packages/OrderedCollections/Xihhq/")
String[]

julia> glob([fn"license*"i], "$(homedir())/.julia/packages/OrderedCollections/Xihhq/")
1-element Vector{String}:
 "~/.julia/packages/OrderedCollections/Xihhq/License.md"

@ven-k
Copy link
Copy Markdown
Member

ven-k commented Mar 31, 2026

create_distribution doesn't bundle includeandetc` directories.

~$ ls .julia/juliaup-depots/juliaup/julia-1.11.9+<custom-distribution>.x64.linux.musl
bin  lib  libexec  local  share
~$ ls .julia/juliaup-depots/juliahub.com/juliaup/juliaup/julia-1.11.9+0.x64.linux.gnu/
bin  etc  include  lib  libexec  LICENSE.md  share

@ven-k
Copy link
Copy Markdown
Member

ven-k commented Apr 7, 2026

TL;DR: Few packages depend on files outside src dir. Instead of copying only src and Project.toml, how about we copy all except a few dirs -- which are least likely to impose such dependencies (ex: test, .github)

These packages fail to precompile without following files:

julia-distribution-patch/share/julia/stdlib/v1.11/ConstructionBase:
README.md

julia-distribution-patch/share/julia/stdlib/v1.11/DomainSets:
FunctionMaps

julia-distribution-patch/share/julia/stdlib/v1.11/DomainSets/FunctionMaps:
LICENSE  Project.toml  README.md  src  test

julia-distribution-patch/share/julia/stdlib/v1.11/MacroTools:
animals.txt

julia-distribution-patch/share/julia/stdlib/v1.11/OpenSpecFun_jll:
Artifacts.toml

This blocks building any sysimage with incremental=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants