krista-common-proto-schema 1.0.5__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of krista-common-proto-schema might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: krista_common_proto_schema
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: Shared Protocol Buffer definitions.
5
5
  Home-page: https://github.com/your-org/krista-common-proto-schema
6
6
  Author: Krista
@@ -5,16 +5,12 @@ This package contains compiled Protocol Buffer definitions
5
5
  that can be imported directly in Python projects.
6
6
 
7
7
  Usage:
8
- from krista_common_proto_schema import user_pb2, message_pb2
8
+ from krista_common_proto_schema.common import user_pb2, message_pb2
9
9
 
10
10
  user = user_pb2.User(id=1, name="John")
11
11
  message = message_pb2.Message(id=1, sender=user, content="Hello")
12
12
  """
13
13
 
14
- __version__ = "1.0.5"
14
+ __version__ = "1.0.7"
15
15
 
16
- # Import compiled proto modules for easy access
17
- from . import user_pb2
18
- from . import message_pb2
19
-
20
- __all__ = ["user_pb2", "message_pb2"]
16
+ __all__ = ["common"]
@@ -22,7 +22,7 @@ _runtime_version.ValidateProtobufRuntimeVersion(
22
22
  _sym_db = _symbol_database.Default()
23
23
 
24
24
 
25
- from common import user_pb2 as common_dot_user__pb2
25
+ from krista_common_proto_schema.common import user_pb2 as common_dot_user__pb2
26
26
 
27
27
 
28
28
  DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63ommon/message.proto\x12\x06\x63ommon\x1a\x11\x63ommon/user.proto\"z\n\x07Message\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x1c\n\x06sender\x18\x02 \x01(\x0b\x32\x0c.common.User\x12\x0f\n\x07\x63ontent\x18\x03 \x01(\t\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12!\n\x04type\x18\x05 \x01(\x0e\x32\x13.common.MessageType*7\n\x0bMessageType\x12\x08\n\x04TEXT\x10\x00\x12\t\n\x05IMAGE\x10\x01\x12\t\n\x05VIDEO\x10\x02\x12\x08\n\x04\x46ILE\x10\x03\x42\'\n\x17\x63om.krista.proto.commonB\x0cMessageProtob\x06proto3')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: krista-common-proto-schema
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: Shared Protocol Buffer definitions.
5
5
  Home-page: https://github.com/your-org/krista-common-proto-schema
6
6
  Author: Krista
@@ -23,6 +23,7 @@ from distutils.command.build import build
23
23
  import subprocess
24
24
  import os
25
25
  import shutil
26
+ import re
26
27
  from pathlib import Path
27
28
 
28
29
 
@@ -64,8 +65,9 @@ class BuildProtoCommand(build_py):
64
65
  version_file = Path("../VERSION")
65
66
  version = version_file.read_text().strip()
66
67
 
67
- # Create output directory
68
+ # Create output directory and subdirectories
68
69
  output_dir.mkdir(exist_ok=True)
70
+ (output_dir / "common").mkdir(exist_ok=True)
69
71
 
70
72
  # Create __init__.py with dynamic version
71
73
  init_file = output_dir / "__init__.py"
@@ -76,7 +78,7 @@ This package contains compiled Protocol Buffer definitions
76
78
  that can be imported directly in Python projects.
77
79
 
78
80
  Usage:
79
- from krista_common_proto_schema import user_pb2, message_pb2
81
+ from krista_common_proto_schema.common import user_pb2, message_pb2
80
82
 
81
83
  user = user_pb2.User(id=1, name="John")
82
84
  message = message_pb2.Message(id=1, sender=user, content="Hello")
@@ -84,11 +86,7 @@ Usage:
84
86
 
85
87
  __version__ = "{version}"
86
88
 
87
- # Import compiled proto modules for easy access
88
- from . import user_pb2
89
- from . import message_pb2
90
-
91
- __all__ = ["user_pb2", "message_pb2"]
89
+ __all__ = ["common"]
92
90
  ''')
93
91
 
94
92
  # Find all .proto files
@@ -105,13 +103,13 @@ __all__ = ["user_pb2", "message_pb2"]
105
103
  # Compile each proto file
106
104
  for proto_file in proto_files:
107
105
  print(f"\n🔨 Compiling {proto_file}...")
108
-
106
+
109
107
  try:
110
108
  subprocess.run(
111
109
  [
112
110
  "python3", "-m", "grpc_tools.protoc",
113
111
  f"-I={proto_dir}",
114
- f"--python_out={output_dir}",
112
+ f"--python_out={output_dir.absolute()}",
115
113
  str(proto_file)
116
114
  ],
117
115
  check=True,
@@ -122,7 +120,21 @@ __all__ = ["user_pb2", "message_pb2"]
122
120
  except subprocess.CalledProcessError as e:
123
121
  print(f" ❌ Error: {e.stderr}")
124
122
  raise
125
-
123
+
124
+ # Fix imports in generated Python files
125
+ print(f"\n🔧 Fixing imports in generated Python files...")
126
+ for py_file in output_dir.rglob("*_pb2.py"):
127
+ content = py_file.read_text()
128
+ # Replace "from common import" with "from krista_common_proto_schema.common import"
129
+ fixed_content = re.sub(
130
+ r'from common import (\w+)',
131
+ r'from krista_common_proto_schema.common import \1',
132
+ content
133
+ )
134
+ if fixed_content != content:
135
+ py_file.write_text(fixed_content)
136
+ print(f" ✅ Fixed imports in {py_file.name}")
137
+
126
138
  # Create __init__.py files in all subdirectories to make them packages
127
139
  print("\n📦 Creating __init__.py files in subdirectories...")
128
140
  for subdir in output_dir.rglob("*"):