@@ -98,7 +98,7 @@ def build_wrapped_itk(
9898 check_call ([ninja_executable ])
9999
100100
101- def build_wheel (python_version , single_wheel = False ):
101+ def build_wheel (python_version , single_wheel = False , cleanup = False ):
102102 venv_dir = os .path .join (ROOT_DIR , "venv-%s" % python_version )
103103
104104 python_executable = os .path .join (venv_dir , "Scripts" , "python.exe" )
@@ -131,7 +131,7 @@ def build_wheel(python_version, single_wheel=False):
131131 setup_py_configure = os .path .join (SCRIPT_DIR , "setup_py_configure.py" )
132132
133133 # Clean up previous invocations
134- if os .path .exists (build_path ):
134+ if cleanup and os .path .exists (build_path ):
135135 shutil .rmtree (build_path )
136136
137137 if single_wheel :
@@ -199,19 +199,24 @@ def build_wheel(python_version, single_wheel=False):
199199 ])
200200
201201 # Cleanup
202- check_call ([python_executable , "setup.py" , "clean" ])
202+ if cleanup :
203+ check_call ([python_executable , "setup.py" , "clean" ])
203204
204205 # Remove unnecessary files for building against ITK
205- for root , _ , file_list in os .walk (build_path ):
206- for filename in file_list :
207- extension = os .path .splitext (filename )[1 ]
208- if extension in [".cpp" , ".xml" , ".obj" ]:
209- os .remove (os .path .join (root , filename ))
210- shutil .rmtree (
211- os .path .join (build_path , "Wrapping" , "Generators" , "CastXML" ))
206+ if cleanup :
207+ for root , _ , file_list in os .walk (build_path ):
208+ for filename in file_list :
209+ extension = os .path .splitext (filename )[1 ]
210+ if extension in [".cpp" , ".xml" , ".obj" ]:
211+ os .remove (os .path .join (root , filename ))
212+ shutil .rmtree (
213+ os .path .join (build_path , "Wrapping" , "Generators" , "CastXML" ))
212214
213215
214- def build_wheels ():
216+ def build_wheels (py_envs = None , cleanup = False ):
217+
218+ if py_envs is None :
219+ py_envs = ["27-x64" , "35-x64" , "36-x64" ]
215220
216221 prepare_build_env ("27-x64" )
217222 prepare_build_env ("35-x64" )
@@ -238,9 +243,8 @@ def build_wheels():
238243 single_wheel = False
239244
240245 # Compile wheels re-using standalone project and archive cache
241- build_wheel ("27-x64" , single_wheel = single_wheel )
242- build_wheel ("35-x64" , single_wheel = single_wheel )
243- build_wheel ("36-x64" , single_wheel = single_wheel )
246+ for py_env in py_envs :
247+ build_wheel (py_env , single_wheel = single_wheel , cleanup = cleanup )
244248
245249
246250if __name__ == "__main__" :
0 commit comments