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__
settings.ini
build/*
env/*
.vscode/*
*.mkv
*.mp4
*.zip
*.tar
*.tar.*
*.exe
ffmpeg

View File

@ -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

View File

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

View File

@ -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()

View File

@ -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]

View File

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