Kurt B. Kaiser | f4f4276 | 2002-12-24 06:36:19 +0000 | [diff] [blame] | 1 | try: |
Terry Jan Reedy | 6fa5bdc | 2016-05-28 13:22:31 -0400 | [diff] [blame] | 2 | import idlelib.pyshell |
Kurt B. Kaiser | 7cca3d8 | 2002-12-31 23:18:00 +0000 | [diff] [blame] | 3 | except ImportError: |
Terry Jan Reedy | 6fa5bdc | 2016-05-28 13:22:31 -0400 | [diff] [blame] | 4 | # IDLE is not installed, but maybe pyshell is on sys.path: |
| 5 | from . import pyshell |
Serhiy Storchaka | ef94869 | 2015-05-20 16:15:02 +0300 | [diff] [blame] | 6 | import os |
Terry Jan Reedy | 6fa5bdc | 2016-05-28 13:22:31 -0400 | [diff] [blame] | 7 | idledir = os.path.dirname(os.path.abspath(pyshell.__file__)) |
Serhiy Storchaka | ef94869 | 2015-05-20 16:15:02 +0300 | [diff] [blame] | 8 | if idledir != os.getcwd(): |
| 9 | # We're not in the IDLE directory, help the subprocess find run.py |
| 10 | pypath = os.environ.get('PYTHONPATH', '') |
| 11 | if pypath: |
| 12 | os.environ['PYTHONPATH'] = pypath + ':' + idledir |
| 13 | else: |
| 14 | os.environ['PYTHONPATH'] = idledir |
Terry Jan Reedy | 6fa5bdc | 2016-05-28 13:22:31 -0400 | [diff] [blame] | 15 | pyshell.main() |
Kurt B. Kaiser | e23ca3c | 2003-01-02 17:09:34 +0000 | [diff] [blame] | 16 | else: |
Terry Jan Reedy | 6fa5bdc | 2016-05-28 13:22:31 -0400 | [diff] [blame] | 17 | idlelib.pyshell.main() |