-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Add import_to_main
flag for Main module package name conflicts resolution
#807
Changes from 3 commits
3fcbf33
918c07b
cdb5a41
6da547c
25187b3
c68f67b
c255bdc
e66470b
aa464ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -309,7 +309,8 @@ function create_sysimg_object_file(object_file::String, | |||||
script::Union{Nothing, String}, | ||||||
sysimage_build_args::Cmd, | ||||||
extra_precompiles::String, | ||||||
incremental::Bool) | ||||||
incremental::Bool, | ||||||
import_into_main::Bool) | ||||||
julia_code_buffer = IOBuffer() | ||||||
# include all packages into the sysimg | ||||||
print(julia_code_buffer, """ | ||||||
|
@@ -409,10 +410,21 @@ function create_sysimg_object_file(object_file::String, | |||||
""" | ||||||
|
||||||
# Make packages available in Main. It is unclear if this is the right thing to do. | ||||||
for pkg in packages | ||||||
print(julia_code_buffer, """ | ||||||
import $pkg | ||||||
if import_into_main | ||||||
for pkg in packages | ||||||
print(julia_code_buffer, """ | ||||||
if isdefined(Main, Symbol("$pkg")) | ||||||
@warn( | ||||||
"Skipping the import of $pkg into Main. A package with this name has " * | ||||||
"already been imported. You can disable importing packages into Main " * | ||||||
"by setting the `import_into_main` flag to `false`. " * | ||||||
"Ref: https://github.com/JuliaLang/PackageCompiler.jl/issues/768" | ||||||
) | ||||||
else | ||||||
import $pkg | ||||||
end | ||||||
""") | ||||||
end | ||||||
end | ||||||
|
||||||
print(julia_code_buffer, precompile_code) | ||||||
|
@@ -484,6 +496,9 @@ compiler (can also include extra arguments to the compiler, like `-g`). | |||||
transitive dependencies into the sysimage. This only makes a difference if some | ||||||
packages do not load all their dependencies when themselves are loaded. Defaults to `true`. | ||||||
|
||||||
- `import_into_main::Bool`: If `true`, import all packages from the sysimage into `Main`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this true? I thought it was just the packages in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I believe only deps from the project you're creating a sysimage of go in
Suggested change
This is more accurate I guess |
||||||
This allows calling `using .Package` without the Project.toml the sysimage was built with. | ||||||
|
||||||
### Advanced keyword arguments | ||||||
|
||||||
- `base_sysimage::Union{Nothing, String}`: If a `String`, names an existing sysimage upon which to build | ||||||
|
@@ -516,6 +531,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector | |||||
soname=nothing, | ||||||
compat_level::String="major", | ||||||
extra_precompiles::String = "", | ||||||
import_into_main::Bool=true, | ||||||
) | ||||||
# We call this at the very beginning to make sure that the user has a compiler available. Therefore, if no compiler | ||||||
# is found, we throw an error immediately, instead of making the user wait a while before the error is thrown. | ||||||
|
@@ -609,7 +625,8 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector | |||||
script, | ||||||
sysimage_build_args, | ||||||
extra_precompiles, | ||||||
incremental) | ||||||
incremental, | ||||||
import_into_main) | ||||||
object_files = [object_file] | ||||||
if julia_init_c_file !== nothing | ||||||
push!(object_files, compile_c_init_julia(julia_init_c_file, basename(sysimage_path))) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that users will see this warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it on a build once but let me confirm on a simple example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visible
