diff --git a/clients/python/generate-proto.ps1 b/clients/python/generate-proto.ps1 index a98eb29..863a21c 100644 --- a/clients/python/generate-proto.ps1 +++ b/clients/python/generate-proto.ps1 @@ -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, " +