[Idle-dev] CVS: idle PyShell.py,1.41,1.42 idle,1.4,1.5 setup.py,1.7,1.8

Kurt B. Kaiser kbk@users.sourceforge.net
Sat, 21 Dec 2002 13:03:09 -0800


Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv29372

Modified Files:
	PyShell.py idle setup.py 
Log Message:
M PyShell.py
M idle
M setup.py

To be able to run from the source directory or from an installed version
of IDLE, and also to allow the subprocess to find run(), Python needs to
have the idlelib package on its path.

1. Modify setup.py to supply a .pth file living at same level as idlelib
2. Move boolcheck to PyShell.py
3. Remove boolcheck and path setting code from the "idle" script


Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** PyShell.py	20 Dec 2002 04:24:42 -0000	1.41
--- PyShell.py	21 Dec 2002 21:03:05 -0000	1.42
***************
*** 30,33 ****
--- 30,35 ----
  import RemoteDebugger
  
+ import boolcheck
+ 
  IDENTCHARS = string.ascii_letters + string.digits + "_"
  

Index: idle
===================================================================
RCS file: /cvsroot/idlefork/idle/idle,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** idle	20 Dec 2002 04:24:43 -0000	1.4
--- idle	21 Dec 2002 21:03:06 -0000	1.5
***************
*** 1,33 ****
  #! /usr/bin/env python
  
! # Add IDLE.app/Contents/Resources/idlelib to path.
! # __file__ refers to this file when it is used as a module, sys.argv[0]
! # refers to this file when it is used as a script (pythonw macosx_main.py)
! import sys
! from os.path import split, join
! try:
!     __file__
! except NameError:
!     __file__ = sys.argv[0]
! idlelib = join(split(__file__)[0], 'idlelib')
! if os.path.isdir(idlelib):
!     sys.path.append(idlelib)
  
! # Make sure True, False, bool() builtins exist.
! # - preserves 2.2 compatibility - 2.2.1 includes bool, 2.2 does not.
! # - important for Mac OS X because it ships python 2.2
! import boolcheck
! 
! # see if we are being asked to execute the subprocess code
! if '-p' in sys.argv:
!     # run expects only the port number in sys.argv
!     sys.argv.remove('-p')
  
      # this module will become the namepsace used by the interactive
      # interpreter; remove all variables we have defined.
!     del sys, __file__, boolcheck, split, join
      __import__('run').main()
  else:
!     # start the application.
      import PyShell
      PyShell.main()
--- 1,17 ----
  #! /usr/bin/env python
  
! import sys as _sys
  
! # See if we are being asked to execute the subprocess code
! if '-p' in _sys.argv:
!     # run expects only the port number in _sys.argv
!     _sys.argv.remove('-p')
  
      # this module will become the namepsace used by the interactive
      # interpreter; remove all variables we have defined.
!     del _sys
      __import__('run').main()
  else:
!     # Start the IDLE GUI
      import PyShell
      PyShell.main()

Index: setup.py
===================================================================
RCS file: /cvsroot/idlefork/idle/setup.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** setup.py	20 Dec 2002 22:40:30 -0000	1.7
--- setup.py	21 Dec 2002 21:03:06 -0000	1.8
***************
*** 32,35 ****
--- 32,44 ----
                'config-keys.def', 'config-main.def']
  Icons = glob.glob1("Icons","*.gif")
+ 
+ # Create a .pth file to live in site-packages; Python will add IDLE to
+ # sys.path:
+ 
+ pathfile = idle_name + ".pth"
+ pfile = open(pathfile, 'w')
+ pfile.write(pkgname +'\n')
+ pfile.close()
+ 
  class IDLE_Builder(build_py):
      def get_plain_outfile(self, build_dir, package, file):
***************
*** 55,58 ****
--- 64,73 ----
              self.copy_file(os.path.join("Icons", name),
                             outfile, preserve_mode = 0)
+         # Copy the .pth file to the same level as the package directory
+         outfile = self.get_plain_outfile(self.build_lib, [], pathfile)
+         dir = os.path.dirname(outfile)
+         self.mkpath(dir)
+         self.copy_file(os.path.join(package_dir, pathfile), outfile,
+                        preserve_mode=0)
  
      def get_source_files(self):