def action(stage_dir, root, path): command = [ sys.executable, os.path.join("..", "..", "bin", "nuitka"), "--module", "--output-dir", stage_dir, "--recurse-none", "--remove-output" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(path) try: subprocess.check_call(command) except subprocess.CalledProcessError: my_print("Falling back to full comparison due to error exit.") compareWithCPython(dirname=None, filename=path, extra_flags=["expect_failure"], search_mode=search_mode, needs_2to3=False) else: my_print("OK") if os.name == "nt": suffix = "pyd" else: suffix = "so" target_filename = os.path.basename(path).replace(".py", '.' + suffix) target_filename = target_filename.replace('(', "").replace(')', "") os.unlink(os.path.join(stage_dir, target_filename))
def runValgrind(descr, test_case, args): my_print(descr, file=sys.stderr, end="... ") log_base = test_case[:-3] if test_case.endswith(".py") else test_case log_file = log_base + ".log" valgrind_options = "-q --tool=callgrind --callgrind-out-file=%s" % log_file command = ["valgrind"] + valgrind_options.split() + list(args) process = subprocess.Popen(args=command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) _stdout_valgrind, stderr_valgrind = process.communicate() exit_valgrind = process.returncode assert exit_valgrind == 0, stderr_valgrind my_print("OK", file=sys.stderr) try: for line in open(log_file): if line.startswith("summary:"): return int(line.split()[1]) else: assert False finally: os.unlink(log_file)
def executePASS5(): my_print( "PASS 5: Compiling the compiler 'nuitka' package to single '.so' file." ) path = os.path.join("..", "..", "nuitka") command = [ os.environ["PYTHON"], nuitka_main_path, path, "--plugin-enable=pylint-warnings", "--output-dir=%s" % tmp_dir, "--recurse-all", "--recurse-not-to=PyQt4", "--recurse-not-to=nuitka.build.inline_copy", "--recurse-dir=%s" % path, "--module", path ] result = subprocess.call( command ) if result != 0: sys.exit(result) os.unlink(os.path.join(tmp_dir, "nuitka.so")) shutil.rmtree(os.path.join(tmp_dir, "nuitka.build"))
def executePASS5(): my_print( "PASS 5: Compiling the compiler 'nuitka' package to single '.so' file." ) path = os.path.join("..", "..", "nuitka") command = [ os.environ["PYTHON"], nuitka_main_path, path, "--output-dir=%s" % tmp_dir, "--recurse-all", "--recurse-dir=%s" % path, "--module", path ] result = subprocess.call( command ) if result != 0: sys.exit(result) os.unlink(os.path.join(tmp_dir, "nuitka.so")) shutil.rmtree(os.path.join(tmp_dir, "nuitka.build"))
def action(stage_dir, root, path): command = [ sys.executable, os.path.join("..", "..", "bin", "nuitka"), "--stand", "--run", "--output-dir", stage_dir, "--remove-output" ] filename = os.path.join(stage_dir, "importer.py") assert path.startswith(root) module_name = path[len(root) + 1:] module_name = module_name.split(".")[0] module_name = module_name.replace(os.path.sep, ".") with open(filename, "w") as output: output.write("import " + module_name + "\n") output.write("print('OK')") command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(filename) try: output = subprocess.check_output(command).splitlines() assert output[-1] == "OK", output except Exception as e: print(e) sys.exit(1) else: my_print("OK") shutil.rmtree(filename[:-3] + ".dist")
def runValgrind(descr, test_case, args): my_print(descr, file = sys.stderr, end = "... ") log_base = test_case[:-3] if test_case.endswith(".py") else test_case log_file = log_base + ".log" valgrind_options = "-q --tool=callgrind --callgrind-out-file=%s" % log_file command = ["valgrind"] + valgrind_options.split() + list(args) process = subprocess.Popen( args = command, stdout = subprocess.PIPE, stderr = subprocess.PIPE ) _stdout_valgrind, stderr_valgrind = process.communicate() exit_valgrind = process.returncode assert exit_valgrind == 0, stderr_valgrind my_print("OK", file = sys.stderr) try: for line in open(log_file): if line.startswith("summary:"): return int(line.split()[1]) else: assert False finally: os.unlink(log_file)
def executePASS4(): my_print("PASS 4: Compiling the compiler running from single exe.") exe_path = os.path.join(tmp_dir, "nuitka.exe") compileAndCompareWith(exe_path) my_print("OK.")
def diffRecursive(dir1, dir2): done = set() for filename in os.listdir(dir1): path1 = os.path.join(dir1, filename) path2 = os.path.join(dir2, filename) done.add(path1) # Skip these binary files of course. if filename.endswith(".o") or \ filename.endswith(".os") or \ filename.endswith(".obj"): continue # Skip scons build database if filename == ".sconsign.dblite": continue if not os.path.exists(path2): sys.exit("Only in %s: %s" % (dir1, filename)) if os.path.isdir(path1): diffRecursive(path1, path2) elif os.path.isfile(path1): fromdate = time.ctime(os.stat(path1).st_mtime) todate = time.ctime(os.stat(path2).st_mtime) diff = difflib.unified_diff( a = open(path1, "rb").readlines(), b = open(path2, "rb").readlines(), fromfile = path1, tofile = path2, fromfiledate = fromdate, tofiledate = todate, n = 3 ) result = list(diff) if result: for line in result: my_print(line) sys.exit(1) else: assert False, path1 for filename in os.listdir(dir2): path1 = os.path.join(dir1, filename) path2 = os.path.join(dir2, filename) if path1 in done: continue if not os.path.exists(path1): sys.exit("Only in %s: %s" % (dir2, filename))
def diffRecursive(dir1, dir2): done = set() for filename in os.listdir(dir1): path1 = os.path.join(dir1, filename) path2 = os.path.join(dir2, filename) done.add(path1) # Skip these binary files of course. if filename.endswith(".o") or \ filename.endswith(".os") or \ filename.endswith(".obj"): continue # Skip scons build database if filename == ".sconsign.dblite": continue if not os.path.exists(path2): sys.exit("Only in %s: %s" % (dir1, filename)) if os.path.isdir(path1): diffRecursive(path1, path2) elif os.path.isfile(path1): fromdate = time.ctime(os.stat(path1).st_mtime) todate = time.ctime(os.stat(path2).st_mtime) diff = difflib.unified_diff( a = readSource(path1).splitlines(), b = readSource(path2).splitlines(), fromfile = path1, tofile = path2, fromfiledate = fromdate, tofiledate = todate, n = 3 ) result = list(diff) if result: for line in result: my_print(line) sys.exit(1) else: assert False, path1 for filename in os.listdir(dir2): path1 = os.path.join(dir1, filename) path2 = os.path.join(dir2, filename) if path1 in done: continue if not os.path.exists(path1): sys.exit("Only in %s: %s" % (dir2, filename))
def compileAndCompareWith(nuitka): base_dir = os.path.join("..", "..") for package in PACKAGE_LIST: package = package.replace('/', os.path.sep) source_dir = os.path.join(base_dir, package) for filename in sorted(os.listdir(source_dir)): if not filename.endswith(".py"): continue if filename.startswith(".#"): continue path = os.path.join(source_dir, filename) if filename != "__init__.py": my_print("Compiling", path) target = filename.replace(".py", ".build") target_dir = os.path.join(tmp_dir, target) if os.path.exists(target_dir): shutil.rmtree(target_dir) command = [ nuitka, "--module", "--recurse-none", "--plugin-enable=pylint-warnings", "--output-dir=%s"% tmp_dir, path ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() result = subprocess.call( command ) if result != 0: sys.exit(result) diffRecursive(os.path.join(package, target), target_dir) shutil.rmtree(target_dir) if os.name == "nt": target_filename = filename.replace(".py", ".pyd") else: target_filename = filename.replace(".py", ".so") os.unlink(os.path.join(tmp_dir, target_filename))
def executePASS2(): my_print( "PASS 2: Compiling from compiler running from .exe and many .so files." ) # Windows will load the compiled modules (pyd) only from PYTHONPATH, so we # have to add it. if os.name == "nt": os.environ[ "PYTHONPATH" ] = ":".join( PACKAGE_LIST ) compileAndCompareWith( os.path.join( ".", "nuitka.exe" ) ) # Undo the damage from above. if os.name == "nt": del os.environ[ "PYTHONPATH" ] my_print( "OK." )
def action(stage_dir, root, path): command = [ sys.executable, os.path.join( "..", "..", "bin", "nuitka" ), "--module", "--output-dir", stage_dir, "--recurse-none", "--remove-output" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(path) try: subprocess.check_call(command) except subprocess.CalledProcessError: my_print("Falling back to full comparison due to error exit.") compareWithCPython( dirname = None, filename = path, extra_flags = ["expect_failure"], search_mode = search_mode, needs_2to3 = False ) else: my_print("OK") if os.name == "nt": suffix = "pyd" else: suffix = "so" target_filename = os.path.basename(path).replace(".py",'.'+suffix) target_filename = target_filename.replace('(',"").replace(')',"") os.unlink( os.path.join( stage_dir, target_filename ) )
def executePASS2(): my_print( "PASS 2: Compiling from compiler running from .exe and many .so files." ) # Windows will load the compiled modules (pyd) only from PYTHONPATH, so we # have to add it. if os.name == "nt": os.environ["PYTHONPATH"] = ':'.join(PACKAGE_LIST) compileAndCompareWith(os.path.join('.', "nuitka.exe")) # Undo the damage from above. if os.name == "nt": del os.environ["PYTHONPATH"] my_print("OK.")
def action(stage_dir, root, path): command = [ sys.executable, os.path.join( "..", "..", "bin", "nuitka" ), "--stand", "--run", "--output-dir", stage_dir, "--remove-output" ] filename = os.path.join(stage_dir, "importer.py") assert path.startswith(root) module_name = path[len(root)+1:] module_name = module_name.split(".")[0] module_name = module_name.replace(os.path.sep, ".") with open(filename, "w") as output: output.write("import " + module_name + "\n") output.write("print('OK')") command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(filename) try: output = subprocess.check_output(command).splitlines() assert output[-1] == "OK", output except Exception as e: print(e) sys.exit(1) else: my_print("OK") shutil.rmtree(filename[:-3] + ".dist")
def executePASS3(): my_print( "PASS 3: Compiling from compiler running from .py files to single .exe." ) exe_path = os.path.join(tmp_dir, "nuitka.exe") if os.path.exists(exe_path): os.unlink(exe_path) build_path = os.path.join(tmp_dir, "nuitka.build") if os.path.exists(build_path): shutil.rmtree(build_path) path = os.path.join("..", "..", "bin", "nuitka") my_print("Compiling", path) command = [ os.environ["PYTHON"], nuitka_main_path, path, "--output-dir=%s" % tmp_dir, "--exe", "--recurse-all" ] result = subprocess.call(command) if result != 0: sys.exit(result) shutil.rmtree(build_path) my_print("OK.")
def executePASS3(): my_print( "PASS 3: Compiling from compiler running from .py files to single .exe." ) exe_path = os.path.join( tmp_dir, "nuitka.exe" ) if os.path.exists( exe_path ): os.unlink( exe_path ) build_path = os.path.join( tmp_dir, "nuitka.build" ) if os.path.exists( build_path ): shutil.rmtree( build_path ) path = os.path.join( "..", "..", "bin", "nuitka" ) my_print( "Compiling", path ) command = [ os.environ[ "PYTHON" ], nuitka_main_path, path, "--output-dir=%s" % tmp_dir, "--exe", "--recurse-all" ] result = subprocess.call( command ) if result != 0: sys.exit( result ) shutil.rmtree( build_path ) my_print( "OK." )
python_version = setup(needs_io_encoding = True) search_mode = createSearchMode() for filename in sorted(os.listdir('.')): if not filename.endswith(".py"): continue if not decideFilenameVersionSkip(filename): continue active = search_mode.consider( dirname = None, filename = filename ) if active: extra_flags = ["expect_failure", "remove_output"] compareWithCPython( dirname = None, filename = filename, extra_flags = extra_flags, search_mode = search_mode, needs_2to3 = False ) else: my_print("Skipping", filename) search_mode.finish()
) python_version = setup(needs_io_encoding=True) search_mode = createSearchMode() start_at = sys.argv[2] if len(sys.argv) > 2 else None if start_at: active = False else: active = True os_path = os.path.normcase(os.path.dirname(os.__file__)) my_print("Using standard library path", os_path) try: import numpy extra_path = os.path.normcase( os.path.dirname(os.path.dirname(numpy.__file__))) my_print("Using extra library path", extra_path) except ImportError: extra_path = os_path try: import matplotlib extra_path2 = os.path.normcase(
if not active and start_at in ( filename, path ): active = True extra_flags = [ "expect_success", "remove_output", "module_mode", "two_step_execution" ] # The use of "__main__" in the test package gives a warning. if filename == "sub_package": extra_flags.append( "ignore_warnings" ) if active: my_print( "Consider output of recursively compiled program:", path ) for filename_main in os.listdir( filename ): if not os.path.isdir(os.path.join(filename,filename_main)): continue if filename_main not in ( "..", "." ): break else: sys.exit( """\ Error, no package in dir '%s' found, incomplete test case.""" % filename ) os.environ[ "NUITKA_EXTRA_OPTIONS" ] = \ "--recurse-to=%s" % os.path.basename(filename_main)
def executePASS1(): my_print("PASS 1: Compiling from compiler running from .py files.") base_dir = os.path.join("..", "..") for package in PACKAGE_LIST: package = package.replace('/', os.path.sep) source_dir = os.path.join(base_dir, package) target_dir = package if os.path.exists(target_dir): shutil.rmtree(target_dir) os.mkdir(target_dir) for filename in os.listdir(target_dir): if filename.endswith(".so"): path = os.path.join(target_dir, filename) os.unlink(path) for filename in sorted(os.listdir(source_dir)): if not filename.endswith(".py"): continue if filename.startswith(".#"): continue path = os.path.join(source_dir, filename) if filename != "__init__.py": my_print("Compiling", path) command = [ os.environ["PYTHON"], nuitka_main_path, "--module", "--recurse-none", "--output-dir=%s" % target_dir, path ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() result = subprocess.call(command) if result != 0: sys.exit(result) else: shutil.copyfile(path, os.path.join(target_dir, filename)) my_print("Compiling", nuitka_main_path) shutil.copyfile(nuitka_main_path, "nuitka.py") command = [ os.environ["PYTHON"], nuitka_main_path, "--recurse-none", "--output-dir=.", "nuitka.py" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() result = subprocess.call(command) if result != 0: sys.exit(result) scons_inline_copy_path = os.path.join(base_dir, "nuitka", "build", "inline_copy") if os.path.exists(scons_inline_copy_path): shutil.copytree(scons_inline_copy_path, os.path.join("nuitka", "build", "inline_copy")) shutil.copy(os.path.join(base_dir, "nuitka", "build", "SingleExe.scons"), os.path.join("nuitka", "build", "SingleExe.scons")) shutil.copytree(os.path.join(base_dir, "nuitka", "build", "static_src"), os.path.join("nuitka", "build", "static_src")) shutil.copytree(os.path.join(base_dir, "nuitka", "build", "include"), os.path.join("nuitka", "build", "include"))
path = os.path.relpath(filename) if not active and start_at in (filename, path): active = True extra_flags = [ "expect_success", "remove_output", "module_mode", "two_step_execution" ] # The use of "__main__" in the test package gives a warning. if filename == "sub_package": extra_flags.append("ignore_warnings") if active: my_print("Consider output of recursively compiled program:", path) for filename_main in os.listdir(filename): if not os.path.isdir(os.path.join(filename, filename_main)): continue if filename_main not in ("..", "."): break else: sys.exit("""\ Error, no package in dir '%s' found, incomplete test case.""" % filename) os.environ[ "NUITKA_EXTRA_OPTIONS" ] = \ "--recurse-to=%s" % os.path.basename(filename_main) os.environ[ "NUITKA_EXTRA_OPTIONS" ] += \
def compilePath(path): global active for root, dirnames, filenames in os.walk(path): dirnames.sort() filenames = [ filename for filename in filenames if filename.endswith(".py") if filename not in blacklist ] for filename in sorted(filenames): if '(' in filename: continue # Avoid too complex code for main program. if filename == "idnadata.py": continue path = os.path.join(root, filename) if not active and start_at in (filename, path): active = True if not active: continue command = [ sys.executable, os.path.join( "..", "..", "bin", "nuitka" ), "--module", "--output-dir", stage_dir, "--recurse-none", "--remove-output" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(path) my_print(path, ':', end = ' ') sys.stdout.flush() try: subprocess.check_call(command) except subprocess.CalledProcessError: my_print("Falling back to full comparison due to error exit.") compareWithCPython( dirname = None, filename = path, extra_flags = ["expect_failure"], search_mode = search_mode, needs_2to3 = False ) else: my_print("OK") if os.name == "nt": suffix = "pyd" else: suffix = "so" target_filename = os.path.basename(path).replace(".py",'.'+suffix) target_filename = target_filename.replace('(',"").replace(')',"") os.unlink( os.path.join( stage_dir, target_filename ) )
# import sys, os # Find common code relative in file system. Not using packages for test stuff. sys.path.insert( 0, os.path.normpath( os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))) from test_common import ( executeReferenceChecked, checkReferenceCount, my_print, ) if not hasattr(sys, "gettotalrefcount"): my_print("Warning, using non-debug Python makes this test ineffective.") sys.gettotalrefcount = lambda: 0 x = 17 # Python2 only syntax things are here. def simpleFunction1(): try: raise TypeError, (3, x, x, x) except TypeError: pass def simpleFunction2(): try:
"PySideUsing.py" ) for filename in sorted(os.listdir('.')): if not filename.endswith(".py"): continue if not decideFilenameVersionSkip(filename): continue path = os.path.relpath(filename) active = search_mode.consider(dirname = None, filename = filename) if not active: my_print("Skipping", filename) continue extra_flags = [ "expect_success", "standalone", "remove_output" ] if filename == "PySideUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith("2.6") or \ python_version.startswith("3.2"): reportSkip(".", filename, "irrelevant Python version.") continue
if filename == "Importing.py": extra_flags.append("ignore_warnings") # TODO: Nuitka does not give output for ignored exception in dtor, this is # not fully compatible and potentially an error. if filename == "YieldFrom33.py": extra_flags.append("ignore_stderr") active = search_mode.consider( dirname = None, filename = filename ) if active: if filename.startswith("Referencing") and not hasDebugPython(): my_print("Skipped (no debug Python)") continue needs_2to3 = python_version.startswith('3') and \ not filename.endswith("32.py") and \ not filename.endswith("33.py") with withPythonPathChange(".."): compareWithCPython( dirname = None, filename = filename, extra_flags = extra_flags, search_mode = search_mode, needs_2to3 = needs_2to3 ) else:
# This tests warns about an package relative import despite # being in no package. if filename == "Importing.py": extra_flags.append("ignore_warnings") # TODO: Nuitka does not give output for ignored exception in dtor, this is # not fully compatible and potentially an error. if filename == "YieldFrom33.py": extra_flags.append("ignore_stderr") active = search_mode.consider(dirname=None, filename=filename) if active: if filename.startswith("Referencing") and not hasDebugPython(): my_print("Skipped (no debug Python)") continue needs_2to3 = python_version.startswith('3') and \ not filename.endswith("32.py") and \ not filename.endswith("33.py") with withPythonPathChange(".."): compareWithCPython(dirname=None, filename=filename, extra_flags=extra_flags, search_mode=search_mode, needs_2to3=needs_2to3) else: my_print("Skipping", filename)
def compilePath(path): global active for root, dirnames, filenames in os.walk(path): dirnames.sort() filenames = [ filename for filename in filenames if filename.endswith(".py") if filename not in blacklist ] for filename in sorted(filenames): if '(' in filename: continue # Avoid too complex code for main program. if filename == "idnadata.py": continue path = os.path.join(root, filename) if not active and start_at in (filename, path): active = True if not active: continue command = [ sys.executable, os.path.join("..", "..", "bin", "nuitka"), "--module", "--output-dir", stage_dir, "--recurse-none", "--remove-output" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() command.append(path) my_print(path, ':', end=' ') sys.stdout.flush() try: subprocess.check_call(command) except subprocess.CalledProcessError: my_print("Falling back to full comparison due to error exit.") compareWithCPython(dirname=None, filename=path, extra_flags=["expect_failure"], search_mode=search_mode, needs_2to3=False) else: my_print("OK") if os.name == "nt": suffix = "pyd" else: suffix = "so" target_filename = os.path.basename(path).replace( ".py", '.' + suffix) target_filename = target_filename.replace('(', "").replace(')', "") os.unlink(os.path.join(stage_dir, target_filename))
if not decideFilenameVersionSkip(filename): continue path = os.path.relpath(filename) if not active and start_at in (filename, path): active = True extra_flags = ["expect_success", "standalone", "remove_output"] if filename == "PySideUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith("2.6") or \ python_version.startswith("3.2"): my_print("Skipping", filename, "not relevant.") continue if not hasModule("PySide.QtCore"): my_print("Skipping", filename, "PySide not installed for", python_version, "but test needs it.") continue # For the warnings. extra_flags.append("ignore_stderr") if filename == "PyQtUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith("2.6") or \ python_version.startswith("3.2"):
path = filename if not active and start_at in (filename, path): active = True extra_flags = ["expect_success"] if active: # Apply 2to3 conversion if necessary. assert type(python_version) is bytes if python_version.startswith(b"3"): path = convertUsing2to3(path) my_print("Consider", path, end=" ") command = [ os.environ["PYTHON"], os.path.join("..", "..", "bin", "nuitka"), "--dump-xml", "--module", path ] result = check_output(command) # Parse the result into XML and check it. root = lxml.etree.fromstring(result) module_body = root[0] module_statements_sequence = module_body[0] assert len(module_statements_sequence) == 1
elif nuitka: sys.exit("Error, nuitka binary '%s' not found." % nuitka) from test_common import ( my_print, setup, convertUsing2to3, getTempDir, decideFilenameVersionSkip, ) python_version = setup(silent = True) assert os.path.exists(test_case), (test_case, os.getcwd()) my_print("PYTHON='%s'" % python_version) my_print("TEST_CASE_HASH='%s'" % md5.md5(open(test_case).read()).hexdigest()) needs_2to3 = python_version.startswith('3') and \ not test_case.endswith("32.py") and \ not test_case.endswith("33.py") if options.target_dir: shutil.copy( test_case, os.path.join(options.target_dir, os.path.basename(test_case)) ) if needs_2to3: test_case = convertUsing2to3(test_case)
] result = subprocess.call(command) if result != 0: sys.exit(result) os.unlink(os.path.join(tmp_dir, "nuitka.so")) shutil.rmtree(os.path.join(tmp_dir, "nuitka.build")) cross_compilation = False executePASS1() if cross_compilation: my_print("PASS 2: Skipped for cross-compilation case.") else: executePASS2() executePASS3() if cross_compilation: my_print("PASS 4: Skipped for cross-compilation case.") else: executePASS4() shutil.rmtree("nuitka") executePASS5() os.unlink(os.path.join(tmp_dir, "nuitka.exe"))
result = subprocess.call( command ) if result != 0: sys.exit(result) os.unlink(os.path.join(tmp_dir, "nuitka.so")) shutil.rmtree(os.path.join(tmp_dir, "nuitka.build")) cross_compilation = False executePASS1() if cross_compilation: my_print("PASS 2: Skipped for cross-compilation case.") else: executePASS2() executePASS3() if cross_compilation: my_print("PASS 4: Skipped for cross-compilation case.") else: executePASS4() shutil.rmtree("nuitka") executePASS5() os.unlink(os.path.join(tmp_dir, "nuitka.exe"))
def executePASS1(): my_print("PASS 1: Compiling from compiler running from .py files.") base_dir = os.path.join("..", "..") for package in PACKAGE_LIST: package = package.replace('/', os.path.sep) source_dir = os.path.join(base_dir, package) target_dir = package if os.path.exists(target_dir): shutil.rmtree(target_dir) os.mkdir(target_dir) for filename in os.listdir(target_dir): if filename.endswith(".so"): path = os.path.join(target_dir, filename) os.unlink(path) for filename in sorted(os.listdir(source_dir)): if not filename.endswith(".py"): continue if filename.startswith(".#"): continue path = os.path.join(source_dir, filename) if filename != "__init__.py": my_print("Compiling", path) command = [ os.environ["PYTHON"], nuitka_main_path, "--module", "--recurse-none", "--plugin-enable=pylint-warnings", "--output-dir=%s" % target_dir, path ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() result = subprocess.call( command ) if result != 0: sys.exit(result) else: shutil.copyfile(path, os.path.join(target_dir, filename)) my_print("Compiling", nuitka_main_path) shutil.copyfile(nuitka_main_path, "nuitka.py") command = [ os.environ["PYTHON"], nuitka_main_path, "--recurse-none", "--output-dir=.", "--python-flag=-S", "nuitka.py" ] command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split() result = subprocess.call( command ) if result != 0: sys.exit(result) scons_inline_copy_path = os.path.join( base_dir, "nuitka", "build", "inline_copy" ) if os.path.exists(scons_inline_copy_path): shutil.copytree( scons_inline_copy_path, os.path.join("nuitka", "build", "inline_copy") ) shutil.copy( os.path.join(base_dir, "nuitka", "build", "SingleExe.scons"), os.path.join("nuitka", "build", "SingleExe.scons") ) shutil.copytree( os.path.join(base_dir, "nuitka", "build", "static_src"), os.path.join("nuitka", "build", "static_src") ) shutil.copytree( os.path.join(base_dir, "nuitka", "build", "include"), os.path.join("nuitka", "build", "include") )
active = search_mode.consider( dirname = None, filename = filename ) extra_flags = ["expect_success"] if active: # Apply 2to3 conversion if necessary. if python_version.startswith('3'): filename, changed = convertUsing2to3(filename) else: changed = False my_print("Consider", filename, end = ' ') command = [ os.environ["PYTHON"], os.path.abspath(os.path.join("..", "..", "bin", "nuitka")), "--dump-xml", "--module", filename ] if search_mode.isCoverage(): # To avoid re-execution, which is not acceptable to coverage. if "PYTHONHASHSEED" not in os.environ: os.environ["PYTHONHASHSEED"] = '0'
) python_version = setup(needs_io_encoding = True) search_mode = createSearchMode() start_at = sys.argv[2] if len(sys.argv) > 2 else None if start_at: active = False else: active = True os_path = os.path.normcase(os.path.dirname(os.__file__)) my_print("Using standard library path", os_path) try: import numpy extra_path = os.path.normcase( os.path.dirname( os.path.dirname( numpy.__file__ ) ) ) my_print("Using extra library path", extra_path) except ImportError: extra_path = os_path
"PySideUsing.py" ) for filename in sorted(os.listdir('.')): if not filename.endswith(".py"): continue if not decideFilenameVersionSkip(filename): continue path = os.path.relpath(filename) active = search_mode.consider(dirname = None, filename = filename) if not active: my_print("Skipping", filename) continue extra_flags = [ "expect_success", "standalone", "remove_output" ] if filename == "PySideUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith("2.6") or \ python_version.startswith("3.2"): my_print("Skipping", filename, "not relevant.") continue
nuitka = os.path.abspath(nuitka) elif nuitka: sys.exit("Error, nuitka binary '%s' not found." % nuitka) from test_common import ( my_print, setup, convertUsing2to3, getTempDir ) python_version = setup(silent = True) assert os.path.exists(test_case), (test_case, os.getcwd()) my_print("PYTHON='%s'" % python_version) my_print("PYTHON_BINARY='%s'" % os.environ["PYTHON"]) my_print("TEST_CASE_HASH='%s'" % hashlib.md5(open(test_case, "rb").read()).hexdigest()) needs_2to3 = python_version.startswith('3') and \ not test_case.endswith("32.py") and \ not test_case.endswith("33.py") if options.target_dir: shutil.copy( test_case, os.path.join(options.target_dir, os.path.basename(test_case)) ) if needs_2to3:
path = filename if not active and start_at in (filename, path): active = True extra_flags = ["expect_success"] if active: # Apply 2to3 conversion if necessary. if python_version.startswith("3"): path, changed = convertUsing2to3(path) else: changed = True my_print("Consider", path, end = " ") command = [ os.environ["PYTHON"], os.path.join("..", "..", "bin", "nuitka"), "--dump-xml", "--module", path ] result = check_output( command ) # Parse the result into XML and check it. root = lxml.etree.fromstring(result)
for filename in sorted(os.listdir('.')): if not filename.endswith(".py") or filename.startswith("run_"): continue active = search_mode.consider(dirname=None, filename=filename) extra_flags = ["expect_success"] if active: # Apply 2to3 conversion if necessary. if python_version.startswith('3'): filename, changed = convertUsing2to3(filename) else: changed = False my_print("Consider", filename, end=' ') command = [ os.environ["PYTHON"], os.path.abspath(os.path.join("..", "..", "bin", "nuitka")), "--dump-xml", "--module", filename ] if search_mode.isCoverage(): # To avoid re-execution, which is not acceptable to coverage. if "PYTHONHASHSEED" not in os.environ: os.environ["PYTHONHASHSEED"] = '0' # Coverage modules hates Nuitka to re-execute, and so we must avoid # that. python_path = subprocess.check_output([
options.cpython = "" nuitka = options.nuitka if os.path.exists(nuitka): nuitka = os.path.abspath(nuitka) elif nuitka: sys.exit("Error, nuitka binary '%s' not found." % nuitka) from test_common import (my_print, setup, convertUsing2to3, getTempDir) python_version = setup(silent=True) assert os.path.exists(test_case), (test_case, os.getcwd()) my_print("PYTHON='%s'" % python_version) my_print("PYTHON_BINARY='%s'" % os.environ["PYTHON"]) my_print("TEST_CASE_HASH='%s'" % hashlib.md5(open(test_case, "rb").read()).hexdigest()) needs_2to3 = python_version.startswith('3') and \ not test_case.endswith("32.py") and \ not test_case.endswith("33.py") if options.target_dir: shutil.copy(test_case, os.path.join(options.target_dir, os.path.basename(test_case))) if needs_2to3: test_case, needs_delete = convertUsing2to3(test_case)
if start_at: active = False else: active = True for filename in sorted(os.listdir(".")): if not filename.endswith(".py") or filename == "run_all.py": continue path = filename if not active and start_at in (filename, path): active = True # Some syntax errors are for Python3 only. if filename == "Importing2.py" and python_version < "3": extra_flags = ["remove_output"] elif filename == "GeneratorReturn2.py" and python_version >= "3.3": extra_flags = ["remove_output"] else: extra_flags = ["expect_failure", "remove_output"] if active: compareWithCPython(path=path, extra_flags=extra_flags, search_mode=search_mode, needs_2to3=False) else: my_print("Skipping", filename)
if not active and start_at in (filename, path): active = True extra_flags = [ "expect_success", "standalone", "remove_output" ] if filename == "PySideUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith(b"2.6") or \ python_version.startswith(b"3.2"): my_print("Skipping", filename, "not relevant.") continue if not hasModule("PySide.QtCore"): my_print( "Skipping", filename, "PySide not installed for", python_version, "but test needs it." ) continue # For the warnings. extra_flags.append( "ignore_stderr" ) if filename == "PyQtUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now.
0, os.path.normpath( os.path.join( os.path.dirname(os.path.abspath(__file__)), ".." ) ) ) from test_common import ( executeReferenceChecked, checkReferenceCount, my_print, ) if not hasattr(sys, "gettotalrefcount"): my_print("Warning, using non-debug Python makes this test ineffective.") sys.gettotalrefcount = lambda : 0 def simpleFunction1(): def abc(*, exc=IOError): pass for _ in range(100): abc() def simpleFunction2(): def abc(*, exc=IOError): raise ValueError from None try: abc() except (ValueError, TypeError):
# where it won't call compiled functions as slots. "PySideUsing.py") for filename in sorted(os.listdir('.')): if not filename.endswith(".py"): continue if not decideFilenameVersionSkip(filename): continue path = os.path.relpath(filename) active = search_mode.consider(dirname=None, filename=filename) if not active: my_print("Skipping", filename) continue extra_flags = ["expect_success", "standalone", "remove_output"] if filename == "PySideUsing.py": # Don't test on platforms not supported by current Debian testing, and # which should be considered irrelevant by now. if python_version.startswith("2.6") or \ python_version.startswith("3.2"): reportSkip("irrelevant Python version", ".", filename) continue if not hasModule("PySide.QtCore"): reportSkip( "PySide not installed for this Python version, but test needs it",