Skip to content

Commit

Permalink
Add preliminary support of PyInstaller on AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
albertosottile committed Apr 26, 2018
1 parent bac3cf9 commit 4fb771a
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 14 deletions.
21 changes: 9 additions & 12 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@ 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

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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dist.7z
.*
!.travis.yml
!.appveyor.yml
__pycache__
34 changes: 34 additions & 0 deletions pyinstaller-onedir.spec
Original file line number Diff line number Diff line change
@@ -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 changes: 30 additions & 0 deletions pyinstaller-onefile.spec
Original file line number Diff line number Diff line change
@@ -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')
5 changes: 4 additions & 1 deletion syncplay/players/vlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
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, ''):
Expand Down
6 changes: 5 additions & 1 deletion syncplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4fb771a

Please sign in to comment.