PyInstaller support

Currently builds but errors while executing
This commit is contained in:
chu23465 2025-04-16 16:09:35 +05:30
parent 5827a968b2
commit 5b88624051
7 changed files with 118 additions and 158 deletions

View File

@ -1,95 +0,0 @@
#!/usr/bin/env python3
import itertools
import os
import shutil
import sys
import toml
from PyInstaller.__main__ import run
if sys.platform == "win32":
from PyInstaller.utils.win32.versioninfo import (FixedFileInfo, SetVersion, StringFileInfo, StringStruct,
StringTable, VarFileInfo, VarStruct, VSVersionInfo)
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
"""Load pyproject.toml information."""
project = toml.load(os.path.join(SCRIPT_PATH, "pyproject.toml"))
poetry = project["tool"]["poetry"]
"""Configuration options that may be changed or referenced often."""
DEBUG = False # When False, removes un-needed data after build has finished
NAME = poetry["name"]
AUTHOR = "vinetrimmer contributors"
VERSION = poetry["version"]
ICON_FILE = "assets/icon.ico" # pass None to use default icon
ONE_FILE = False # Must be False if using setup.iss
CONSOLE = True # If build is intended for GUI, set to False
ADDITIONAL_DATA = [
# (local file path, destination in build output)
]
HIDDEN_IMPORTS = []
EXTRA_ARGS = [
"-y", "--win-private-assemblies", "--win-no-prefer-redirects"
]
"""Prepare environment to ensure output data is fresh."""
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist/vinetrimmer", ignore_errors=True)
# we don't want to use any spec, only the configuration set in this file
try:
os.unlink(f"{NAME}.spec")
except FileNotFoundError:
pass
"""Run PyInstaller with the provided configuration."""
run([
"vinetrimmer/vinetrimmer.py",
"-n", NAME,
"-i", ["NONE", ICON_FILE][bool(ICON_FILE)],
["-D", "-F"][ONE_FILE],
["-w", "-c"][CONSOLE],
*itertools.chain(*[["--add-data", os.pathsep.join(x)] for x in ADDITIONAL_DATA]),
*itertools.chain(*[["--hidden-import", x] for x in HIDDEN_IMPORTS]),
*EXTRA_ARGS
])
if sys.platform == "win32":
"""Set Version Info Structure."""
VERSION_4_TUP = tuple(map(int, f"{VERSION}.0".split(".")))
VERSION_4_STR = ".".join(map(str, VERSION_4_TUP))
SetVersion(
"dist/{0}/{0}.exe".format(NAME),
VSVersionInfo(
ffi=FixedFileInfo(
filevers=VERSION_4_TUP,
prodvers=VERSION_4_TUP
),
kids=[
StringFileInfo([StringTable(
"040904B0", # ?
[
StringStruct("Comments", NAME),
StringStruct("CompanyName", AUTHOR),
StringStruct("FileDescription", "Widevine DRM downloader and decrypter"),
StringStruct("FileVersion", VERSION_4_STR),
StringStruct("InternalName", NAME),
StringStruct("LegalCopyright", f"Copyright (C) 2019-2021 {AUTHOR}"),
StringStruct("OriginalFilename", ""),
StringStruct("ProductName", NAME),
StringStruct("ProductVersion", VERSION_4_STR)
]
)]),
VarFileInfo([VarStruct("Translation", [0, 1200])]) # ?
]
)
)
if not DEBUG:
shutil.rmtree("build", ignore_errors=True)
# we don't want to keep the generated spec
try:
os.unlink(f"{NAME}.spec")
except FileNotFoundError:
pass

37
poetry.lock generated
View File

