This repository was archived by the owner on Jun 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
src/betterproto2_compiler Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
import os .path
2
2
import subprocess
3
3
import sys
4
+ from importlib import metadata
4
5
5
6
from .module_validation import ModuleValidator
6
7
24
25
def outputfile_compiler (output_file : OutputTemplate ) -> str :
25
26
templates_folder = os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , "templates" ))
26
27
28
+ version = metadata .version ("betterproto2_compiler" )
29
+
27
30
env = jinja2 .Environment (
28
31
trim_blocks = True ,
29
32
lstrip_blocks = True ,
@@ -35,7 +38,7 @@ def outputfile_compiler(output_file: OutputTemplate) -> str:
35
38
header_template = env .get_template ("header.py.j2" )
36
39
37
40
code = body_template .render (output_file = output_file )
38
- code = header_template .render (output_file = output_file ) + "\n " + code
41
+ code = header_template .render (output_file = output_file , version = version ) + "\n " + code
39
42
40
43
# Sort imports, delete unused ones
41
44
code = subprocess .check_output (
Original file line number Diff line number Diff line change @@ -48,3 +48,5 @@ if TYPE_CHECKING:
48
48
import grpclib.server
49
49
from betterproto2.grpc.grpclib_client import MetadataLike
50
50
from grpclib.metadata import Deadline
51
+
52
+ betterproto2.check_compiler_version("{{ version }}")
You can’t perform that action at this time.
0 commit comments