gpython: Fix startup on Windows when installed by pip
On windows setuptools install gpython.exe and gpython-script.py while pip/distlib install gpython.exe with gpython-script sometimes embedded into gpython.exe itself with argv[0] pointing to 'gpython' without .exe suffix. This leads to gpython startup failure: (1.wenv) Z:\home\kirr\src\tools\go\pygo-win\pygolang>gpython Traceback (most recent call last): File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\Scripts\gpython.exe\__main__.py", line 7, in <module> File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 437, in main pymain(argv, init) File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 79, in pymain if not _is_buildout_script(exe): File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 442, in _is_buildout_script with open(path, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: 'Z:\\home\\kirr\\src\\tools\\go\\pygo-win\\1.wenv\\Scripts\\gpython' (1.wenv) Z:\home\kirr\src\tools\go\pygo-win\pygolang>dir ../1.wenv/scripts/gpython* Directory of Z:\home\kirr\src\tools\go\pygo-win\1.wenv\scripts 26.04.2023 14:17 108,404 gpython.exe 1 file 108,404 bytes 0 directories 88,508,866,560 bytes free -> Adjust pymain to handle this case accordingly.
Showing
Please register or sign in to comment