@ -1355,7 +1355,6 @@ cleo = ">=2.1.0,<3.0.0"
crashtest = ">=0.4.1,<0.5.0" crashtest = ">=0.4.1,<0.5.0"
dulwich = ">=0.21.2,<0.22.0" dulwich = ">=0.21.2,<0.22.0"
fastjsonschema = ">=2.18.0,<3.0.0" fastjsonschema = ">=2.18.0,<3.0.0"
importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""}
installer = ">=0.7.0,<0.8.0" installer = ">=0.7.0,<0.8.0"
keyring = ">=24.0.0,<25.0.0" keyring = ">=24.0.0,<25.0.0"
packaging = ">=23.1" packaging = ">=23.1"
@ -1625,27 +1624,32 @@ requests = "*"
[[package]] [[package]]
name = "pyinstaller" name = "pyinstaller"
version = "4.5.1" version = "5.13.2"
description = "PyInstaller bundles a Python application and all its dependencies into a single package." description = "PyInstaller bundles a Python application and all its dependencies into a single package."
optional = false optional = false
python-versions = ">=3.6" python-versions = "<3.13,>=3.7"
files = [ files = [
{file = "pyinstaller-4.5.1-py3-none-macosx_10_13_universal2.whl", hash = "sha256:ecc2baadeeefd2b6fbf39d13c65d4aa603afdda1c6aaaebc4577ba72893fee9e"}, {file = "pyinstaller-5.13.2-py3-none-macosx_10_13_universal2.whl", hash = "sha256:16cbd66b59a37f4ee59373a003608d15df180a0d9eb1a29ff3bfbfae64b23d0f"},
{file = "pyinstaller-4.5.1-py3-none-manylinux2014_aarch64.whl", hash = "sha256:4d848cd782ee0893d7ad9fe2bfe535206a79f0b6760cecc5f2add831258b9322"}, {file = "pyinstaller-5.13.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8f6dd0e797ae7efdd79226f78f35eb6a4981db16c13325e962a83395c0ec7420"},
{file = "pyinstaller-4.5.1-py3-none-manylinux2014_i686.whl", hash = "sha256:8f747b190e6ad30e2d2fd5da9a64636f61aac8c038c0b7f685efa92c782ea14f"}, {file = "pyinstaller-5.13.2-py3-none-manylinux2014_i686.whl", hash = "sha256:65133ed89467edb2862036b35d7c5ebd381670412e1e4361215e289c786dd4e6"},
{file = "pyinstaller-4.5.1-py3-none-manylinux2014_x86_64.whl", hash = "sha256:c587da8f521a7ce1b9efb4e3d0117cd63c92dc6cedff24590aeef89372f53012"}, {file = "pyinstaller-5.13.2-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:7d51734423685ab2a4324ab2981d9781b203dcae42839161a9ee98bfeaabdade"},
{file = "pyinstaller-4.5.1-py3-none-win32.whl", hash = "sha256:fed9f5e4802769a416a8f2ca171c6be961d1861cc05a0b71d20dfe05423137e9"}, {file = "pyinstaller-5.13.2-py3-none-manylinux2014_s390x.whl", hash = "sha256:2c2fe9c52cb4577a3ac39626b84cf16cf30c2792f785502661286184f162ae0d"},
{file = "pyinstaller-4.5.1-py3-none-win_amd64.whl", hash = "sha256:aae456205c68355f9597411090576bb31b614e53976b4c102d072bbe5db8392a"}, {file = "pyinstaller-5.13.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:c63ef6133eefe36c4b2f4daf4cfea3d6412ece2ca218f77aaf967e52a95ac9b8"},
{file = "pyinstaller-4.5.1.tar.gz", hash = "sha256:30733baaf8971902286a0ddf77e5499ac5f7bf8e7c39163e83d4f8c696ef265e"}, {file = "pyinstaller-5.13.2-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:aadafb6f213549a5906829bb252e586e2cf72a7fbdb5731810695e6516f0ab30"},
{file = "pyinstaller-5.13.2-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:b2e1c7f5cceb5e9800927ddd51acf9cc78fbaa9e79e822c48b0ee52d9ce3c892"},
{file = "pyinstaller-5.13.2-py3-none-win32.whl", hash = "sha256:421cd24f26144f19b66d3868b49ed673176765f92fa9f7914cd2158d25b6d17e"},
{file = "pyinstaller-5.13.2-py3-none-win_amd64.whl", hash = "sha256:ddcc2b36052a70052479a9e5da1af067b4496f43686ca3cdda99f8367d0627e4"},
{file = "pyinstaller-5.13.2-py3-none-win_arm64.whl", hash = "sha256:27cd64e7cc6b74c5b1066cbf47d75f940b71356166031deb9778a2579bb874c6"},
{file = "pyinstaller-5.13.2.tar.gz", hash = "sha256:c8e5d3489c3a7cc5f8401c2d1f48a70e588f9967e391c3b06ddac1f685f8d5d2"},
] ]
[package.dependencies] [package.dependencies]
altgraph = "*" altgraph = "*"
macholib = {version = ">=1.8", markers = "sys_platform == \"darwin\""} macholib = {version = ">=1.8", markers = "sys_platform == \"darwin\""}
pefile = {version = ">=2017.8.1", markers = "sys_platform == \"win32\""} pefile = {version = ">=2022.5.30", markers = "sys_platform == \"win32\""}
pyinstaller-hooks-contrib = ">=2020.6" pyinstaller-hooks-contrib = ">=2021.4"
pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} pywin32-ctypes = {version = ">=0.2.1", markers = "sys_platform == \"win32\""}
setuptools = "*" setuptools = ">=42.0.0"
[package.extras] [package.extras]
encryption = ["tinyaes (>=1.0.0)"] encryption = ["tinyaes (>=1.0.0)"]
@ -1663,7 +1667,6 @@ files = [
] ]
[package.dependencies] [package.dependencies]
importlib_metadata = {version = ">=4.6", markers = "python_version < \"3.10\""}
packaging = ">=22.0" packaging = ">=22.0"
setuptools = ">=42.0.0" setuptools = ">=42.0.0"
@ -2533,5 +2536,5 @@ type = ["pytest-mypy"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.9" python-versions = ">=3.10,<3.13"
content-hash = "d6b9563126bec58d43aa054636d2f6972b53bcab3d13fc13972899134aba0b96" content-hash = "f840ef73c0dc08490a0894e655df27f34ab60e5a5f8c4e3ae8e23ec15f548dad"

96
pyinstaller.py Normal file
View File

@ -0,0 +1,96 @@
#!/usr/bin/env python3
import itertools
import os
import shutil
import sys
import toml
from PyInstaller.__main__ import run
if sys.platform == "win32":
from PyInstaller.utils.win32.versioninfo import (FixedFileInfo, StringFileInfo, StringStruct,
StringTable, VarFileInfo, VarStruct, VSVersionInfo)
#from PyInstaller.utils.win32.versioninfo import SetVersion
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
"""Load pyproject.toml information."""
project = toml.load(os.path.join(SCRIPT_PATH, "pyproject.toml"))
poetry = project["tool"]["poetry"]
"""Configuration options that may be changed or referenced often."""
DEBUG = False # When False, removes un-needed data after build has finished
NAME = poetry["name"]
AUTHOR = "vinetrimmer contributors"
VERSION = poetry["version"]
ICON_FILE = "assets/icon.ico" # pass None to use default icon
ONE_FILE = False # Must be False if using setup.iss
CONSOLE = True # If build is intended for GUI, set to False
ADDITIONAL_DATA = [
# (local file path, destination in build output)
]
HIDDEN_IMPORTS = []
EXTRA_ARGS = [
"-y", "--win-private-assemblies", "--win-no-prefer-redirects"
]
"""Prepare environment to ensure output data is fresh."""
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist/vinetrimmer", ignore_errors=True)
# we don't want to use any spec, only the configuration set in this file
try:
os.unlink(f"{NAME}.spec")
except FileNotFoundError:
pass
"""Run PyInstaller with the provided configuration."""
run([
"vinetrimmer/vinetrimmer.py",
"-n", NAME,
"-i", ["NONE", ICON_FILE][bool(ICON_FILE)],
["-D", "-F"][ONE_FILE],
["-w", "-c"][CONSOLE],
*itertools.chain(*[["--add-data", os.pathsep.join(x)] for x in ADDITIONAL_DATA]),
*itertools.chain(*[["--hidden-import", x] for x in HIDDEN_IMPORTS]),
*EXTRA_ARGS
])
if sys.platform == "win32":
"""Set Version Info Structure."""
VERSION_4_TUP = tuple(map(int, f"{VERSION}.0".split(".")))
VERSION_4_STR = ".".join(map(str, VERSION_4_TUP))
#SetVersion(
# "dist/{0}/{0}.exe".format(NAME),
# VSVersionInfo(
# ffi=FixedFileInfo(
# filevers=VERSION_4_TUP,
# prodvers=VERSION_4_TUP
# ),
# kids=[
# StringFileInfo([StringTable(
# "040904B0", # ?
# [
# StringStruct("Comments", NAME),
# StringStruct("CompanyName", AUTHOR),
# StringStruct("FileDescription", "Widevine DRM downloader and decrypter"),
# StringStruct("FileVersion", VERSION_4_STR),
# StringStruct("InternalName", NAME),
# StringStruct("LegalCopyright", f"Copyright (C) 2019-2021 {AUTHOR}"),
# StringStruct("OriginalFilename", ""),
# StringStruct("ProductName", NAME),
# StringStruct("ProductVersion", VERSION_4_STR)
# ]
# )]),
# VarFileInfo([VarStruct("Translation", [0, 1200])]) # ?
# ]
# )
#)
if not DEBUG:
shutil.rmtree("build", ignore_errors=True)
# we don't want to keep the generated spec
try:
os.unlink(f"{NAME}.spec")
except FileNotFoundError:
pass

View File

@ -9,7 +9,7 @@ description = 'Widevine and Playready DRM downloader and decrypter'
authors = [] authors = []
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = ">=3.10,<3.13"
appdirs = "^1.4.4" appdirs = "^1.4.4"
beautifulsoup4 = "^4.8.2" beautifulsoup4 = "^4.8.2"
click = "^8.0.1" click = "^8.0.1"
@ -55,7 +55,7 @@ yt-dlp = "^2024.11.11"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
flake8 = "^3.8.4" flake8 = "^3.8.4"
isort = "^5.9.2" isort = "^5.9.2"
pyinstaller = "^4.4" pyinstaller = "5.13.2"
[tool.poetry.scripts] [tool.poetry.scripts]
vt = 'vinetrimmer.vinetrimmer:main' vt = 'vinetrimmer.vinetrimmer:main'

View File

@ -1,44 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['vinetrimmer\\vinetrimmer.py'],
pathex=['E:\\PitbullTools\\VT-0.1.0'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=True,
win_private_assemblies=True,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='vinetrimmer',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None , icon='assets\\icon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='vinetrimmer')