Example Batch Script for PyInstaller

For someone used to unix environment, Windows batch script can be a little bit confuse. Bellow I provide an example to invoke pyInstaller as a batch.

set "WINPYDIR=C:\Users\test\Python\WinPython-32bit-3.4.3.7\python-3.4.3"
set "WINPYVER=3.4.3.7"
set "HOME=%WINPYDIR%\..\settings"
set "WINPYARCH=WIN32"

set "PATH=%WINPYDIR%\Lib\site-packages\PyQt4;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\tools;"

rem keep nbextensions in Winpython directory, rather then %APPDATA% default
set "JUPYTER_DATA_DIR=%WINPYDIR%\..\settings"

rem project settings
set "PROJECTNAME=TestProject"
set "BUILDSETTINGSDIR=%WORKSPACE%\build_settings\win"
set "MAINSCRIPT=%WORKSPACE%\testproject\__main__.py"
set "BUILDOUTDIR=%WORKSPACE%\build"
set "DISTOUTDIR=%WORKSPACE%\dist"
set "ICONPATH=%BUILDSETTINGSDIR%\icon_128x128.ico"

rem echo %WORKSPACE%
rem echo %PROJECTNAME%
rem echo %BUILDSETTINGSDIR%
rem echo %MAINSCRIPT%
rem echo %BUILDOUTDIR%
rem echo %DISTOUTDIR%

@RD /S /Q %BUILDOUTDIR%
@RD /S /Q %DISTOUTDIR%

python setup.py sdist

pyinstaller --additional-hooks-dir "%BUILDSETTINGSDIR%\hooks" --name %PROJECTNAME% --icon "%ICONPATH%" --debug --onefile "%MAINSCRIPT%"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s