1515"""Helper for building py_cel with bazel for PyPI releases."""
1616
1717import os
18+ import re
1819import shutil
1920import subprocess
2021import sys
@@ -49,11 +50,15 @@ def build_extension(self, ext):
4950
5051 module_bazel_path = os .path .join (os .path .dirname (__file__ ), 'MODULE.bazel' )
5152 if os .path .exists (module_bazel_path ):
52- sed_command = (
53- "sed -i 's/python_version\\ s*=\\ s*\" .*\" /"
54- f"python_version = \" { python_version } \" /' { module_bazel_path } "
53+ with open (module_bazel_path , 'r' ) as f :
54+ content = f .read ()
55+ content = re .sub (
56+ r'python_version\s*=\s*".*"' ,
57+ f'python_version = "{ python_version } "' ,
58+ content ,
5559 )
56- subprocess .check_call (sed_command , shell = True )
60+ with open (module_bazel_path , 'w' ) as f :
61+ f .write (content )
5762 else :
5863 raise RuntimeError (
5964 f'MODULE.bazel not found at { module_bazel_path } '
@@ -66,6 +71,8 @@ def build_extension(self, ext):
6671 # Build with bazel
6772 # Use --compilation_mode=opt for release builds
6873 cmd = ['bazel' , 'build' , ext .target , '--compilation_mode=opt' ]
74+ if sys .platform == 'darwin' :
75+ cmd .extend (['--macos_minimum_os=10.13' , '--cxxopt=-faligned-allocation' ])
6976 print (f"Building { ext .name } with bazel: { ' ' .join (cmd )} " )
7077 subprocess .check_call (cmd )
7178
@@ -134,8 +141,8 @@ def build_extension(self, ext):
134141 '//cel_expr_python/ext:ext_proto' ,
135142 ),
136143 BazelExtension (
137- 'cel_expr_python.ext.ext_string ' ,
138- '//cel_expr_python/ext:ext_string ' ,
144+ 'cel_expr_python.ext.ext_strings ' ,
145+ '//cel_expr_python/ext:ext_strings ' ,
139146 ),
140147 ],
141148 cmdclass = {'build_ext' : BazelBuild },
0 commit comments