nicotine+: use pyscript2exe (#25141)

forgot that we have such handy script...
This commit is contained in:
Maksim Bondarenkov 2025-08-09 20:23:20 +07:00 committed by GitHub
parent 2344954ab9
commit ec10d137a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View File

@ -4,7 +4,7 @@ _realname=nicotine+
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.3.10
pkgrel=1
pkgrel=2
pkgdesc="Graphical client for the Soulseek peer-to-peer network (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
@ -26,8 +26,10 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-gobject-introspection"
"${MINGW_PACKAGE_PREFIX}-gettext-tools")
options=('!strip')
source=("${msys2_repository_url}/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('3917ebc562f2d6a6b26b3d815d7cbdf1d11c058d994b1f47794bbb850489b35e')
source=("${msys2_repository_url}/archive/${pkgver}/${_realname}-${pkgver}.tar.gz"
"pyscript2exe.py")
sha256sums=('3917ebc562f2d6a6b26b3d815d7cbdf1d11c058d994b1f47794bbb850489b35e'
'3c65bc3dd7337877e14b19bc7c42918bde664a11a860cfc0b9db891f8a1052db')
noextract=("${_realname}-${pkgver}.tar.gz")
prepare() {
@ -47,5 +49,7 @@ package() {
python -m installer --prefix=${MINGW_PREFIX} \
--destdir="${pkgdir}" dist/*.whl
python "${srcdir}/pyscript2exe.py" "${pkgdir}${MINGW_PREFIX}/bin/nicotine"
install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}

View File

@ -0,0 +1,23 @@
"""
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")