53
53
"""
54
54
55
55
from argparse import ArgumentParser , RawTextHelpFormatter
56
+ from pathlib import Path
56
57
import os
57
58
import sys
59
+ import tempfile
58
60
59
61
try :
60
62
this_file = __file__
@@ -111,7 +113,7 @@ def get_examples_dir():
111
113
112
114
113
115
def package_prefix_names ():
114
- # Note: shiboken6_generator is not needed for compile_using_pyinstaller ,
116
+ # Note: shiboken6_generator is not needed for compile_using_nuitka ,
115
117
# but building modules with cmake needs it.
116
118
return ["shiboken6" , "shiboken6_generator" , "PySide6" ]
117
119
@@ -225,6 +227,33 @@ def compile_using_pyinstaller():
225
227
log .info ("" )
226
228
227
229
230
+ def test_nuitka (example ):
231
+ testprog = "Nuitka"
232
+ name = os .path .splitext (os .path .basename (example ))[0 ]
233
+ print (f"Running { testprog } test of { name } " )
234
+ current_dir = os .getcwd ()
235
+ result = False
236
+ tmpdirname = tempfile .mkdtemp ()
237
+ try :
238
+ os .chdir (tmpdirname )
239
+ cmd = [sys .executable , "-m" , "nuitka" , "--run" , example ]#, "--standalone"]
240
+ exit_code = run_process (cmd )
241
+ result = True
242
+ except RuntimeError as e :
243
+ print (str (e ))
244
+ finally :
245
+ os .chdir (current_dir )
246
+ print (f"Executable is in { tmpdirname } " )
247
+ return result
248
+
249
+
250
+ def run_nuitka_test (example ):
251
+ if test_nuitka (example ):
252
+ log .info ("" )
253
+ else :
254
+ raise RuntimeError (f"Failure running { example } with Nuitka." )
255
+
256
+
228
257
def run_make ():
229
258
args = []
230
259
if is_unix ():
@@ -287,17 +316,24 @@ def prepare_build_folder(src_path, build_folder_name):
287
316
def try_build_examples ():
288
317
examples_dir = get_examples_dir ()
289
318
290
- # This script should better go to the last place, here.
291
- # But because it is most likely to break, we put it here for now.
292
- log .info ("Attempting to build hello.py using PyInstaller." )
293
- # PyInstaller is loaded by coin_build_instructions.py, but not when
294
- # testing directly this script.
295
- src_path = os .path .join (examples_dir , "installer_test" )
296
- prepare_build_folder (src_path , "pyinstaller" )
297
319
298
- compile_using_pyinstaller ()
299
- run_compiled_script (os .path .join (src_path ,
300
- "pyinstaller" , "dist" , "hello_app" , "hello_app" ))
320
+ # Disabled PyInstaller until it supports PySide 6
321
+ if False :
322
+ # But because it is most likely to break, we put it here for now.
323
+ log .info ("Attempting to build hello.py using PyInstaller." )
324
+ # PyInstaller is loaded by coin_build_instructions.py, but not when
325
+ # testing directly this script.
326
+ src_path = os .path .join (examples_dir , "installer_test" )
327
+ prepare_build_folder (src_path , "pyinstaller" )
328
+ compile_using_pyinstaller ()
329
+ run_compiled_script (os .path .join (src_path ,
330
+ "pyinstaller" , "dist" , "hello_app" , "hello_app" ))
331
+
332
+ src_path = Path (examples_dir ) / "installer_test"
333
+ log .info ("Attempting to build hello.py using Nuitka." )
334
+ # Nuitka is loaded by coin_build_instructions.py, but not when
335
+ # testing directly this script.
336
+ run_nuitka_test (os .fspath (src_path / "hello.py" ))
301
337
302
338
log .info ("Attempting to build and run samplebinding using cmake." )
303
339
src_path = os .path .join (examples_dir , "samplebinding" )
@@ -307,11 +343,12 @@ def try_build_examples():
307
343
run_make_install ()
308
344
execute_script (os .path .join (src_path , "main.py" ))
309
345
310
- log .info ("Attempting to build scriptableapplication using cmake." )
311
- src_path = os .path .join (examples_dir , "scriptableapplication" )
312
- prepare_build_folder (src_path , "cmake" )
313
- generate_build_cmake ()
314
- run_make ()
346
+ log .info ("*** Defunct: build scriptableapplication using cmake." )
347
+ # log.info("Attempting to build scriptableapplication using cmake.")
348
+ # src_path = os.path.join(examples_dir, "scriptableapplication")
349
+ # prepare_build_folder(src_path, "cmake")
350
+ # generate_build_cmake()
351
+ # run_make()
315
352
316
353
log .info ("Attempting to build scriptableapplication using qmake." )
317
354
src_path = os .path .join (examples_dir , "scriptableapplication" )
0 commit comments