The leo/plugins folder no longer contains pyzo's sources!

39 views
Skip to first unread message

Edward K. Ream

unread,
Oct 8, 2019, 4:41:46 AM10/8/19
to leo-editor
As of rev 835218 in devel, the pyzo_in_leo plugin works by using pyzo's actual sources.

To make this work you must do the following:

1. Install pyzo.
2. Put pyzo on your path, such that typing `pyzo` in a console starts pyzo.

I recently discovered the marvelous find_executable function in python's distutils.spawn module.  This function has changed how I think about inter-process communication.

Edward

P.S. Here are some examples showing how to use find_executable...

Here is how Leo communicates with asciidoctor and asciidoc3:

asciidoctor_exec = find_executable('asciidoctor')
asciidoc3_exec
= find_executable('asciidoc3')
...
def run_asciidoctor(self, i_path, o_path):
   
global asciidoctor_exec, asciidoc3_exec
   
# Call the external program to write the output file.
    prog
= 'asciidoctor' if asciidoctor_exec else 'asciidoc3'
    command
= f"{prog} {i_path} -o {o_path} -b html5"
    g
.execute_shell_commands(command)

And here is how the top-level init function in the pyzo_in_leo plugin discovers how to import pyzo:

global pyzo
# Fail if can't find pyzo.exe.
pyzo_exec
= find_executable('pyzo')
if not pyzo_exec:
   
return oops('can not find pyzo.exe')
# Add pyzo/source to sys.path
pyzo_dir
= os.path.dirname(pyzo_exec)
pyzo_source_dir
= os.path.join(pyzo_dir, 'source')
if pyzo_source_dir not in sys.path:
    sys
.path.insert(0, pyzo_source_dir)
# Fail if still can't import pyzo.
try:
   
import pyzo as local_pyzo
    pyzo
= local_pyzo
except ImportError:
   
return oops(f"can not import pyzo from {pyzo_source_dir!r}")

EKR

Matt Wilkie

unread,
Oct 8, 2019, 3:17:31 PM10/8/19
to leo-editor
I recently discovered the marvelous find_executable function in python's distutils.spawn module.  This function has changed how I think about inter-process communication.

Thank you!!

Edward K. Ream

unread,
Oct 8, 2019, 3:22:48 PM10/8/19
to leo-editor
On Tue, Oct 8, 2019 at 2:17 PM Matt Wilkie <map...@gmail.com> wrote:
I recently discovered the marvelous find_executable function in python's distutils.spawn module.  This function has changed how I think about inter-process communication.

Thank you!!

You're welcome. I'm glad there is no need for the code bloat.  I'll have more to say on IPC in another thread, maybe tomorrow.

Edward

Matt Wilkie

unread,
Oct 8, 2019, 3:27:48 PM10/8/19
to leo-editor

I recently discovered the marvelous find_executable function in python's distutils.spawn module.  This function has changed how I think about inter-process communication.

Thank you!!

This prompted some research on how to use the function, which turned up this alternate more concise approach that works for me here:

from shutil import which
which('notepad')

Edward K. Ream

unread,
Oct 8, 2019, 5:00:32 PM10/8/19
to leo-editor
On Tue, Oct 8, 2019 at 2:27 PM Matt Wilkie <map...@gmail.com> wrote:

> This prompted some research on how to use the function, which turned up this alternate more concise approach that works for me here:

from shutil import which
which('notepad')
Thanks. Any day without distutils is a good day :-)
Edward
Reply all
Reply to author
Forward
0 new messages