Maksim Bondarenkov ec10d137a0
nicotine+: use pyscript2exe (#25141)
forgot that we have such handy script...
2025-08-09 20:23:20 +07:00

24 lines
600 B
Python

"""
Creates an exe launcher for Python scripts for the executing interpreter.
foobar.py -> foobar.exe + foobar-script.py
"""
import sys
import re
import os
try:
from setuptools.command.easy_install import get_win_launcher
except ImportError:
# v80+
from setuptools._scripts import get_win_launcher
path = sys.argv[1]
with open(path, "rb") as f:
data = f.read()
with open(path, "wb") as f:
f.write(re.sub(b"^#![^\n\r]*", b'', data))
root, ext = os.path.splitext(path)
with open(root + ".exe", "wb") as f:
f.write(get_win_launcher("cli"))
os.rename(path, root + "-script.py")