build_artifact_python.bat 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. @rem Copyright 2016 gRPC authors.
  2. @rem
  3. @rem Licensed under the Apache License, Version 2.0 (the "License");
  4. @rem you may not use this file except in compliance with the License.
  5. @rem You may obtain a copy of the License at
  6. @rem
  7. @rem http://www.apache.org/licenses/LICENSE-2.0
  8. @rem
  9. @rem Unless required by applicable law or agreed to in writing, software
  10. @rem distributed under the License is distributed on an "AS IS" BASIS,
  11. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. @rem See the License for the specific language governing permissions and
  13. @rem limitations under the License.
  14. @rem set path to python
  15. set PATH=C:\%1;C:\%1\scripts;%PATH%
  16. if "%1" == "Python27" goto :install_mingw64_with_msvcr90
  17. if "%1" == "Python27_32bit" goto :install_mingw64_with_msvcr90
  18. @rem set path to the existed mingw compiler
  19. set PATH=C:\msys64\mingw%2\bin;C:\tools\msys64\mingw%2\bin;%PATH%
  20. :end_mingw64_installation
  21. python -m pip install --upgrade six
  22. @rem some artifacts are broken for setuptools 38.5.0. See https://github.com/grpc/grpc/issues/14317
  23. python -m pip install --upgrade setuptools==44.1.1
  24. python -m pip install --upgrade cython
  25. python -m pip install -rrequirements.txt --user
  26. @rem set GRPC_PYTHON_OVERRIDE_CYGWIN_DETECTION_FOR_27=1
  27. set GRPC_PYTHON_BUILD_WITH_CYTHON=1
  28. @rem Allow build_ext to build C/C++ files in parallel
  29. @rem by enabling a monkeypatch. It speeds up the build a lot.
  30. @rem Use externally provided GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS value if set.
  31. if "%GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS%"=="" (
  32. set GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=4
  33. )
  34. mkdir -p %ARTIFACTS_OUT%
  35. set ARTIFACT_DIR=%cd%\%ARTIFACTS_OUT%
  36. @rem Set up gRPC Python tools
  37. python tools\distrib\python\make_grpcio_tools.py
  38. @rem Build gRPC Python extensions
  39. python setup.py build_ext -c %EXT_COMPILER% || goto :error
  40. pushd tools\distrib\python\grpcio_tools
  41. python setup.py build_ext -c %EXT_COMPILER% || goto :error
  42. popd
  43. @rem Build gRPC Python distributions
  44. python setup.py bdist_wheel || goto :error
  45. pushd tools\distrib\python\grpcio_tools
  46. python setup.py bdist_wheel || goto :error
  47. popd
  48. @rem Ensure the generate artifacts are valid.
  49. python -m pip install twine==3.8.0
  50. python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error
  51. xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error
  52. xcopy /Y /I /S tools\distrib\python\grpcio_tools\dist\* %ARTIFACT_DIR% || goto :error
  53. goto :EOF
  54. :error
  55. popd
  56. exit /b 1
  57. :install_mingw64_with_msvcr90
  58. set MSYS64_DOWNLOAD_URL=https://storage.googleapis.com/grpc-build-helper/msys64.zip
  59. set MSYS64_PATH=C:\tools\msys64_win7
  60. set PATH=%MSYS64_PATH%\mingw%2\bin;%PATH%
  61. @rem Skip the installation if the directory exists
  62. if exist "%MSYS64_PATH%" goto :end_mingw64_installation
  63. python -m pip install requests || goto :error
  64. python tools\run_tests\python_utils\download_and_unzip.py "%MSYS64_DOWNLOAD_URL%" "%MSYS64_PATH%" || goto :error
  65. goto :end_mingw64_installation