From 7942980730238a15d1b4ad84338d380bc109c855 Mon Sep 17 00:00:00 2001 From: Sam Lade Date: Sat, 2 May 2020 18:30:14 +0100 Subject: [PATCH] working windows build too --- build-windows.sh | 2 -- bundle-windows.sh | 2 ++ dr-windows.spec | 33 +++++++++++++++++++++++++++++++++ dr.py | 12 +++++++++--- 4 files changed, 44 insertions(+), 5 deletions(-) delete mode 100644 build-windows.sh create mode 100644 bundle-windows.sh create mode 100644 dr-windows.spec diff --git a/build-windows.sh b/build-windows.sh deleted file mode 100644 index e3d915e..0000000 --- a/build-windows.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -pyinstaller --add-binary="assets/ffmpeg.exe;assets" --add-binary="assets/libwinpthread-1.dll;assets" --add-binary="assets/tag.dll;." -Fw dr.py diff --git a/bundle-windows.sh b/bundle-windows.sh new file mode 100644 index 0000000..1c6acff --- /dev/null +++ b/bundle-windows.sh @@ -0,0 +1,2 @@ +#! /bin/sh +pyinstaller dr-windows.spec diff --git a/dr-windows.spec b/dr-windows.spec new file mode 100644 index 0000000..d9e06ce --- /dev/null +++ b/dr-windows.spec @@ -0,0 +1,33 @@ +# -*- mode: python ; coding: utf-8 -*- +block_cipher = None + + +a = Analysis(['dr.py'], + pathex=['C:\\Users\\Sam\\devel\\drpy'], + datas=[], + hookspath=[], + runtime_hooks=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, + binaries=[('assets/ffmpeg.exe', 'assets'), ('assets/libwinpthread-1.dll', 'assets'), ('assets/tag.dll', '.')], + hiddenimports=['plyer.platforms.win.filechooser'], + excludes=['numpy'], + ) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='dr', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False ) diff --git a/dr.py b/dr.py index 7edf607..a5981c2 100755 --- a/dr.py +++ b/dr.py @@ -27,6 +27,7 @@ import math import os import pathlib +import platform import queue import random import shutil @@ -114,12 +115,17 @@ def convert_file(filename, tmpdir): if not (d / tmpf).exists(): break tmpf = str(d / tmpf) - ffmpeg_path = shutil.which("ffmpeg") + ffmpeg_name = "ffmpeg" + args = {} + if platform.system() == "Windows": + ffmpeg_name += ".exe" + args["creationflags"] = subprocess.CREATE_NO_WINDOW + ffmpeg_path = shutil.which(ffmpeg_name) if not ffmpeg_path: bundle_dir = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__))) - ffmpeg_path = os.path.join(bundle_dir, "assets", "ffmpeg") + ffmpeg_path = os.path.join(bundle_dir, "assets", ffmpeg_name) try: - subprocess.check_output([ffmpeg_path, "-i", filename, tmpf], stderr=subprocess.STDOUT) + subprocess.check_output([ffmpeg_path, "-i", str(filename), tmpf], stderr=subprocess.STDOUT, stdin=subprocess.PIPE, **args) except subprocess.CalledProcessError as e: print(e.output.decode("utf8")) raise