xref: /aosp_15_r20/external/grpc-grpc/tools/run_tests/artifacts/build_artifact_python.bat (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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
18@rem set path to the existed mingw compiler
19set PATH=C:\msys64\mingw%2\bin;C:\tools\msys64\mingw%2\bin;%PATH%
20:end_mingw64_installation
21
22python -m pip install --upgrade pip six setuptools wheel
23python -m pip install --upgrade "cython<3.0.0rc1"
24python -m pip install -rrequirements.txt --user
25
26@rem set GRPC_PYTHON_OVERRIDE_CYGWIN_DETECTION_FOR_27=1
27set GRPC_PYTHON_BUILD_WITH_CYTHON=1
28
29@rem Allow build_ext to build C/C++ files in parallel
30@rem by enabling a monkeypatch. It speeds up the build a lot.
31@rem Use externally provided GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS value if set.
32if "%GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS%"=="" (
33  set GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=4
34)
35
36mkdir -p %ARTIFACTS_OUT%
37set ARTIFACT_DIR=%cd%\%ARTIFACTS_OUT%
38
39@rem Set up gRPC Python tools
40python tools\distrib\python\make_grpcio_tools.py
41
42@rem Build gRPC Python extensions
43python setup.py build_ext -c %EXT_COMPILER% || goto :error
44
45pushd tools\distrib\python\grpcio_tools
46python setup.py build_ext -c %EXT_COMPILER% || goto :error
47popd
48
49@rem Build gRPC Python distributions
50python setup.py bdist_wheel || goto :error
51
52pushd tools\distrib\python\grpcio_tools
53python setup.py bdist_wheel || goto :error
54popd
55
56@rem Ensure the generate artifacts are valid.
57python -m pip install packaging==21.3 twine==3.8.0
58python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error
59
60xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error
61xcopy /Y /I /S tools\distrib\python\grpcio_tools\dist\* %ARTIFACT_DIR% || goto :error
62
63goto :EOF
64
65:error
66popd
67exit /b 1
68