File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,20 +109,45 @@ def main(argv: Sequence[str] | None = None) -> int:
109109 "w" ,
110110 delete_on_close = False ,
111111 ) as compiled_out :
112- subprocess .check_call (
113- [
114- "docker" ,
115- "run" ,
116- f"--volume={ os .getcwd ()} :/work" ,
117- "--rm" ,
118- MelangeImage ,
119- "compile" ,
120- f"--arch={ os .uname ().machine } " ,
121- "--pipeline-dir=./pipelines" ,
122- filename ,
123- ],
124- stdout = compiled_out ,
125- )
112+ # Try multiple architectures
113+ architectures = list (dict .fromkeys ([os .uname ().machine , 'x86_64' , 'aarch64' ]))
114+ compilation_succeeded = False
115+
116+ for i , arch in enumerate (architectures ):
117+ try :
118+ subprocess .run (
119+ [
120+ "docker" ,
121+ "run" ,
122+ f"--volume={ os .getcwd ()} :/work" ,
123+ "--rm" ,
124+ MelangeImage ,
125+ "compile" ,
126+ f"--arch={ arch } " ,
127+ "--pipeline-dir=./pipelines" ,
128+ filename ,
129+ ],
130+ stdout = compiled_out ,
131+ stderr = subprocess .PIPE ,
132+ check = True ,
133+ text = True
134+ )
135+ compilation_succeeded = True
136+ break # Success, exit the architecture loop
137+ except subprocess .CalledProcessError as e :
138+ if i < len (architectures ) - 1 :
139+ # Reset the file for the next attempt
140+ compiled_out .seek (0 )
141+ compiled_out .truncate ()
142+ continue
143+ else :
144+ # Last architecture failed, propagate the error
145+ raise
146+
147+ if not compilation_succeeded :
148+ fail_cnt += 1
149+ continue
150+
126151 compiled_out .close ()
127152 try :
128153 with open (compiled_out .name ) as compiled_in :
You can’t perform that action at this time.
0 commit comments