1+ #!/usr/bin/env python
12
3+ import argparse
24import glob
35import json
46import os
@@ -104,7 +106,8 @@ def build_wrapped_itk(
104106
105107
106108def build_wheel (python_version , single_wheel = False ,
107- cleanup = False , wheel_names = None ):
109+ cleanup = False , wheel_names = None ,
110+ cmake_options = []):
108111
109112 python_executable , \
110113 python_include_dir , \
@@ -148,8 +151,9 @@ def build_wheel(python_version, single_wheel=False,
148151 "-DITK_BINARY_DIR:PATH=%s" % build_path ,
149152 "-DPYTHON_EXECUTABLE:FILEPATH=%s" % python_executable ,
150153 "-DPYTHON_INCLUDE_DIR:PATH=%s" % python_include_dir ,
151- "-DPYTHON_LIBRARY:FILEPATH=%s" % python_library
152- ])
154+ "-DPYTHON_LIBRARY:FILEPATH=%s" % python_library ,
155+ "-DDOXYGEN_EXECUTABLE:FILEPATH=C:/P/doxygen/doxygen.exe" ,
156+ ] + cmake_options )
153157 # Cleanup
154158 check_call ([python_executable , "setup.py" , "clean" ])
155159
@@ -189,7 +193,7 @@ def build_wheel(python_version, single_wheel=False,
189193 "-DPYTHON_EXECUTABLE:FILEPATH=%s" % python_executable ,
190194 "-DPYTHON_INCLUDE_DIR:PATH=%s" % python_include_dir ,
191195 "-DPYTHON_LIBRARY:FILEPATH=%s" % python_library
192- ])
196+ ] + cmake_options )
193197
194198 # Cleanup
195199 if cleanup :
@@ -215,24 +219,35 @@ def fixup_wheels():
215219 fixup_wheel (wheel )
216220
217221
218- def test_wheels (single_wheel = False ):
222+ def test_wheels (python_env ):
223+ (
224+ python_executable ,
225+ python_include_dir ,
226+ python_library ,
227+ pip ,
228+ ninja_executable ,
229+ path
230+ ) = venv_paths (python_env )
231+ check_call ([pip , 'install' , 'itk' , '--no-cache-dir' , '--no-index' ,
232+ '-f' , 'dist' ])
233+ print ('Wheel successfully installed.' )
219234 check_call ([
220235 python_executable ,
221236 os .path .join (ROOT_DIR , "docs/code/testDriver.py" )
222237 ])
238+ print ('Documentation tests passed.' )
223239
224240
225241def build_wheels (py_envs = DEFAULT_PY_ENVS , single_wheel = False ,
226- cleanup = False , wheel_names = None ):
242+ cleanup = False , wheel_names = None , cmake_options = [] ):
227243
228- prepare_build_env ("35-x64" )
229- prepare_build_env ("36-x64" )
230- prepare_build_env ("37-x64" )
244+ for py_env in py_envs :
245+ prepare_build_env (py_env )
231246
232247 with push_dir (directory = STANDALONE_DIR , make_directory = True ):
233248
234249 cmake_executable = "cmake.exe"
235- tools_venv = os .path .join (ROOT_DIR , "venv-35-x64" )
250+ tools_venv = os .path .join (ROOT_DIR , "venv-" + py_envs [ 0 ] )
236251 pip_install (tools_venv , "ninja" )
237252 ninja_executable = os .path .join (tools_venv , "Scripts" , "ninja.exe" )
238253
@@ -249,19 +264,26 @@ def build_wheels(py_envs=DEFAULT_PY_ENVS, single_wheel=False,
249264
250265 # Compile wheels re-using standalone project and archive cache
251266 for py_env in py_envs :
252- build_wheel (
253- py_env , single_wheel = single_wheel ,
254- cleanup = cleanup , wheel_names = wheel_names )
255-
256-
257- def main (py_envs = DEFAULT_PY_ENVS , wheel_names = None , cleanup = True ):
258- single_wheel = False
259-
260- build_wheels (
261- single_wheel = single_wheel , cleanup = cleanup ,
262- py_envs = py_envs , wheel_names = wheel_names )
267+ build_wheel (py_env , single_wheel = single_wheel ,
268+ cleanup = cleanup , wheel_names = wheel_names ,
269+ cmake_options = cmake_options )
270+
271+
272+ def main (wheel_names = None ):
273+ parser = argparse .ArgumentParser (description = 'Driver script to build ITK Python wheels.' )
274+ parser .add_argument ('--single-wheel' , action = 'store_true' , help = 'Build a single wheel as opposed to one wheel per ITK module group.' )
275+ parser .add_argument ('--py-envs' , nargs = '+' , default = DEFAULT_PY_ENVS ,
276+ help = 'Target Python environment versions, e.g. "37-x64".' )
277+ parser .add_argument ('--no-cleanup' , dest = 'cleanup' , action = 'store_false' , help = 'Do not clean up temporary build files.' )
278+ parser .add_argument ('cmake_options' , nargs = '*' , help = 'Extra options to pass to CMake, e.g. -DBUILD_SHARED_LIBS:BOOL=OFF' )
279+ args = parser .parse_args ()
280+
281+ build_wheels (single_wheel = args .single_wheel , cleanup = args .cleanup ,
282+ py_envs = args .py_envs , wheel_names = wheel_names ,
283+ cmake_options = args .cmake_options )
263284 fixup_wheels ()
264- test_wheels (single_wheel = single_wheel )
285+ for py_env in args .py_envs :
286+ test_wheels (py_env )
265287
266288
267289if __name__ == "__main__" :
0 commit comments