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

Fix Base.isinteractive() for startup files #42507

Merged
merged 5 commits into from Oct 7, 2021

Conversation

petvana
Copy link
Member

@petvana petvana commented Oct 5, 2021

This PR aims to fix #10779 by deciding whether the session is interactive before the startup file is executed. PR also enables hot-fix to set interactivity for PyPlot in the startup file when using PackageCompiler, see #42425.

$cat ~/.julia/config/startup.jl
@show Base.isinteractive()

Before PR:

$ julia -q
Base.isinteractive() = false

After this PR:

$ julia -q
Base.isinteractive() = true

@KristofferC
Copy link
Sponsor Member

PR also enables hot-fix to set interactivity for PyPlot in the startup file when using PackageCompiler

Could you explain this a bit more?

@petvana
Copy link
Member Author

petvana commented Oct 5, 2021

@KristofferC You can add something like this to the startup file:

shell> cat ~/.julia/config/startup.jl
try PyPlot.plt.interactive(Base.isinteractive()) catch ; end

System image is build using

using PackageCompiler
create_sysimage([:PyPlot]; sysimage_path="sys_PyPlot.so")

... and the PyPlot works as expected

$ ./julia -J sys_PyPlot.so -q
julia> using PyPlot

julia> plt.isinteractive()
true

Alternative would be to use atreplinit().

Xref: JuliaPy/PyPlot.jl#476

base/client.jl Outdated
@@ -299,9 +302,7 @@ function exec_options(opts)
end
repl |= is_interactive::Bool
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Looks like this could be moved higher as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

repl is only a local variable and seems not to have any effect before because it is always used as repl || is_interactive::Bool. So I moved it to the following if statement to simplify the code slightly.

base/client.jl Outdated Show resolved Hide resolved
@JeffBezanson
Copy link
Sponsor Member

Thanks, looks good to me.

petvana and others added 3 commits October 6, 2021 00:00
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
@petvana petvana marked this pull request as ready for review October 5, 2021 23:19
base/client.jl Outdated Show resolved Hide resolved
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.

isinteractive() and REPL customizations no longer available from .juliarc.jl
4 participants