cjdoris / Bokeh.jl

Interactive plotting made easy
https://cjdoris.github.io/Bokeh.jl
Other
77 stars 3 forks source link

support browser open on WSL #7

Closed johnnychen94 closed 2 years ago

johnnychen94 commented 2 years ago

This works locally on Windows11 WSL

PS C:\Users\jc> wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2

Windows Subsystem for Linux was last updated on 2022/3/26
WSL automatic updates are on.

Kernel version: 5.10.102.1
➜ cat /proc/version                                                                                                                                                                     (base) 
Linux version 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Wed Mar 2 00:30:59 UTC 2022
➜ fish --version                                                                                                                                                                        (base) 
fish, version 3.3.1
julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 12th Gen Intel(R) Core(TM) i9-12900K
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, goldmont)
cjdoris commented 2 years ago

For me:

$ cat /proc/version
Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020

From some searching, it seems occursin("microsoft", lowercase(read("/proc/version", String))) may be the most robust test.

cjdoris commented 2 years ago

It turns out there's a package for this: https://github.com/tpapp/DefaultApplication.jl

It doesn't support WSL, but you could make a PR for WSL support there, and Bokeh can just use DefaultApplication.open to open plots by default, unless the user explicitly sets a browser_cmd.

cjdoris commented 2 years ago

I decided to use DefaultApplication which simplifies things a bit: https://github.com/cjdoris/Bokeh.jl/blob/426bb87fef1a8bae5ba49d70b020b799f3307c46/src/display.jl#L13-L19

I've kept a branch in the logic to handle WSL explicitly and made a PR to DefaultApplication to add WSL support: https://github.com/tpapp/DefaultApplication.jl/pull/17.

cjdoris commented 2 years ago

Closing as I think everything relevant is on main now.

johnnychen94 commented 2 years ago

Thanks!