fix(codegen): PS5.1-safe quoting for native-exe args in generate-proto probes
This commit is contained in:
@@ -36,7 +36,11 @@ function Resolve-Python {
|
||||
function Assert-GrpcioToolsVersion {
|
||||
param([string]$Python)
|
||||
|
||||
$version = (& $Python -c 'import grpc_tools; from importlib.metadata import version; print(version("grpcio-tools"))').Trim()
|
||||
# Windows PowerShell 5.1 strips embedded double quotes when passing an argument to a native
|
||||
# exe (pwsh 7 does not), so a Python literal quoted with " " here would arrive at Python as
|
||||
# print(version(grpcio-tools)) -> NameError. Use single quotes for the Python string literal
|
||||
# inside this double-quoted PowerShell string so the quoting survives on both hosts.
|
||||
$version = (& $Python -c "import grpc_tools; from importlib.metadata import version; print(version('grpcio-tools'))").Trim()
|
||||
if ($version -ne $PinnedGrpcioToolsVersion) {
|
||||
throw "grpcio-tools $version is installed, but regeneration is pinned to $PinnedGrpcioToolsVersion. " +
|
||||
"Install the pin (python -m pip install 'grpcio-tools==$PinnedGrpcioToolsVersion') before regenerating, " +
|
||||
|
||||
Reference in New Issue
Block a user