[Idle-dev] Re: Startup

Tony Lownds tony@lownds.com
Mon, 23 Dec 2002 10:40:01 -0800


>However, I'm not wedded to this.  You point out that the .pth approach
>is not the best way for the Mac.

It should not be a problem if .pth files are used on Windows or Linux though.

>   It is possible to set up IDLE as a
>package and I suspect I can figure out a way to start the subprocess
>when idlelib doesn't (yet) exist: probably something in run.run() like
>try: __import__ idlelib.run except: __import__ run and something
>similar in idle.py so IDLE will work from the source tree before it's
>installed.  Slightly kludgey but no one's going to turn into a pillar
>of salt.  .pth files are kludges, too.

Sounds good to me. Here is one approach (tested)

Index: idle
===================================================================
RCS file: /cvsroot/idlefork/idle/idle,v
retrieving revision 1.6
diff -u -r1.6 idle
--- idle        23 Dec 2002 18:12:41 -0000      1.6
+++ idle        23 Dec 2002 18:27:56 -0000
@@ -1,4 +1,7 @@
  #! /usr/bin/env python

-import PyShell
+try:
+    from idlelib import PyShell
+except ImportError:
+    import PyShell
  PyShell.main()
Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.45
diff -u -r1.45 PyShell.py
--- PyShell.py  23 Dec 2002 18:11:26 -0000      1.45
+++ PyShell.py  23 Dec 2002 18:27:59 -0000
@@ -322,8 +322,12 @@
              return [sys.executable, '-p', str(self.port)]
          else:
              w = ['-W' + s for s in sys.warnoptions]       
+            if __name__ == 'idlelib.PyShell':
+                command = "__import__('idlelib.run').run.main()"
+            else:
+                command = "__import__('run').main()"
              return [sys.executable] + w \
-                 + ["-c", "__import__('run').main()", str(self.port)]
+                 + ["-c", command, str(self.port)]

      def start_subprocess(self):
          addr = ("localhost", self.port)

>What do you guys think?  I'm ready for alpha on Linux and Windows.

Cool. I'm ready here.

-Tony