|
| 1 | +From: RISE python-wheels <noreply@riseproject.dev> |
| 2 | +Subject: [PATCH] fix per-package command cwd-relative path regression from #40833 |
| 3 | + |
| 4 | +Same regression as the grpcio_tests/commands.py GatherProto fix |
| 5 | +(0003-fix-GatherProto-cwd-relative-path-regression.patch): the |
| 6 | +pyproject.toml migration (#40833) made these per-package "preprocess"/ |
| 7 | +"build_package_protos" setuptools Command classes cwd-relative instead |
| 8 | +of anchored to GRPC_ROOT_ABS_PATH/ROOT_DIR (both already computed |
| 9 | +absolute in each file). install_all_python_modules.sh pushd's into each |
| 10 | +package's own directory before running these commands, so the relative |
| 11 | +paths ("src/proto/...", "./LICENSE", ROOT_REL_DIR) don't resolve there - |
| 12 | +symptoms range from a silently-skipped proto copy to |
| 13 | +grpc_tools.command.build_package_protos() finding zero .proto files and |
| 14 | +silently emitting no *_pb2.py, e.g.: |
| 15 | + |
| 16 | + ImportError: cannot import name 'health_pb2' from 'grpc_health.v1' |
| 17 | + |
| 18 | +Fixes the same way as 0003: revert each file's constants/run() bodies to |
| 19 | +use the already-computed absolute ROOT_DIR/GRPC_ROOT_ABS_PATH instead of |
| 20 | +the relative ROOT_REL_DIR, matching pre-#40833 behavior. Affects every |
| 21 | +per-package command module install_all_python_modules.sh's PACKAGES loop |
| 22 | +touches that generates protos or copies LICENSE: grpcio_channelz, |
| 23 | +grpcio_health_checking, grpcio_reflection, grpcio_status, grpcio_testing. |
| 24 | +(grpcio_tests/commands.py is 0003; grpcio/commands.py and grpcio_csds/ |
| 25 | +grpcio_admin/grpcio_csm_observability are unaffected - the former is |
| 26 | +invoked from repo root, the latter three carry no such module.) |
| 27 | + |
| 28 | +Upstream-Status: To upstream |
| 29 | + |
| 30 | +Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> |
| 31 | +--- |
| 32 | +diff --git a/src/python/grpcio_channelz/channelz_commands.py b/src/python/grpcio_channelz/channelz_commands.py |
| 33 | +index 3a1cc26..8c2cae5 100644 |
| 34 | +--- a/src/python/grpcio_channelz/channelz_commands.py |
| 35 | ++++ b/src/python/grpcio_channelz/channelz_commands.py |
| 36 | +@@ -20,9 +20,10 @@ import setuptools |
| 37 | + |
| 38 | + ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
| 39 | + GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..") |
| 40 | +-ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH) |
| 41 | +-CHANNELZ_PROTO = "src/proto/grpc/channelz/channelz.proto" |
| 42 | +-LICENSE = "./LICENSE" |
| 43 | ++CHANNELZ_PROTO = os.path.join( |
| 44 | ++ GRPC_ROOT_ABS_PATH, "src/proto/grpc/channelz/channelz.proto" |
| 45 | ++) |
| 46 | ++LICENSE = os.path.join(GRPC_ROOT_ABS_PATH, "LICENSE") |
| 47 | + |
| 48 | + |
| 49 | + class Preprocess(setuptools.Command): |
| 50 | +@@ -43,10 +44,10 @@ class Preprocess(setuptools.Command): |
| 51 | + if os.path.isfile(CHANNELZ_PROTO): |
| 52 | + shutil.copyfile( |
| 53 | + CHANNELZ_PROTO, |
| 54 | +- os.path.join(ROOT_REL_DIR, "grpc_channelz/v1/channelz.proto"), |
| 55 | ++ os.path.join(ROOT_DIR, "grpc_channelz/v1/channelz.proto"), |
| 56 | + ) |
| 57 | + if os.path.isfile(LICENSE): |
| 58 | +- shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE")) |
| 59 | ++ shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE")) |
| 60 | + |
| 61 | + |
| 62 | + class BuildPackageProtos(setuptools.Command): |
| 63 | +@@ -65,4 +66,4 @@ class BuildPackageProtos(setuptools.Command): |
| 64 | + from grpc_tools import command |
| 65 | + |
| 66 | + # find and build all protos in the current package |
| 67 | +- command.build_package_protos(ROOT_REL_DIR, strict_mode=True) |
| 68 | ++ command.build_package_protos(ROOT_DIR, strict_mode=True) |
| 69 | +diff --git a/src/python/grpcio_health_checking/health_commands.py b/src/python/grpcio_health_checking/health_commands.py |
| 70 | +index 6b90962..d8a7bc9 100644 |
| 71 | +--- a/src/python/grpcio_health_checking/health_commands.py |
| 72 | ++++ b/src/python/grpcio_health_checking/health_commands.py |
| 73 | +@@ -20,9 +20,10 @@ import setuptools |
| 74 | + |
| 75 | + ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
| 76 | + GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..") |
| 77 | +-ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH) |
| 78 | +-HEALTH_PROTO = "src/proto/grpc/health/v1/health.proto" |
| 79 | +-LICENSE = "./LICENSE" |
| 80 | ++HEALTH_PROTO = os.path.join( |
| 81 | ++ GRPC_ROOT_ABS_PATH, "src/proto/grpc/health/v1/health.proto" |
| 82 | ++) |
| 83 | ++LICENSE = os.path.join(GRPC_ROOT_ABS_PATH, "LICENSE") |
| 84 | + |
| 85 | + |
| 86 | + class Preprocess(setuptools.Command): |
| 87 | +@@ -43,10 +44,10 @@ class Preprocess(setuptools.Command): |
| 88 | + if os.path.isfile(HEALTH_PROTO): |
| 89 | + shutil.copyfile( |
| 90 | + HEALTH_PROTO, |
| 91 | +- os.path.join(ROOT_REL_DIR, "grpc_health/v1/health.proto"), |
| 92 | ++ os.path.join(ROOT_DIR, "grpc_health/v1/health.proto"), |
| 93 | + ) |
| 94 | + if os.path.isfile(LICENSE): |
| 95 | +- shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE")) |
| 96 | ++ shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE")) |
| 97 | + |
| 98 | + |
| 99 | + class BuildPackageProtos(setuptools.Command): |
| 100 | +@@ -65,4 +66,4 @@ class BuildPackageProtos(setuptools.Command): |
| 101 | + from grpc_tools import command |
| 102 | + |
| 103 | + # find and build all protos in the current package |
| 104 | +- command.build_package_protos(ROOT_REL_DIR, strict_mode=True) |
| 105 | ++ command.build_package_protos(ROOT_DIR, strict_mode=True) |
| 106 | +diff --git a/src/python/grpcio_reflection/reflection_commands.py b/src/python/grpcio_reflection/reflection_commands.py |
| 107 | +index 49cd4c4..af443b8 100644 |
| 108 | +--- a/src/python/grpcio_reflection/reflection_commands.py |
| 109 | ++++ b/src/python/grpcio_reflection/reflection_commands.py |
| 110 | +@@ -20,9 +20,10 @@ import setuptools |
| 111 | + |
| 112 | + ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
| 113 | + GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..") |
| 114 | +-ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH) |
| 115 | +-REFLECTION_PROTO = "src/proto/grpc/reflection/v1alpha/reflection.proto" |
| 116 | +-LICENSE = "./LICENSE" |
| 117 | ++REFLECTION_PROTO = os.path.join( |
| 118 | ++ GRPC_ROOT_ABS_PATH, "src/proto/grpc/reflection/v1alpha/reflection.proto" |
| 119 | ++) |
| 120 | ++LICENSE = os.path.join(GRPC_ROOT_ABS_PATH, "LICENSE") |
| 121 | + |
| 122 | + |
| 123 | + class Preprocess(setuptools.Command): |
| 124 | +@@ -44,11 +45,11 @@ class Preprocess(setuptools.Command): |
| 125 | + shutil.copyfile( |
| 126 | + REFLECTION_PROTO, |
| 127 | + os.path.join( |
| 128 | +- ROOT_REL_DIR, "grpc_reflection/v1alpha/reflection.proto" |
| 129 | ++ ROOT_DIR, "grpc_reflection/v1alpha/reflection.proto" |
| 130 | + ), |
| 131 | + ) |
| 132 | + if os.path.isfile(LICENSE): |
| 133 | +- shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE")) |
| 134 | ++ shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE")) |
| 135 | + |
| 136 | + |
| 137 | + class BuildPackageProtos(setuptools.Command): |
| 138 | +@@ -67,4 +68,4 @@ class BuildPackageProtos(setuptools.Command): |
| 139 | + from grpc_tools import command |
| 140 | + |
| 141 | + # find and build all protos in the current package |
| 142 | +- command.build_package_protos(ROOT_REL_DIR, strict_mode=True) |
| 143 | ++ command.build_package_protos(ROOT_DIR, strict_mode=True) |
| 144 | +diff --git a/src/python/grpcio_status/status_commands.py b/src/python/grpcio_status/status_commands.py |
| 145 | +index dec7c78..d2705b2 100644 |
| 146 | +--- a/src/python/grpcio_status/status_commands.py |
| 147 | ++++ b/src/python/grpcio_status/status_commands.py |
| 148 | +@@ -20,10 +20,11 @@ import setuptools |
| 149 | + |
| 150 | + ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
| 151 | + GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..") |
| 152 | +-ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH) |
| 153 | +-STATUS_PROTO = "third_party/googleapis/google/rpc/status.proto" |
| 154 | ++STATUS_PROTO = os.path.join( |
| 155 | ++ GRPC_ROOT_ABS_PATH, "third_party/googleapis/google/rpc/status.proto" |
| 156 | ++) |
| 157 | + PACKAGE_STATUS_PROTO_DIR = "grpc_status/google/rpc" |
| 158 | +-LICENSE = "./LICENSE" |
| 159 | ++LICENSE = os.path.join(GRPC_ROOT_ABS_PATH, "LICENSE") |
| 160 | + |
| 161 | + |
| 162 | + class Preprocess(setuptools.Command): |
| 163 | +@@ -40,7 +41,7 @@ class Preprocess(setuptools.Command): |
| 164 | + |
| 165 | + def run(self): |
| 166 | + package_status_proto_rel_path = os.path.join( |
| 167 | +- ROOT_REL_DIR, PACKAGE_STATUS_PROTO_DIR |
| 168 | ++ ROOT_DIR, PACKAGE_STATUS_PROTO_DIR |
| 169 | + ) |
| 170 | + |
| 171 | + if os.path.isfile(STATUS_PROTO): |
| 172 | +@@ -51,4 +52,4 @@ class Preprocess(setuptools.Command): |
| 173 | + os.path.join(package_status_proto_rel_path, "status.proto"), |
| 174 | + ) |
| 175 | + if os.path.isfile(LICENSE): |
| 176 | +- shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE")) |
| 177 | ++ shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE")) |
| 178 | +diff --git a/src/python/grpcio_testing/testing_commands.py b/src/python/grpcio_testing/testing_commands.py |
| 179 | +index cf8594b..2931837 100644 |
| 180 | +--- a/src/python/grpcio_testing/testing_commands.py |
| 181 | ++++ b/src/python/grpcio_testing/testing_commands.py |
| 182 | +@@ -20,8 +20,7 @@ import setuptools |
| 183 | + |
| 184 | + ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
| 185 | + GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..") |
| 186 | +-ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH) |
| 187 | +-LICENSE = "./LICENSE" |
| 188 | ++LICENSE = os.path.join(GRPC_ROOT_ABS_PATH, "LICENSE") |
| 189 | + |
| 190 | + |
| 191 | + class Preprocess(setuptools.Command): |
| 192 | +@@ -38,4 +37,4 @@ class Preprocess(setuptools.Command): |
| 193 | + |
| 194 | + def run(self): |
| 195 | + if os.path.isfile(LICENSE): |
| 196 | +- shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE")) |
| 197 | ++ shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE")) |
0 commit comments