Skip to content

Commit

Permalink
M PyShell.py
Browse files Browse the repository at this point in the history
M idle
M idle.py
M idle.pyw
M setup.py

Switch back to installing IDLE as a package.  The IDLE GUI and the
subprocess will both attempt to start up via the package mechanism, but if
IDLE is not yet installed it is possible to run by calling python idle.py
in the IDLE source directory, or to add the source directory to sys.path.

One advantage of doing it this way is IDLE stays off sys.path.

Developed in collaboration with Tony Lownds.
  • Loading branch information
kbkaiser committed Dec 24, 2002
1 parent 12bf339 commit f4f4276
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
12 changes: 9 additions & 3 deletions Lib/idlelib/PyShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,15 @@ def build_subprocess_arglist(self):
# XXX what about warnoptions?
return [sys.executable, '-p', str(self.port)]
else:
w = ['-W' + s for s in sys.warnoptions]
return [sys.executable] + w \
+ ["-c", "__import__('run').main()", str(self.port)]
w = ['-W' + s for s in sys.warnoptions]
# Maybe IDLE is installed and is being accessed via sys.path,
# or maybe it's not installed and the idle.py script is being
# run from the IDLE source directory.
if __name__ == 'idlelib.PyShell':
command = "__import__('idlelib.run').run.main()"
else:
command = "__import__('run').main()"
return [sys.executable] + w + ["-c", command, str(self.port)]

def start_subprocess(self):
addr = ("localhost", self.port)
Expand Down
9 changes: 7 additions & 2 deletions Lib/idlelib/idle
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env python

import PyShell
PyShell.main()
try:
import idlelib.PyShell
idlelib.PyShell.main()
except:
# IDLE is not installed, but maybe PyShell is on sys.path:
import PyShell
PyShell.main()
9 changes: 7 additions & 2 deletions Lib/idlelib/idle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env python

import PyShell
PyShell.main()
try:
import idlelib.PyShell
idlelib.PyShell.main()
except:
# IDLE is not installed, but maybe PyShell is on sys.path:
import PyShell
PyShell.main()
9 changes: 7 additions & 2 deletions Lib/idlelib/idle.pyw
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env python

import PyShell
PyShell.main()
try:
import idlelib.PyShell
idlelib.PyShell.main()
except:
# IDLE is not installed, but maybe PyShell is on sys.path:
import PyShell
PyShell.main()
11 changes: 5 additions & 6 deletions Lib/idlelib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def run(self):
# Copies all .py files, then also copies the txt and gif files
build_py.run(self)
for name in txt_files:
outfile = self.get_plain_outfile(self.build_lib, [], name)
outfile = self.get_plain_outfile(self.build_lib, [pkgname], name)
dir = os.path.dirname(outfile)
self.mkpath(dir)
self.copy_file(os.path.join(pkg_dir, name), outfile,
preserve_mode = 0)
for name in Icons:
outfile = self.get_plain_outfile(self.build_lib,
["Icons"], name)
[pkgname, "Icons"], name)
dir = os.path.dirname(outfile)
self.mkpath(dir)
self.copy_file(os.path.join("Icons", name),
Expand All @@ -71,11 +71,11 @@ def get_outputs(self, include_bytecode=1):
if not include_bytecode:
return outputs
for name in txt_files:
filename = self.get_plain_outfile(self.build_lib, [], name)
filename = self.get_plain_outfile(self.build_lib, [pkgname], name)
outputs.append(filename)
for name in Icons:
filename = self.get_plain_outfile(self.build_lib,
["Icons"], name)
[pkgname, "Icons"], name)
outputs.append(filename)
return outputs

Expand Down Expand Up @@ -111,7 +111,6 @@ def _bytecode_filenames(self, files):
cmdclass = {'build_py':IDLE_Builder,
'install_lib':IDLE_Installer},
package_dir = {pkgname: pkg_dir},
extra_path = pkgname,
py_modules = [f.split('.')[0] for f in glob.glob("*.py")],
packages = [pkgname],
scripts = [os.path.join(pkg_dir, idle_name)]
)

0 comments on commit f4f4276

Please sign in to comment.