From 5b810fed99afa514568c386ad82b71e75e01df36 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 2 Jun 2017 12:48:27 -0700 Subject: [PATCH] build: create standalone binary with WinPython Recent changes for building standalone dvc binary on Linux made it possible to do the same thing on Windows. So now we are getting rid of WinPython and instead building standalone dvc binary using PyInstall and packaing it into an installer with InnoSetup. One of the benefits is dramatically decreased installer size. From 125M we got to only 13M! Signed-off-by: Ruslan Kuprieiev --- .gitignore | 4 ++++ build.cmd | 45 ----------------------------------------- build_windows.cmd | 35 ++++++++++++++++++++++++++++++++ innosetup/config_gen.py | 2 +- innosetup/dvc.bat | 2 -- innosetup/setup.iss | 6 ++---- 6 files changed, 42 insertions(+), 52 deletions(-) delete mode 100644 build.cmd create mode 100644 build_windows.cmd delete mode 100644 innosetup/dvc.bat diff --git a/.gitignore b/.gitignore index 315af31ca..4d4c11d2f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ hooks/*.pyc *.rpm *.deb + +innosetup/config.ini + +*.exe diff --git a/build.cmd b/build.cmd deleted file mode 100644 index b57180cc8..000000000 --- a/build.cmd +++ /dev/null @@ -1,45 +0,0 @@ -@echo OFF - -echo ====== Starting to build dvc installer for Windows... ====== - -rmdir /Q /S dist -rmdir /Q /S WinPython -del /Q /S "dvc-*.exe" - -if not exist WinPython-64bit-3.6.1.0Zero.exe (echo Error: Couldn't find WinPython installer. Please go to winpython.github.io, download WinPython-64bit-3.6.1.0Zero.exe and place it in project's root directory && goto:error) - -if not exist "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" (echo Error: Couldn't find Inno Setup compiler. Please go to jrsoftware.org/isinfo.php and install Inno Setup 5 && goto:error) - -echo ====== Installing WinPython... ====== -call .\WinPython-64bit-3.6.1.0Zero.exe /S /D=%cd%\WinPython || goto :error - -echo ====== Copying additional files... ====== -copy innosetup\addSymLinkPermissions.ps1 WinPython\ || goto :error -mkdir Winpython\bin || goto :error -copy innosetup\dvc.bat WinPython\bin || goto :error - -echo ====== Installing requirements... ====== -cd WinPython || goto :error -call scripts\python -m pip install -r ..\requirements.txt || goto :error -cd .. || goto :error - -echo ====== Building dvc sdist... ====== -call WinPython\scripts\python setup.py sdist || goto :error - -echo ====== Installing dvc sdist into WinPython... ====== -cd WinPython || goto :error -for %%s in ("..\dist\dvc-*.tar.gz") do call scripts\python -m pip install "%%s" || goto :error -cd .. || goto :error - -echo ====== Building dvc installer... ====== -cd innosetup || goto :error -call ..\WinPython\scripts\python config_gen.py || goto :error -cd .. || goto :error -call "C:\Program Files (x86)\Inno Setup 5\iscc" innosetup\setup.iss || goto :error - -echo ====== DONE ====== -goto :EOF - -:error -echo ====== FAIL ====== -exit /b 1 diff --git a/build_windows.cmd b/build_windows.cmd new file mode 100644 index 000000000..9aeafadea --- /dev/null +++ b/build_windows.cmd @@ -0,0 +1,35 @@ +@echo Off + +echo ====== Starting to build dvc installer for Windows... ====== + +rmdir /Q /S build +rmdir /Q /S dist +del /Q /S dvc.spec +del /Q /S "dvc-*.exe" + +where pip +if %errorlevel% neq 0 (echo Error: pip not found && goto :error) + +if not exist "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" (echo Error: Couldn't find Inno Setup compiler. Please go to jrsoftware.org/isinfo.php and install Inno Setup 5 && goto :error) + +echo ====== Installing requirements... ====== +call pip install -r requirements.txt || goto :error +call pip install pyinstaller || goto :error + +echo ====== Building dvc binary... ====== +call pyinstaller --onefile --additional-hooks-dir hooks dvc/__main__.py --name dvc --specpath build + +echo ====== Copying additional files... ====== +copy innosetup\addSymLinkPermissions.ps1 dist\ || goto :error + +echo ====== Building dvc installer... ====== +set PYTHONPATH=%cd% +call python innosetup\config_gen.py || goto :error +call "C:\Program Files (x86)\Inno Setup 5\iscc" innosetup\setup.iss || goto :error + +echo ====== DONE ====== +goto :EOF + +:error +echo ====== FAIL ====== +exit /b 1 diff --git a/innosetup/config_gen.py b/innosetup/config_gen.py index 5ccd0f3ba..65d17622e 100644 --- a/innosetup/config_gen.py +++ b/innosetup/config_gen.py @@ -10,5 +10,5 @@ config = ConfigParser.ConfigParser() config.add_section('Version') config.set('Version', 'Version', VERSION) -with open('config.ini', 'w') as f: +with open('innosetup/config.ini', 'w') as f: config.write(f) diff --git a/innosetup/dvc.bat b/innosetup/dvc.bat deleted file mode 100644 index 380634268..000000000 --- a/innosetup/dvc.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -call "%~dp0..\python-3.6.1.amd64\python" -m dvc %* diff --git a/innosetup/setup.iss b/innosetup/setup.iss index 0cc28b51b..4abf7daaa 100644 --- a/innosetup/setup.iss +++ b/innosetup/setup.iss @@ -1,10 +1,8 @@ #define MyAppName "Data Version Control" -; FIXME: Hardcoded version is not nice, but will do for now. #define MyAppVersion ReadIni(".\innosetup\config.ini", "Version", "version", "unknown") #define MyAppPublisher "Dmitry Petrov" #define MyAppURL "https://dataversioncontrol.com/" -;#define MyAppExeName "dvc.exe" -#define MyAppDir "..\WinPython" +#define MyAppDir "..\dist" [Setup] AppId={{8258CE8A-110E-4E0D-AE60-FEE00B15F041} @@ -39,7 +37,7 @@ Name: addsymlinkpermissions\system; Description: Add permissions for creating sy [Code] const ModPathName = 'modifypath'; - ModPathPath = '{app}\bin'; + ModPathPath = '{app}'; SymLinkName = 'addsymlinkpermissions'; var