From 4f508e1b1fcabb2834dc65bceb4bae307f9264ea Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Mon, 9 Feb 2026 13:29:01 -0500 Subject: [PATCH] Widen copy_globs to accept any pattern type Glob.glob supports Addresses review feedback from @bauglir: allow copy_globs elements to be anything Glob.glob accepts (String, GlobMatch, Vector of matchers including FilenameMatch, Regex, etc.) instead of only String. This enables case-insensitive matching via e.g. `[[fn"license*"i]]`. Co-Authored-By: Claude Opus 4.6 --- src/PackageCompiler.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index bdadda51..dc9d4873 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -1021,9 +1021,12 @@ runtime behavior. - `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_globs::Vector=[]`: Patterns for copying package files to the stdlib directory. + Each element can be anything [`Glob.glob`](https://github.com/vtjnash/Glob.jl) accepts as a pattern: + a `String`, a `GlobMatch`, or a `Vector` of matchers (strings, `Regex`, `Glob.FilenameMatch`, etc.). 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. + For case-insensitive matching, use `Glob.FilenameMatch` patterns: `[[fn"license*"i]]`. """ function create_distribution(project_dir::String, dist_dir::String; @@ -1037,7 +1040,7 @@ function create_distribution(project_dir::String, include_transitive_dependencies::Bool=true, include_preferences::Bool=true, script::Union{Nothing, String}=nothing, - copy_globs::Vector{String}=String[], + copy_globs::Vector=[], release_banner::Union{Nothing, String}=nothing) ctx = create_pkg_context(project_dir) Pkg.instantiate(ctx, verbose=true, allow_autoprecomp=false) @@ -1572,7 +1575,7 @@ function bundle_default_stdlibs(dest_dir) end function bundle_custom_stdlibs(ctx, dest_dir, packages::Vector{Pkg.Types.PackageEntry}, - copy_globs::Vector{String}=String[]) + copy_globs::Vector=[]) isempty(packages) && return version_dir = joinpath(dest_dir, "share", "julia", "stdlib", string('v', VERSION.major, '.', VERSION.minor)) mkpath(version_dir) @@ -1593,8 +1596,8 @@ function bundle_custom_stdlibs(ctx, dest_dir, packages::Vector{Pkg.Types.Package # Copy files matching glob patterns if specified if !isempty(copy_globs) for pattern in copy_globs - # For patterns ending with ** or **/*, copy entire directory tree recursively - if endswith(pattern, "**") || endswith(pattern, "**/*") + # For string patterns ending with ** or **/*, copy entire directory tree recursively + if pattern isa AbstractString && (endswith(pattern, "**") || endswith(pattern, "**/*")) base_dir = replace(replace(pattern, "**/*" => ""), "**" => "") base_dir = rstrip(base_dir, ['/', '\\']) source_dir = joinpath(pkg_source_path, base_dir) @@ -1614,7 +1617,7 @@ function bundle_custom_stdlibs(ctx, dest_dir, packages::Vector{Pkg.Types.Package end end else - # Use glob for specific patterns + # Use glob for specific patterns (accepts String, GlobMatch, Vector of matchers, etc.) matched_files = glob(pattern, pkg_source_path) for src_file in matched_files if isfile(src_file)