Skip to content

Commit

Permalink
working windows build too
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentynel committed May 2, 2020
1 parent 7d363b9 commit 7942980
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
2 changes: 0 additions & 2 deletions build-windows.sh

This file was deleted.

2 changes: 2 additions & 0 deletions bundle-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /bin/sh
pyinstaller dr-windows.spec
33 changes: 33 additions & 0 deletions dr-windows.spec
Original file line number Diff line number Diff line change
@@ -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 )
12 changes: 9 additions & 3 deletions dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import math
import os
import pathlib
import platform
import queue
import random
import shutil
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7942980

Please sign in to comment.