Skip to content

Commit a80d57c

Browse files
committed
Noam Raphael's patch.
SF Patch 686254 "Run IDLEfork from any directory without set-up" Allows IDLE to run when not installed and cwd is not the IDLE directory. I took the liberty of moving it to the startup scripts since once IDLEfork is again a part of Python it will be superfluous and I don't want it to be forgotten. But it is very useful for those using IDLEfork standalone! M CREDITS.txt M NEWS.txt M idle M idle.py M idle.pyw
1 parent ab0053a commit a80d57c

5 files changed

Lines changed: 52 additions & 14 deletions

File tree

Lib/idlelib/CREDITS.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ improvements.
1313
Besides Guido, the main developers who have been active on IDLEfork version
1414
0.8.1 and later are Stephen M. Gava, who implemented the Configuration GUI, the
1515
new configuration system, and the new About menu, and Kurt B. Kaiser, who
16-
completed the integration of the RPC and remote debugger, and made a number of
17-
usability enhancements.
16+
completed the integration of the RPC and remote debugger, implemented the
17+
threaded subprocess, and made a number of usability enhancements.
1818

1919
Other contributors include Raymond Hettinger, Tony Lownds (Mac integration),
2020
Neal Norwitz (code check and clean-up), and Chui Tey (RPC integration, debugger
2121
integration and persistent breakpoints).
2222

23-
Hernan Foffani, Christos Georgiou, Jason Orendorff, Josh Robb, and Bruce
24-
Sherwood have submitted useful patches. Thanks, guys!
23+
Hernan Foffani, Christos Georgiou, Martin v. Loewis, Jason Orendorff,
24+
Noam Raphael, Josh Robb, and Bruce Sherwood have submitted useful patches.
25+
Thanks, guys!
2526

2627
There are others who should be included here, especially those who contributed
2728
to IDLE versions prior to 0.8, principally Mark Hammond, Jeremy Hylton,

Lib/idlelib/NEWS.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ What's New in IDLEfork 0.9b1?
77

88
*Release date: XX-XXX-2003*
99

10+
- Allow IDLE to run when not installed and cwd is not the IDLE directory
11+
SF Patch 686254 "Run IDLEfork from any directory without set-up" - Raphael
12+
13+
- When a module is run from an EditorWindow: if its directory is not in
14+
sys.path, prepend it. This allows the module to import other modules in
15+
the same directory. Do the same for a script run from the command line.
16+
1017
- Interrupt the subprocess if it is running when the user attempts to
1118
restart the shell, run a module, or exit.
1219

1320
- Improved exception reporting when running commands or scripts from the
1421
command line.
1522

23+
- Added a -n command line switch to start IDLE without the subprocess.
24+
Removed the Shell menu when running in that mode. Updated help messages.
25+
1626
- Added a comment to the shell startup header to indicate when IDLE is not
17-
using the subprocess. (For now, set PyShell.use_subprocess to False to run
18-
in this mode.)
27+
using the subprocess.
1928

2029
- Restore the ability to run without the subprocess. This can be important for
2130
some platforms or configurations. (Running without the subprocess allows the

Lib/idlelib/idle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ try:
44
import idlelib.PyShell
55
except ImportError:
66
# IDLE is not installed, but maybe PyShell is on sys.path:
7-
import PyShell
8-
PyShell.main()
7+
try:
8+
import PyShell
9+
except ImportError:
10+
print "Can't locate PyShell.py"
11+
else:
12+
import os
13+
idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
14+
if idledir != os.getcwd():
15+
# We're not in the IDLE directory, help the subprocess find run.py
16+
pypath = os.environ.get('PYTHONPATH', '')
17+
os.environ['PYTHONPATH'] = pypath + ':' + idledir
18+
PyShell.main()
919
else:
1020
idlelib.PyShell.main()

Lib/idlelib/idle.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
import idlelib.PyShell
55
except ImportError:
66
# IDLE is not installed, but maybe PyShell is on sys.path:
7-
import PyShell
8-
PyShell.main()
7+
try:
8+
import PyShell
9+
except ImportError:
10+
print "Can't locate PyShell.py"
11+
else:
12+
import os
13+
idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
14+
if idledir != os.getcwd():
15+
# We're not in the IDLE directory, help the subprocess find run.py
16+
pypath = os.environ.get('PYTHONPATH', '')
17+
os.environ['PYTHONPATH'] = pypath + ':' + idledir
18+
PyShell.main()
919
else:
1020
idlelib.PyShell.main()

Lib/idlelib/idle.pyw

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
#!/usr/bin/python
2-
31
try:
42
import idlelib.PyShell
53
except ImportError:
64
# IDLE is not installed, but maybe PyShell is on sys.path:
7-
import PyShell
8-
PyShell.main()
5+
try:
6+
import PyShell
7+
except ImportError:
8+
print "Can't locate PyShell.py"
9+
else:
10+
import os
11+
idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
12+
if idledir != os.getcwd():
13+
# We're not in the IDLE directory, help the subprocess find run.py
14+
pypath = os.environ.get('PYTHONPATH', '')
15+
os.environ['PYTHONPATH'] = pypath + ':' + idledir
16+
PyShell.main()
917
else:
1018
idlelib.PyShell.main()

0 commit comments

Comments
 (0)