@@ -872,6 +872,7 @@ def _verify_library_namespace(library_id: str, repo: str):
872872 # TODO(https://github.com/googleapis/google-cloud-python/issues/14376): Update the list of namespaces which are exceptions.
873873 exception_namespaces = [
874874 "google.area120" ,
875+ "google.api" ,
875876 "google.apps.script" ,
876877 "google.apps.script.type" ,
877878 "google.cloud.alloydb" ,
@@ -883,14 +884,17 @@ def _verify_library_namespace(library_id: str, repo: str):
883884 "google.cloud.security" ,
884885 "google.cloud.video" ,
885886 "google.cloud.workflows" ,
887+ "google.gapic" ,
888+ "google.logging" ,
886889 "google.monitoring" ,
890+ "google.rpc" ,
887891 ]
888892 valid_namespaces = [
889893 "google" ,
890- "google.analytics" ,
891- "google.apps" ,
892894 "google.ads" ,
893895 "google.ai" ,
896+ "google.analytics" ,
897+ "google.apps" ,
894898 "google.cloud" ,
895899 "google.geo" ,
896900 "google.maps" ,
@@ -899,28 +903,32 @@ def _verify_library_namespace(library_id: str, repo: str):
899903 * exception_namespaces ,
900904 ]
901905 gapic_version_file = "gapic_version.py"
906+ proto_file = "*.proto"
902907
903- # This is now the "package root" path we will use for comparison
904908 library_path = Path (f"{ repo } /packages/{ library_id } " )
905909
906910 if not library_path .is_dir ():
907911 raise ValueError (f"Error: Path is not a directory: { library_path } " )
908912
909- # Recursively glob (rglob) for all 'gapic_version.py' files
910- all_gapic_files = list ( library_path . rglob ( gapic_version_file ) )
913+ # Use a set to store unique parent directories of relevant files
914+ relevant_dirs = set ( )
911915
912- if not all_gapic_files :
916+ # Find all parent directories for 'gapic_version.py' files
917+ for gapic_file in library_path .rglob (gapic_version_file ):
918+ relevant_dirs .add (gapic_file .parent )
919+
920+ # Find all parent directories for '*.proto' files
921+ for proto_file in library_path .rglob (proto_file ):
922+ relevant_dirs .add (proto_file .parent )
923+
924+ if not relevant_dirs :
913925 raise ValueError (
914926 f"Error: namespace cannot be determined for { library_id } ."
915- f" Library is missing a `{ gapic_version_file } `."
927+ f" Library is missing a `{ gapic_version_file } ` or ` { proto_file } ` file ."
916928 )
917929
918- for gapic_file in all_gapic_files :
919- # The directory we want is the parent of `gapic_version.py` file.
920- gapic_parent_dir = gapic_file .parent
921-
922- # Pass both the specific dir and the package root for a safe relative comparison
923- library_namespace = _determine_library_namespace (gapic_parent_dir , library_path )
930+ for relevant_dir in relevant_dirs :
931+ library_namespace = _determine_library_namespace (relevant_dir , library_path )
924932
925933 if library_namespace not in valid_namespaces :
926934 raise ValueError (
0 commit comments