From f12fbffae026a6cbf6d36a56fe5773f1e0ed4732 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Tue, 11 Sep 2018 17:21:40 +0200 Subject: win build: Remove py2exe support Signed-off-by: Michael Buesch --- maintenance/win-standalone-build.cmd | 262 ++++++++++++++++------------------- 1 file changed, 122 insertions(+), 140 deletions(-) diff --git a/maintenance/win-standalone-build.cmd b/maintenance/win-standalone-build.cmd index bcaa1724..9acabeb8 100644 --- a/maintenance/win-standalone-build.cmd +++ b/maintenance/win-standalone-build.cmd @@ -1,4 +1,23 @@ @echo off +rem +rem AWL simulator - Windows frozen package build script +rem +rem Copyright 2012-2018 Michael Buesch +rem +rem This program is free software; you can redistribute it and/or modify +rem it under the terms of the GNU General Public License as published by +rem the Free Software Foundation; either version 2 of the License, or +rem (at your option) any later version. +rem +rem This program is distributed in the hope that it will be useful, +rem but WITHOUT ANY WARRANTY; without even the implied warranty of +rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +rem GNU General Public License for more details. +rem +rem You should have received a copy of the GNU General Public License along +rem with this program; if not, write to the Free Software Foundation, Inc., +rem 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +rem setlocal ENABLEDELAYEDEXPANSION set project=awlsim @@ -8,14 +27,12 @@ for /D %%f in ( "C:\PYTHON*" ) do set PATH=!PATH!;%%f for /D %%f in ( "%USERPROFILE%\AppData\Local\Programs\Python\Python*" ) do set PATH=!PATH!;%%f;%%f\Scripts set PATH=%PATH%;%ProgramFiles%\7-Zip + cd .. if ERRORLEVEL 1 goto error_basedir -py -c "from awlsim.common.version import VERSION_STRING; print(VERSION_STRING)" > version.txt -if ERRORLEVEL 1 goto error_version -set /p version= < version.txt -del version.txt +call :detect_version if "%PROCESSOR_ARCHITECTURE%" == "x86" ( set winprefix=win32 ) else ( @@ -30,165 +47,130 @@ set licensedirname=licenses set licensedir=%distdir%\%licensedirname% -echo Building standalone Windows executable for %project% v%version%... -echo. +echo Building standalone Windows executable for %project%-%version% -echo Please select GUI framework: -echo 1) Build with PyQt5 (default) -echo 2) Build with PySide4 -set /p framework=Selection: -if "%framework%" == "" goto framework_pyqt5 -if "%framework%" == "1" goto framework_pyqt5 -if "%framework%" == "2" goto framework_pyside4 -echo "Error: Invalid selection" -goto error +call :select_buildcython +call :prepare_env +call :build_cxfreeze +call :copy_files +call :gen_startup_wrapper +call :make_archive + +echo --- +echo finished +pause +exit /B 0 -:framework_pyqt5 -echo Using PyQt5 -set excludes=PySide -goto select_buildcython -:framework_pyside4 -echo Using PySide4 -set excludes=PyQt5 -goto select_buildcython +:detect_version + py -c "from awlsim.common.version import VERSION_STRING; print(VERSION_STRING)" > version.txt + if ERRORLEVEL 1 goto error_version + set /p version= < version.txt + del version.txt + exit /B 0 :select_buildcython -echo. -echo Build optimized Cython modules? -echo 1) Do not build Cython modules (default) -echo 2) Build Cython modules -set /p buildcython=Selection: -if "%buildcython%" == "" goto buildcython_no -if "%buildcython%" == "1" goto buildcython_no -if "%buildcython%" == "2" goto buildcython_yes -echo "Error: Invalid selection" -goto error + echo. + echo Build optimized Cython modules? + echo 1) Do not build Cython modules (default) + echo 2) Build Cython modules + set /p buildcython=Selection: + if "%buildcython%" == "" goto buildcython_no + if "%buildcython%" == "1" goto buildcython_no + if "%buildcython%" == "2" goto buildcython_yes + echo "Error: Invalid selection" + goto error + + :buildcython_yes + echo Building Cython modules + set AWLSIM_CYTHON_BUILD=1 + exit /B 0 + + :buildcython_no + echo Not building Cython modules + set AWLSIM_CYTHON_BUILD=0 + exit /B 0 -:buildcython_yes -echo Building Cython modules -set AWLSIM_CYTHON_BUILD=1 -goto select_freezer - -:buildcython_no -echo Not building Cython modules -set AWLSIM_CYTHON_BUILD=0 -goto select_freezer - - -:select_freezer -echo. -echo Please select freezer: -echo 1) Build 'cx_Freeze' based distribution (default) -echo 2) Build 'py2exe' based distribution -set /p buildtype=Selection: -if "%buildtype%" == "" goto build_cxfreeze -if "%buildtype%" == "1" goto build_cxfreeze -if "%buildtype%" == "2" goto build_py2exe -echo "Error: Invalid selection" -goto error + +:prepare_env + echo === Preparing distribution environment + rd /S /Q build 2>NUL + rd /S /Q %distdir% 2>NUL + del %sfxfile% 2>NUL + timeout /T 2 /NOBREAK >NUL + mkdir %distdir% + if ERRORLEVEL 1 goto error_prep + mkdir %bindir% + if ERRORLEVEL 1 goto error_prep + exit /B 0 :build_cxfreeze -set buildtype=1 -echo === Creating the cx_Freeze distribution -call :prepare_env -py setup.py ^ - build ^ - --build-base=%builddir% ^ - build_exe ^ - --build-exe=%bindir% -if ERRORLEVEL 1 goto error_exe -goto copy_files - - -:build_py2exe -set buildtype=2 -echo === Creating the py2exe distribution -call :prepare_env -py setup.py py2exe ^ - --dist-dir=%bindir% ^ - --bundle-files=3 ^ - --ignores=win32api,win32con,readline,awlsim_cython ^ - --excludes=%excludes% ^ - --packages=awlsimhw_debug,awlsimhw_dummy,awlsimhw_linuxcnc,awlsimhw_pyprofibus,awlsimhw_rpigpio,awlsimhw_pixtend,awlsim.library.iec ^ - --quiet -if ERRORLEVEL 1 goto error_exe -goto copy_files + echo === Creating the cx_Freeze distribution + py setup.py ^ + build ^ + --build-base=%builddir% ^ + build_exe ^ + --build-exe=%bindir% + if ERRORLEVEL 1 goto error_exe + exit /B 0 :copy_files -echo === Copying additional files -if %AWLSIM_CYTHON_BUILD% NEQ 0 ( - rem Copy Cython modules from builddir to bindir - for /D %%f in ( "%builddir%\lib*" ) do ( - for /D %%i in ( "%%f\*_cython" ) do ( - xcopy /E /I %%i %bindir%\lib\%%~ni - if ERRORLEVEL 1 goto error_copy + echo === Copying additional files + if %AWLSIM_CYTHON_BUILD% NEQ 0 ( + rem Copy Cython modules from builddir to bindir + for /D %%f in ( "%builddir%\lib*" ) do ( + for /D %%i in ( "%%f\*_cython" ) do ( + xcopy /E /I %%i %bindir%\lib\%%~ni + if ERRORLEVEL 1 goto error_copy + ) ) ) -) -mkdir %licensedir% -if ERRORLEVEL 1 goto error_copy -copy examples\*.awlpro %distdir%\ -if ERRORLEVEL 1 goto error_copy -copy *.html %distdir%\ -if ERRORLEVEL 1 goto error_copy -xcopy /E /I doc %distdir%\doc -if ERRORLEVEL 1 goto error_copy -rmdir /S /Q %distdir%\doc\foreign-licenses -if ERRORLEVEL 1 goto error_copy -copy doc\foreign-licenses\*.txt %licensedir%\ -if ERRORLEVEL 1 goto error_copy -copy COPYING.txt %licensedir%\AWLSIM-LICENSE.txt -if ERRORLEVEL 1 goto error_copy -for /D %%f in ( "progs\putty\*" ) do ( - copy %%f\putty\PUTTY.EXE %bindir%\ + mkdir %licensedir% if ERRORLEVEL 1 goto error_copy - copy %%f\putty\PLINK.EXE %bindir%\ + copy examples\*.awlpro %distdir%\ if ERRORLEVEL 1 goto error_copy - copy %%f\LICENCE %licensedir%\PUTTY-LICENSE.txt + copy *.html %distdir%\ if ERRORLEVEL 1 goto error_copy -) -if %buildtype% == 1 goto no_servermod_rename -move %bindir%\server.exe %bindir%\awlsim-server-module.exe -if ERRORLEVEL 1 goto error_copy -:no_servermod_rename -rd /S /Q %builddir% -if ERRORLEVEL 1 goto error_copy - - -echo === Generating startup wrapper -set wrapper=%distdir%\%project%.cmd -echo @set PATH=%bindirname%;%bindirname%\lib;%bindirname%\platforms;%bindirname%\imageformats;%%PATH%%> %wrapper% -echo @set AWLSIM_CYTHON=1 >> %wrapper% -echo @start %project%-bin\awlsim-gui.exe %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9>> %wrapper% -if ERRORLEVEL 1 goto error_wrapper - + xcopy /E /I doc %distdir%\doc + if ERRORLEVEL 1 goto error_copy + rmdir /S /Q %distdir%\doc\foreign-licenses + if ERRORLEVEL 1 goto error_copy + copy doc\foreign-licenses\*.txt %licensedir%\ + if ERRORLEVEL 1 goto error_copy + copy COPYING.txt %licensedir%\AWLSIM-LICENSE.txt + if ERRORLEVEL 1 goto error_copy + for /D %%f in ( "progs\putty\*" ) do ( + copy %%f\putty\PUTTY.EXE %bindir%\ + if ERRORLEVEL 1 goto error_copy + copy %%f\putty\PLINK.EXE %bindir%\ + if ERRORLEVEL 1 goto error_copy + copy %%f\LICENCE %licensedir%\PUTTY-LICENSE.txt + if ERRORLEVEL 1 goto error_copy + ) + rd /S /Q %builddir% + if ERRORLEVEL 1 goto error_copy + exit /B 0 -echo === Creating the distribution archive -7z a -mx=9 -sfx7z.sfx %sfxfile% %distdir% -if ERRORLEVEL 1 goto error_7z +:gen_startup_wrapper + echo === Generating startup wrapper + set wrapper=%distdir%\%project%.cmd + echo @set PATH=%bindirname%;%bindirname%\lib;%bindirname%\platforms;%bindirname%\imageformats;%%PATH%% > %wrapper% + echo @set AWLSIM_CYTHON=%AWLSIM_CYTHON_BUILD% >> %wrapper% + echo @start %project%-bin\awlsim-gui.exe %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> %wrapper% + if ERRORLEVEL 1 goto error_wrapper + exit /B 0 -echo --- -echo finished -pause -exit /B 0 +:make_archive + echo === Creating the distribution archive + 7z a -mx=9 -sfx7z.sfx %sfxfile% %distdir% + if ERRORLEVEL 1 goto error_7z + exit /B 0 -:prepare_env -echo === Preparing distribution environment -rd /S /Q build 2>NUL -rd /S /Q %distdir% 2>NUL -del %sfxfile% 2>NUL -timeout /T 2 /NOBREAK >NUL -mkdir %distdir% -if ERRORLEVEL 1 goto error_prep -mkdir %bindir% -if ERRORLEVEL 1 goto error_prep -exit /B 0 :error_basedir echo FAILED to CD to base directory -- cgit v1.2.3