rm unneeded imports, work on freezing

This commit is contained in:
tassaron 2017-07-02 14:19:15 -04:00
parent 0a9002b42c
commit 38557f29f9
6 changed files with 51 additions and 28 deletions

7
.gitignore vendored
View File

@ -1,6 +1,11 @@
__pycache__ __pycache__
settings.ini
build/* build/*
env/*
.vscode/* .vscode/*
*.mkv *.mkv
*.mp4 *.mp4
*.zip
*.tar
*.tar.*
*.exe
ffmpeg

View File

@ -1,11 +1,14 @@
from cx_Freeze import setup, Executable from cx_Freeze import setup, Executable
import sys import sys
import os
# Dependencies are automatically detected, but it might need # Dependencies are automatically detected, but it might need
# fine tuning. # 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( buildOptions = dict(
packages=[],
excludes=[ excludes=[
"apport", "apport",
"apt", "apt",
@ -17,17 +20,21 @@ buildOptions = dict(
"xmlrpc", "xmlrpc",
"nose" "nose"
], ],
include_files=[
"mainwindow.ui",
"presetmanager.ui",
"background.png",
"encoder-options.json",
"components/"
],
includes=[ includes=[
'numpy.core._methods', "encodings",
'numpy.lib.format' "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 = [ executables = [
Executable( Executable(
'main.py', 'src/main.py',
base=base, base=base,
targetName='audio-visualizer-python' targetName='audio-visualizer-python'
) ),
] ]
setup( setup(
name='audio-visualizer-python', name='audio-visualizer-python',
version='1.0', version='2.0',
description='GUI tool to render visualization videos of audio files', description='GUI tool to render visualization videos of audio files',
options=dict(build_exe=buildOptions), options=dict(build_exe=buildOptions),
executables=executables executables=executables

View File

@ -1,4 +1,4 @@
from PyQt5 import uic, QtGui, QtCore, QtWidgets from PyQt5 import uic, QtCore, QtWidgets
from PIL import Image from PIL import Image
import os import os

View File

@ -3,7 +3,7 @@ from PyQt5.QtGui import QPainter, QColor, QFont
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt5 import QtGui, QtCore, QtWidgets
from PIL.ImageQt import ImageQt from PIL.ImageQt import ImageQt
import os import os
import io import sys
from . import __base__ from . import __base__
@ -136,7 +136,10 @@ class Component(__base__.Component):
painter = QPainter(image) painter = QPainter(image)
self.titleFont.setPixelSize(self.fontSize) self.titleFont.setPixelSize(self.fontSize)
painter.setFont(self.titleFont) 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.drawText(x, y, self.title)
painter.end() painter.end()

View File

@ -17,7 +17,6 @@ import string
class Core(): class Core():
def __init__(self): def __init__(self):
self.FFMPEG_BIN = self.findFfmpeg()
self.dataDir = QStandardPaths.writableLocation( self.dataDir = QStandardPaths.writableLocation(
QStandardPaths.AppConfigLocation QStandardPaths.AppConfigLocation
) )
@ -63,6 +62,7 @@ class Core():
'*.xpm', '*.xpm',
]) ])
self.FFMPEG_BIN = self.findFfmpeg()
self.findComponents() self.findComponents()
self.selectedComponents = [] self.selectedComponents = []
# copies of named presets to detect modification # copies of named presets to detect modification
@ -437,15 +437,23 @@ class Core():
self.encoder_options = json.load(json_file) self.encoder_options = json.load(json_file)
def findFfmpeg(self): def findFfmpeg(self):
if sys.platform == "win32": if getattr(sys, 'frozen', False):
return "ffmpeg.exe" # 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: else:
try: if sys.platform == "win32":
with open(os.devnull, "w") as f: return "ffmpeg.exe"
sp.check_call(['ffmpeg', '-version'], stdout=f, stderr=f) else:
return "ffmpeg" try:
except: with open(os.devnull, "w") as f:
return "avconv" sp.check_call(['ffmpeg', '-version'], stdout=f, stderr=f)
return "ffmpeg"
except:
return "avconv"
def readAudioFile(self, filename, parent): def readAudioFile(self, filename, parent):
command = [self.FFMPEG_BIN, '-i', filename] command = [self.FFMPEG_BIN, '-i', filename]

View File

@ -1,4 +1,4 @@
from PyQt5 import QtGui, uic, QtWidgets from PyQt5 import uic, QtWidgets
import sys import sys
import os import os