_build_python_32bit.bat 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. @echo off
  2. REM Copyright (C) 1994-2017 Altair Engineering, Inc.
  3. REM For more information, contact Altair at www.altair.com.
  4. REM
  5. REM This file is part of the PBS Professional ("PBS Pro") software.
  6. REM
  7. REM Open Source License Information:
  8. REM
  9. REM PBS Pro is free software. You can redistribute it and/or modify it under the
  10. REM terms of the GNU Affero General Public License as published by the Free
  11. REM Software Foundation, either version 3 of the License, or (at your option) any
  12. REM later version.
  13. REM
  14. REM PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  15. REM WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  16. REM PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
  17. REM
  18. REM You should have received a copy of the GNU Affero General Public License along
  19. REM with this program. If not, see <http://www.gnu.org/licenses/>.
  20. REM
  21. REM Commercial License Information:
  22. REM
  23. REM The PBS Pro software is licensed under the terms of the GNU Affero General
  24. REM Public License agreement ("AGPL"), except where a separate commercial license
  25. REM agreement for PBS Pro version 14 or later has been executed in writing with Altair.
  26. REM
  27. REM Altair’s dual-license business model allows companies, individuals, and
  28. REM organizations to create proprietary derivative works of PBS Pro and distribute
  29. REM them - whether embedded or bundled with other software - under a commercial
  30. REM license agreement.
  31. REM
  32. REM Use of Altair’s trademarks, including but not limited to "PBS™",
  33. REM "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  34. REM trademark licensing policies.
  35. @echo on
  36. setlocal
  37. call "%~dp0set_paths.bat" %~1
  38. cd "%BINARIESDIR%"
  39. if not defined PYTHON_VERSION (
  40. echo "Please set PYTHON_VERSION to Python version!"
  41. exit /b 1
  42. )
  43. if exist "%BINARIESDIR%\python" (
  44. echo "%BINARIESDIR%\python exist already!"
  45. exit /b 0
  46. )
  47. if not exist "%BINARIESDIR%\cpython-%PYTHON_VERSION%.zip" (
  48. "%CURL_BIN%" -qkL -o "%BINARIESDIR%\cpython-%PYTHON_VERSION%.zip" https://github.com/python/cpython/archive/v%PYTHON_VERSION%.zip
  49. if not exist "%BINARIESDIR%\cpython-%PYTHON_VERSION%.zip" (
  50. echo "Failed to download python"
  51. exit /b 1
  52. )
  53. )
  54. 2>nul rd /S /Q "%BINARIESDIR%\cpython-%PYTHON_VERSION%"
  55. "%UNZIP_BIN%" -q "%BINARIESDIR%\cpython-%PYTHON_VERSION%.zip"
  56. cd "%BINARIESDIR%\cpython-%PYTHON_VERSION%"
  57. REM Restore externals directory if python_externals.tar.gz exists
  58. if exist "%BINARIESDIR%\python_externals.tar.gz" (
  59. if not exist "%BINARIESDIR%\cpython-%PYTHON_VERSION%\externals" (
  60. "%MSYSDIR%\bin\bash" --login -i -c "cd \"$BINARIESDIR_M/cpython-$PYTHON_VERSION\" && tar -xf \"$BINARIESDIR_M/python_externals.tar.gz\""
  61. )
  62. )
  63. call "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PCbuild\env.bat" x86
  64. call "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PC\VS9.0\build.bat" -e
  65. if not %ERRORLEVEL% == 0 (
  66. echo "Failed to compile Python 32bit"
  67. exit /b 1
  68. )
  69. REM Workaround for cabarc.exe, required by msi.py
  70. if not exist "%BINARIESDIR%\cabarc.exe" (
  71. if not exist "%BINARIESDIR%\supporttools.exe" (
  72. "%CURL_BIN%" -qkL -o "%BINARIESDIR%\supporttools.exe" http://download.microsoft.com/download/d/3/8/d38066aa-4e37-4ae8-bce3-a4ce662b2024/WindowsXP-KB838079-SupportTools-ENU.exe
  73. if not exist "%BINARIESDIR%\supporttools.exe" (
  74. echo "Failed to download supporttools.exe"
  75. exit /b 1
  76. )
  77. )
  78. 2>nul rd /S /Q "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  79. mkdir "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  80. "%BINARIESDIR%\supporttools.exe" /C /T:"%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  81. expand "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp\support.cab" -F:cabarc.exe "%BINARIESDIR%"
  82. )
  83. set PATH=%BINARIESDIR%;%PATH%
  84. REM Workaround for python2713.chm
  85. mkdir "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Doc\build\htmlhelp"
  86. echo "dummy chm file to make msi.py happy" > "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Doc\build\htmlhelp\python%PYTHON_VERSION:.=%.chm"
  87. cd PC
  88. nmake /f "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PC\icons.mak"
  89. if not %ERRORLEVEL% == 0 (
  90. echo "Failed to build icons for Python 32bit"
  91. exit /b 1
  92. )
  93. cd "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi"
  94. set PCBUILD=PC\VS9.0
  95. set SNAPSHOT=0
  96. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" -m ensurepip -U --default-pip
  97. if not %ERRORLEVEL% == 0 (
  98. echo "Failed to run ensurepip for Python 32bit"
  99. exit /b 1
  100. )
  101. set PIP_EXTRA_ARGS=
  102. if exist "%BINARIESDIR%\pypiwin32-219-cp27-none-win32.whl" (
  103. set PIP_EXTRA_ARGS=--no-index --find-links="%BINARIESDIR%" --no-cache-dir
  104. )
  105. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" -m pip install %PIP_EXTRA_ARGS% pypiwin32==219
  106. if not %ERRORLEVEL% == 0 (
  107. echo "Failed to install pypiwin32 for Python 32bit"
  108. exit /b 1
  109. )
  110. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" msi.py
  111. if not exist "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi\python-%PYTHON_VERSION%150.msi" (
  112. echo "Failed to generate msi Python 32bit"
  113. exit /b 1
  114. )
  115. start /wait msiexec /qn /a "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi\python-%PYTHON_VERSION%150.msi" TARGETDIR="%BINARIESDIR%\python"
  116. if not %ERRORLEVEL% == 0 (
  117. echo "Failed to extract msi Python 32bit to %BINARIESDIR%\python"
  118. exit /b 1
  119. )
  120. "%BINARIESDIR%\python\python.exe" -Wi "%BINARIESDIR%\python\Lib\compileall.py" -q -f -x "bad_coding|badsyntax|site-packages|py3_" "%BINARIESDIR%\python\Lib"
  121. "%BINARIESDIR%\python\python.exe" -O -Wi "%BINARIESDIR%\python\Lib\compileall.py" -q -f -x "bad_coding|badsyntax|site-packages|py3_" "%BINARIESDIR%\python\Lib"
  122. "%BINARIESDIR%\python\python.exe" -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
  123. "%BINARIESDIR%\python\python.exe" -m ensurepip -U --default-pip
  124. if not %ERRORLEVEL% == 0 (
  125. echo "Failed to run ensurepip in %BINARIESDIR%\python for Python 32bit"
  126. exit /b 1
  127. )
  128. "%BINARIESDIR%\python\python.exe" -m pip install %PIP_EXTRA_ARGS% pypiwin32==219
  129. if not %ERRORLEVEL% == 0 (
  130. echo "Failed to install pypiwin32 in %BINARIESDIR%\python for Python 32bit"
  131. exit /b 1
  132. )
  133. copy /B /Y "%VS90COMNTOOLS%..\..\VC\redist\amd64\Microsoft.VC90.CRT\msvcr90.dll" "%BINARIESDIR%\python\"
  134. if not %ERRORLEVEL% == 0 (
  135. echo "Failed to copy msvcr90.dll in %BINARIESDIR%\python for Python 32bit"
  136. exit /b 1
  137. )
  138. copy /B /Y "%VS90COMNTOOLS%..\..\VC\redist\amd64\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest" "%BINARIESDIR%\python\"
  139. if not %ERRORLEVEL% == 0 (
  140. echo "Failed to copy Microsoft.VC90.CRT.manifest in %BINARIESDIR%\python for Python 32bit"
  141. exit /b 1
  142. )
  143. cd "%BINARIESDIR%"
  144. 2>nul rd /S /Q "%BINARIESDIR%\cpython-%PYTHON_VERSION%"
  145. 2>nul del /Q /F "%BINARIESDIR%\cabarc.exe"
  146. exit /b 0