Re: [Python-Dev] Portable "spawn" module for core?

Recently, Greg Ward <gward@cnri.reston.va.us> said:
Yes, but the interface is quite a bit more high-level, so it's pretty difficult to reconcile with the Unix and Windows "every argument is a string" paradigm. You start the process and pass along an AppleEvent (basically an RPC-call) that will be presented to the program upon startup. So on the mac there's a serious difference between (inventing the API interface here, cut down to make it understandable to non-macheads:-) spawn("netscape", ("Open", "file.html")) and spawn("netscape", ("OpenURL", "http://foo.com/file.html")) The mac interface is (of course:-) infinitely more powerful, allowing you to talk to running apps, adressing stuff in it as COM/OLE does, etc. but unfortunately the simple case of spawn("rm", "-rf", "/") is impossible to represent in a meaningful way. Add to that the fact that there's no stdin/stdout/stderr and there's little common ground. The one area of common ground is "run program X on files Y and Z and wait (or don't wait) for completion", so that is something that could maybe have a special method that could be implemented on all three mentioned platforms (and probably everything else as well). And even then it'll be surprising to Mac users that they have to _exit_ their editor (if you specify wait), not something people commonly do. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm

Indeed. I'm guessing that Greg wrote his code specifically to drive compilers, not so much to invoke an editor on a specific file. It so happens that the Windows compilers have command lines that look sufficiently like the Unix compilers that this might actually work. On the Mac, driving the compilers is best done using AppleEvents, so it's probably better to to try to abuse the spawn() interface for that... (Greg, is there a higher level where the compiler actions are described without referring to specific programs, but perhaps just to compiler actions and input and output files?) --Guido van Rossum (home page: http://www.python.org/~guido/)

On 30 August 1999, Guido van Rossum said:
Correct, but the spawn module I posted should work for any case where you want to run an external command synchronously without redirecting I/O. (And it could probably be extended to handle those cases, but a) I don't need them for Distutils [yet!], and b) I don't know how to do it portably.)
[off-topic alert... probably belongs on distutils-sig, but there you go] Yes, my CCompiler class is all about providing a (hopefully) compiler- and platform-neutral interface to a C/C++ compiler. Currently there're only two concrete subclasses of this: UnixCCompiler and MSVCCompiler, and they both obviously use spawn, because Unix C compilers and MSVC both provide that kind of interface. A hypothetical sibling class that provides an interface to some Mac C compiler might use a souped-up spawn that "knows about" Apple Events, or it might use some other interface to Apple Events. If Jack's simplified summary of what passing Apple Events to a command looks like is accurate, maybe spawn can be souped up to work on the Mac. Or we might need a dedicated module for running Mac programs. So does anybody have code to run external programs on the Mac using Apple Events? Would it be possible/reasonable to add that as '_spawn_mac()' to my spawn module? Greg -- Greg Ward - software developer gward@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive voice: +1-703-620-8990 Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913

Indeed. I'm guessing that Greg wrote his code specifically to drive compilers, not so much to invoke an editor on a specific file. It so happens that the Windows compilers have command lines that look sufficiently like the Unix compilers that this might actually work. On the Mac, driving the compilers is best done using AppleEvents, so it's probably better to to try to abuse the spawn() interface for that... (Greg, is there a higher level where the compiler actions are described without referring to specific programs, but perhaps just to compiler actions and input and output files?) --Guido van Rossum (home page: http://www.python.org/~guido/)

On 30 August 1999, Guido van Rossum said:
Correct, but the spawn module I posted should work for any case where you want to run an external command synchronously without redirecting I/O. (And it could probably be extended to handle those cases, but a) I don't need them for Distutils [yet!], and b) I don't know how to do it portably.)
[off-topic alert... probably belongs on distutils-sig, but there you go] Yes, my CCompiler class is all about providing a (hopefully) compiler- and platform-neutral interface to a C/C++ compiler. Currently there're only two concrete subclasses of this: UnixCCompiler and MSVCCompiler, and they both obviously use spawn, because Unix C compilers and MSVC both provide that kind of interface. A hypothetical sibling class that provides an interface to some Mac C compiler might use a souped-up spawn that "knows about" Apple Events, or it might use some other interface to Apple Events. If Jack's simplified summary of what passing Apple Events to a command looks like is accurate, maybe spawn can be souped up to work on the Mac. Or we might need a dedicated module for running Mac programs. So does anybody have code to run external programs on the Mac using Apple Events? Would it be possible/reasonable to add that as '_spawn_mac()' to my spawn module? Greg -- Greg Ward - software developer gward@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive voice: +1-703-620-8990 Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
participants (3)
-
Greg Ward
-
Guido van Rossum
-
Jack Jansen