Skip to content

Commit 2ce8a11

Browse files
authored
chore: replace pkg_resources with importlib.resources (#326)
* chore: remove depecated pkg resources Signed-off-by: exploreriii <[email protected]> * chore: changelog update Signed-off-by: exploreriii <[email protected]> --------- Signed-off-by: exploreriii <[email protected]>
1 parent 32ccb4a commit 2ce8a11

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
3434
- Removed the old `/documentation` folder.
3535
- Rebase command in README_upstream changed to just -S
3636
- generate_proto.sh
37+
- pkg_resources dependency in generate_proto.py
3738

3839
### Breaking API changes
3940
- We have some changed imports and returns to maintain compatability in the proto bump

generate_proto.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import tarfile
3333
import tempfile
3434
import urllib.request
35+
from importlib.resources import files as pkg_files
3536
from dataclasses import dataclass
3637
from pathlib import Path
3738
from typing import Iterable, List, Set, Tuple
@@ -254,15 +255,7 @@ def run_protoc(
254255
logging.info("No .proto files to compile (skipping).")
255256
return
256257

257-
# Add grpc_tools' bundled google protos include path
258-
try:
259-
# setuptools/pkg_resources works with grpc_tools wheels
260-
from pkg_resources import resource_filename
261-
google_include = resource_filename("grpc_tools", "_proto")
262-
except Exception as _:
263-
# Fallback for environments without pkg_resources
264-
import importlib_resources # type: ignore
265-
google_include = str(importlib_resources.files("grpc_tools").joinpath("_proto"))
258+
google_include = str(pkg_files("grpc_tools").joinpath("_proto"))
266259

267260
args: list[str] = ["protoc"]
268261
# 1) our temp normalized include(s)

0 commit comments

Comments
 (0)