Fixed pypy bug

master
Tibor Bizjak 2023-04-10 22:49:00 +02:00
parent 4f8788bdee
commit 1647025aa4
1 changed files with 7 additions and 6 deletions

13
main.py
View File

@ -65,14 +65,15 @@ def get_cmd(fn):
ext = fn.split('.')[-1]
if ext == 'py':
with open(fn) as f:
shebang = f.read().lstrip().split('\n')[0]
if shebang[:2] != '#!':
cmd = 'python '
fst_line = f.read().lstrip().split('\n')[0]
if fst_line[:2] != '#!':
return 'python '
shebang = fst_line[2:]
if pypy_installed:
return shebang[2:].replace('python', 'pypy') + ' '
return shebang.replace('python', 'pypy') + ' '
if pypy3_installed:
return shebang[2:].replace('python3', 'pypy3') + ' '
return shebang.replace('python3', 'pypy3') + ' '
return shebang
return './'