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
15@rem set path to python
16set PATH=C:\%1;C:\%1\scripts;%PATH%
17
18if "%1" == "Python27" goto :install_mingw64_with_msvcr90
19if "%1" == "Python27_32bit" goto :install_mingw64_with_msvcr90
20@rem set path to the existed mingw compiler
21set PATH=C:\msys64\mingw%2\bin;C:\tools\msys64\mingw%2\bin;%PATH%
22:end_mingw64_installation
23
24python -m pip install --upgrade six
25@rem some artifacts are broken for setuptools 38.5.0. See https://github.com/grpc/grpc/issues/14317
26python -m pip install --upgrade setuptools==44.1.1
27python -m pip install --upgrade cython
28python -m pip install -rrequirements.txt --user
29
30@rem set GRPC_PYTHON_OVERRIDE_CYGWIN_DETECTION_FOR_27=1
31set GRPC_PYTHON_BUILD_WITH_CYTHON=1
32
33@rem Allow build_ext to build C/C++ files in parallel
34@rem by enabling a monkeypatch. It speeds up the build a lot.
35set GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=4
36
37mkdir -p %ARTIFACTS_OUT%
38set ARTIFACT_DIR=%cd%\%ARTIFACTS_OUT%
39
40@rem Set up gRPC Python tools
41python tools\distrib\python\make_grpcio_tools.py
42
43@rem Build gRPC Python extensions
44python setup.py build_ext -c %EXT_COMPILER% || goto :error
45
46pushd tools\distrib\python\grpcio_tools
47python setup.py build_ext -c %EXT_COMPILER% || goto :error
48popd
49
50@rem Build gRPC Python distributions
51python setup.py bdist_wheel || goto :error
52
53pushd tools\distrib\python\grpcio_tools
54python setup.py bdist_wheel || goto :error
55popd
56
57@rem Ensure the generate artifacts are valid.
58python -m pip install "twine<=2.0"
59python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error
60
61xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error
62xcopy /Y /I /S tools\distrib\python\grpcio_tools\dist\* %ARTIFACT_DIR% || goto :error
63
64goto :EOF
65
66:error
67popd
68exit /b 1
69
70:install_mingw64_with_msvcr90
71set MSYS64_DOWNLOAD_URL=https://storage.googleapis.com/grpc-build-helper/msys64.zip
72set MSYS64_PATH=C:\tools\msys64_win7
73set PATH=%MSYS64_PATH%\mingw%2\bin;%PATH%
74@rem Skip the installation if the directory exists
75if exist "%MSYS64_PATH%" goto :end_mingw64_installation
76python -m pip install requests || goto :error
77python tools\run_tests\python_utils\download_and_unzip.py "%MSYS64_DOWNLOAD_URL%" "%MSYS64_PATH%" || goto :error
78goto :end_mingw64_installation
79