Add preliminary support of PyInstaller on AppVeyor

This commit is contained in:
Alberto Sottile 2018-04-26 23:34:09 +02:00
parent bac3cf9a7f
commit 4fb771a450
6 changed files with 83 additions and 14 deletions

View File

@ -12,7 +12,7 @@ init:
- conda install python=3.5 -y
- conda install pywin32 -y
- conda install -c conda-forge pyside2 -y
- pip install twisted py2exe zope.interface
- pip install twisted pyinstaller zope.interface
- type nul > C:\Miniconda\envs\syncplay\lib\site-packages\zope\__init__.py
- pip freeze
- conda list
@ -20,25 +20,22 @@ init:
install:
- cd %APPVEYOR_BUILD_FOLDER%
- for /F "tokens=2 delims='" %%a in ('findstr version syncplay\__init__.py') do @set ver=%%a
- python buildPy2exe.py
- del syncplay_v%ver%\lib\api-*
- del syncplay_v%ver%\lib\DNSAPI.dll
- del syncplay_v%ver%\lib\IPHLPAPI.dll
- del syncplay_v%ver%\lib\MPR.dll
- mkdir syncplay_v%ver%\platforms
- copy C:\Miniconda\envs\syncplay\library\plugins\platforms\qwindows.dll syncplay_v%ver%\platforms\
- copy Syncplay-%ver%-Setup.exe Syncplay-%ver%-Setup-Py3-PySide2.exe
- pyinstaller pyinstaller-onefile.spec
- move dist\Syncplay.exe Syncplay-%ver%-win-Py3-PySide2.exe
- del build /s /Q
- del dist /s /Q
- pyinstaller pyinstaller-onedir.spec
# Not a project with an msbuild file, build done at install.
build: off
artifacts:
- path: 'syncplay_v$(ver)'
- path: 'dist'
type: zip
name: Syncplay-$(ver)-win-py3-pyside2
- path: Syncplay-$(ver)-Setup-Py3-PySide2.exe
name: Syncplay-$(ver)-win-setup-py3-pyside2
- path: Syncplay-$(ver)-win-Py3-PySide2.exe
name: Syncplay-$(ver)-win-py3-pyside2
# Push artefact to S3 bucket and list all
before_deploy:

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ dist.7z
.*
!.travis.yml
!.appveyor.yml
__pycache__

34
pyinstaller-onedir.spec Executable file
View File

@ -0,0 +1,34 @@
# -*- mode: python -*-
block_cipher = None
a = Analysis(['syncplayClient.py'],
pathex=['C:\\Users\\Alberto\\Documents\\syncplay-py3-qtpy-pyside2'],
binaries=[],
datas=[('resources/*', 'resources')],
hiddenimports=['PySide2', 'PySide2.QtCore', 'PySide2.QtWidgets'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Syncplay',
debug=False,
strip=False,
upx=True,
console=False,
icon='resources/icon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='Syncplay')

30
pyinstaller-onefile.spec Executable file
View File

@ -0,0 +1,30 @@
# -*- mode: python -*-
block_cipher = None
a = Analysis(['syncplayClient.py'],
pathex=['C:\\Users\\Alberto\\Documents\\syncplay-py3-qtpy-pyside2'],
binaries=[],
datas=[('resources/*', 'resources')],
hiddenimports=['PySide2', 'PySide2.QtCore', 'PySide2.QtWidgets'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Syncplay',
debug=False,
strip=False,
upx=False,
runtime_tmpdir=None,
console=False,
icon='resources/icon.ico')

View File

@ -373,7 +373,10 @@ class VlcPlayer(BasePlayer):
self.__playerController.drop(getMessage("vlc-interface-version-mismatch").format(self.oldIntfVersion,constants.VLC_INTERFACE_MIN_VERSION))
else:
self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None: #Needed for pyinstaller --onefile bundle
self.__process = subprocess.Popen(call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=False, creationflags=0x08000000)
else:
self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
self.timeVLCLaunched = time.time()
if self._shouldListenForSTDOUT():
for line in iter(self.__process.stderr.readline, ''):

View File

@ -143,12 +143,16 @@ def findWorkingDir():
path = os.path.dirname(os.path.dirname(__file__))
elif frozen in ('dll', 'console_exe', 'windows_exe', 'macosx_app'):
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
elif frozen: #needed for PyInstaller
if getattr(sys, '_MEIPASS', '') is not None:
path = getattr(sys, '_MEIPASS', '') #--onefile
else:
path = os.path.dirname(sys.executable) #--onedir
else:
path = ""
return path
def getResourcesPath():
if isWindows():
return findWorkingDir() + "\\resources\\"
else: