diff options
| author | tassaron | 2017-07-02 14:19:15 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-02 14:19:15 -0400 |
| commit | 38557f29f91b8abc68ec3408ce466ee8a5da815e (patch) | |
| tree | 9018c2357645aca9fd5296cfa75bf9ed0cf297ee | |
| parent | 0a9002b42cbfa51fb826868a215202c83c97c330 (diff) | |
rm unneeded imports, work on freezing
| -rw-r--r-- | .gitignore | 7 | ||||
| -rw-r--r-- | freeze.py | 35 | ||||
| -rw-r--r-- | src/components/__base__.py | 2 | ||||
| -rw-r--r-- | src/components/text.py | 7 | ||||
| -rw-r--r-- | src/core.py | 26 | ||||
| -rw-r--r-- | src/main.py | 2 |
6 files changed, 51 insertions, 28 deletions
@@ -1,6 +1,11 @@ __pycache__ -settings.ini build/* +env/* .vscode/* *.mkv *.mp4 +*.zip +*.tar +*.tar.* +*.exe +ffmpeg @@ -1,11 +1,14 @@ from cx_Freeze import setup, Executable import sys +import os # Dependencies are automatically detected, but it might need # fine tuning. +deps = [os.path.join('src', p) for p in os.listdir('src') if p] +deps.append('ffmpeg.exe' if sys.platform == 'win32' else 'ffmpeg') + buildOptions = dict( - packages=[], excludes=[ "apport", "apt", @@ -17,17 +20,21 @@ buildOptions = dict( "xmlrpc", "nose" ], - include_files=[ - "mainwindow.ui", - "presetmanager.ui", - "background.png", - "encoder-options.json", - "components/" - ], includes=[ - 'numpy.core._methods', - 'numpy.lib.format' - ] + "encodings", + "json", + "filecmp", + "numpy.core._methods", + "numpy.lib.format", + "PyQt5.QtCore", + "PyQt5.QtGui", + "PyQt5.QtWidgets", + "PyQt5.uic", + "PIL.Image", + "PIL.ImageQt", + "PIL.ImageDraw", + ], + include_files=deps, ) @@ -35,16 +42,16 @@ base = 'Win32GUI' if sys.platform == 'win32' else None executables = [ Executable( - 'main.py', + 'src/main.py', base=base, targetName='audio-visualizer-python' - ) + ), ] setup( name='audio-visualizer-python', - version='1.0', + version='2.0', description='GUI tool to render visualization videos of audio files', options=dict(build_exe=buildOptions), executables=executables diff --git a/src/components/__base__.py b/src/components/__base__.py index 00601e7..b5e7d93 100644 --- a/src/components/__base__.py +++ b/src/components/__base__.py @@ -1,4 +1,4 @@ -from PyQt5 import uic, QtGui, QtCore, QtWidgets +from PyQt5 import uic, QtCore, QtWidgets from PIL import Image import os diff --git a/src/components/text.py b/src/components/text.py index 96421e6..6c5c4eb 100644 --- a/src/components/text.py +++ b/src/components/text.py @@ -3,7 +3,7 @@ from PyQt5.QtGui import QPainter, QColor, QFont from PyQt5 import QtGui, QtCore, QtWidgets from PIL.ImageQt import ImageQt import os -import io +import sys from . import __base__ @@ -136,7 +136,10 @@ class Component(__base__.Component): painter = QPainter(image) self.titleFont.setPixelSize(self.fontSize) painter.setFont(self.titleFont) - painter.setPen(QColor(*self.textColor[::-1])) + if sys.byteorder == 'big': + painter.setPen(QColor(*self.textColor)) + else: + painter.setPen(QColor(*self.textColor[::-1])) painter.drawText(x, y, self.title) painter.end() diff --git a/src/core.py b/src/core.py index b3c5640..3fa67db 100644 --- a/src/core.py +++ b/src/core.py @@ -17,7 +17,6 @@ import string class Core(): def __init__(self): - self.FFMPEG_BIN = self.findFfmpeg() self.dataDir = QStandardPaths.writableLocation( QStandardPaths.AppConfigLocation ) @@ -63,6 +62,7 @@ class Core(): '*.xpm', ]) + self.FFMPEG_BIN = self.findFfmpeg() self.findComponents() self.selectedComponents = [] # copies of named presets to detect modification @@ -437,15 +437,23 @@ class Core(): self.encoder_options = json.load(json_file) def findFfmpeg(self): - if sys.platform == "win32": - return "ffmpeg.exe" + if getattr(sys, 'frozen', False): + # The application is frozen + if sys.platform == "win32": + return os.path.join(self.wd, 'ffmpeg.exe') + else: + return os.path.join(self.wd, 'ffmpeg') + else: - try: - with open(os.devnull, "w") as f: - sp.check_call(['ffmpeg', '-version'], stdout=f, stderr=f) - return "ffmpeg" - except: - return "avconv" + if sys.platform == "win32": + return "ffmpeg.exe" + else: + try: + with open(os.devnull, "w") as f: + sp.check_call(['ffmpeg', '-version'], stdout=f, stderr=f) + return "ffmpeg" + except: + return "avconv" def readAudioFile(self, filename, parent): command = [self.FFMPEG_BIN, '-i', filename] diff --git a/src/main.py b/src/main.py index fd32b13..bae9adf 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,4 @@ -from PyQt5 import QtGui, uic, QtWidgets +from PyQt5 import uic, QtWidgets import sys import os |
