_build_python_64bit.bat 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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_x64" (
  44. echo "%BINARIESDIR%\python_x64 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. ) else (
  63. call "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PCbuild\get_externals.bat"
  64. )
  65. REM workaround to openssl build fail
  66. 2>nul del /Q /F "%BINARIESDIR%\cpython-%PYTHON_VERSION%\externals\openssl-1.0.2j\ms\nt64.mak"
  67. if exist "%VS90COMNTOOLS%..\..\VC\bin\amd64\vcvarsamd64.bat" (
  68. call "%VS90COMNTOOLS%..\..\VC\bin\amd64\vcvarsamd64.bat"
  69. ) else if exist "%VS90COMNTOOLS%..\..\VC\bin\vcvarsx86_amd64.bat" (
  70. call "%VS90COMNTOOLS%..\..\VC\bin\vcvarsx86_amd64.bat"
  71. ) else (
  72. echo "Could not find x64 build tools for Visual Studio"
  73. exit /b 1
  74. )
  75. call "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PC\VS9.0\build.bat" -e -p x64
  76. if not %ERRORLEVEL% == 0 (
  77. echo "Failed to compile Python 64bit"
  78. exit /b 1
  79. )
  80. REM Workaround for cabarc.exe, required by msi.py
  81. if not exist "%BINARIESDIR%\cabarc.exe" (
  82. if not exist "%BINARIESDIR%\supporttools.exe" (
  83. "%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
  84. if not exist "%BINARIESDIR%\supporttools.exe" (
  85. echo "Failed to download supporttools.exe"
  86. exit /b 1
  87. )
  88. )
  89. 2>nul rd /S /Q "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  90. mkdir "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  91. "%BINARIESDIR%\supporttools.exe" /C /T:"%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp"
  92. expand "%BINARIESDIR%\cpython-%PYTHON_VERSION%\cabarc_temp\support.cab" -F:cabarc.exe "%BINARIESDIR%"
  93. )
  94. set PATH=%BINARIESDIR%;%PATH%
  95. REM Workaround for python2713.chm
  96. mkdir "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Doc\build\htmlhelp"
  97. echo "dummy chm file to make msi.py happy" > "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Doc\build\htmlhelp\python%PYTHON_VERSION:.=%.chm"
  98. cd PC
  99. REM we need 32bit compiler as python icons does not compile in 64bit
  100. call "%VS90COMNTOOLS%vsvars32.bat"
  101. nmake /f "%BINARIESDIR%\cpython-%PYTHON_VERSION%\PC\icons.mak"
  102. if not %ERRORLEVEL% == 0 (
  103. echo "Failed to build icons for Python 64bit"
  104. exit /b 1
  105. )
  106. REM Restore back 64 bit compiler
  107. if exist "%VS90COMNTOOLS%..\..\VC\bin\amd64\vcvarsamd64.bat" (
  108. call "%VS90COMNTOOLS%..\..\VC\bin\amd64\vcvarsamd64.bat"
  109. ) else if exist "%VS90COMNTOOLS%..\..\VC\bin\vcvarsx86_amd64.bat" (
  110. call "%VS90COMNTOOLS%..\..\VC\bin\vcvarsx86_amd64.bat"
  111. ) else (
  112. echo "Could not find x64 build tools for Visual Studio"
  113. exit /b 1
  114. )
  115. cd "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi"
  116. set PCBUILD=PC\VS9.0\amd64
  117. set SNAPSHOT=0
  118. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" -m ensurepip -U --default-pip
  119. if not %ERRORLEVEL% == 0 (
  120. echo "Failed to run ensurepip for Python 64bit"
  121. exit /b 1
  122. )
  123. set PIP_EXTRA_ARGS=
  124. if exist "%BINARIESDIR%\pypiwin32-219-cp27-none-win_amd64.whl" (
  125. set PIP_EXTRA_ARGS=--no-index --find-links="%BINARIESDIR%" --no-cache-dir
  126. )
  127. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" -m pip install %PIP_EXTRA_ARGS% pypiwin32==219
  128. if not %ERRORLEVEL% == 0 (
  129. echo "Failed to install pypiwin32 for Python 64bit"
  130. exit /b 1
  131. )
  132. "%BINARIESDIR%\cpython-%PYTHON_VERSION%\%PCBUILD%\python.exe" msi.py
  133. if not exist "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi\python-%PYTHON_VERSION%150.amd64.msi" (
  134. echo "Failed to generate msi Python 64bit"
  135. exit /b 1
  136. )
  137. start /wait msiexec /qn /a "%BINARIESDIR%\cpython-%PYTHON_VERSION%\Tools\msi\python-%PYTHON_VERSION%150.amd64.msi" TARGETDIR="%BINARIESDIR%\python_x64"
  138. if not %ERRORLEVEL% == 0 (
  139. echo "Failed to extract msi Python 64bit to %BINARIESDIR%\python_x64"
  140. exit /b 1
  141. )
  142. "%BINARIESDIR%\python_x64\python.exe" -Wi "%BINARIESDIR%\python_x64\Lib\compileall.py" -q -f -x "bad_coding|badsyntax|site-packages|py3_" "%BINARIESDIR%\python_x64\Lib"
  143. "%BINARIESDIR%\python_x64\python.exe" -O -Wi "%BINARIESDIR%\python_x64\Lib\compileall.py" -q -f -x "bad_coding|badsyntax|site-packages|py3_" "%BINARIESDIR%\python_x64\Lib"
  144. "%BINARIESDIR%\python_x64\python.exe" -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
  145. "%BINARIESDIR%\python_x64\python.exe" -m ensurepip -U --default-pip
  146. if not %ERRORLEVEL% == 0 (
  147. echo "Failed to run ensurepip in %BINARIESDIR%\python_x64 for Python 64bit"
  148. exit /b 1
  149. )
  150. "%BINARIESDIR%\python_x64\python.exe" -m pip install %PIP_EXTRA_ARGS% pypiwin32==219
  151. if not %ERRORLEVEL% == 0 (
  152. echo "Failed to install pypiwin32 in %BINARIESDIR%\python_x64 for Python 64bit"
  153. exit /b 1
  154. )
  155. copy /B /Y "%VS90COMNTOOLS%..\..\VC\redist\amd64\Microsoft.VC90.CRT\msvcr90.dll" "%BINARIESDIR%\python_x64\"
  156. if not %ERRORLEVEL% == 0 (
  157. echo "Failed to copy msvcr90.dll in %BINARIESDIR%\python_x64 for Python 64bit"
  158. exit /b 1
  159. )
  160. copy /B /Y "%VS90COMNTOOLS%..\..\VC\redist\amd64\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest" "%BINARIESDIR%\python_x64\"
  161. if not %ERRORLEVEL% == 0 (
  162. echo "Failed to copy Microsoft.VC90.CRT.manifest in %BINARIESDIR%\python_x64 for Python 64bit"
  163. exit /b 1
  164. )
  165. cd "%BINARIESDIR%"
  166. 2>nul rd /S /Q "%BINARIESDIR%\cpython-%PYTHON_VERSION%"
  167. 2>nul del /Q /F "%BINARIESDIR%\cabarc.exe"
  168. exit /b 0