mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
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
This commit is contained in:
parent
9c36c29156
commit
dd70e1be91
3 changed files with 24 additions and 23 deletions
|
@ -29,6 +29,8 @@ import idlever
|
||||||
import rpc
|
import rpc
|
||||||
import RemoteDebugger
|
import RemoteDebugger
|
||||||
|
|
||||||
|
import boolcheck
|
||||||
|
|
||||||
IDENTCHARS = string.ascii_letters + string.digits + "_"
|
IDENTCHARS = string.ascii_letters + string.digits + "_"
|
||||||
|
|
||||||
# Change warnings module to write to sys.__stderr__
|
# Change warnings module to write to sys.__stderr__
|
||||||
|
|
|
@ -1,33 +1,17 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
# Add IDLE.app/Contents/Resources/idlelib to path.
|
import sys as _sys
|
||||||
# __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.
|
# See if we are being asked to execute the subprocess code
|
||||||
# - preserves 2.2 compatibility - 2.2.1 includes bool, 2.2 does not.
|
if '-p' in _sys.argv:
|
||||||
# - important for Mac OS X because it ships python 2.2
|
# run expects only the port number in _sys.argv
|
||||||
import boolcheck
|
_sys.argv.remove('-p')
|
||||||
|
|
||||||
# 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
|
# this module will become the namepsace used by the interactive
|
||||||
# interpreter; remove all variables we have defined.
|
# interpreter; remove all variables we have defined.
|
||||||
del sys, __file__, boolcheck, split, join
|
del _sys
|
||||||
__import__('run').main()
|
__import__('run').main()
|
||||||
else:
|
else:
|
||||||
# start the application.
|
# Start the IDLE GUI
|
||||||
import PyShell
|
import PyShell
|
||||||
PyShell.main()
|
PyShell.main()
|
||||||
|
|
|
@ -31,6 +31,15 @@ txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'LICENSE.txt']
|
||||||
txt_files += ['config-extensions.def', 'config-highlight.def',
|
txt_files += ['config-extensions.def', 'config-highlight.def',
|
||||||
'config-keys.def', 'config-main.def']
|
'config-keys.def', 'config-main.def']
|
||||||
Icons = glob.glob1("Icons","*.gif")
|
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):
|
class IDLE_Builder(build_py):
|
||||||
def get_plain_outfile(self, build_dir, package, file):
|
def get_plain_outfile(self, build_dir, package, file):
|
||||||
# like get_module_outfile, but does not append .py
|
# like get_module_outfile, but does not append .py
|
||||||
|
@ -54,6 +63,12 @@ class IDLE_Builder(build_py):
|
||||||
self.mkpath(dir)
|
self.mkpath(dir)
|
||||||
self.copy_file(os.path.join("Icons", name),
|
self.copy_file(os.path.join("Icons", name),
|
||||||
outfile, preserve_mode = 0)
|
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):
|
def get_source_files(self):
|
||||||
# returns the .py files, the .txt and .def files, and the icons
|
# returns the .py files, the .txt and .def files, and the icons
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue