def main(): nuitka_version = getNuitkaVersion() branch_name = checkBranchName() # Only real master releases so far. assert branch_name == "master", branch_name assert "pre" not in nuitka_version and "rc" not in nuitka_version print("Uploading Nuitka '%s'" % nuitka_version) # Need to remove the contents from the Rest, or else PyPI will not render # it. Stupid but true. with open("README.rst", "rb") as f: contents = f.read() contents = contents.replace(b".. contents::\n", b"") contents = contents.replace( b".. image:: doc/images/Nuitka-Logo-Symbol.png\n", b"") contents = contents.replace( b".. raw:: pdf\n\n PageBreak oneColumn\n SetPageCounter 1", b"") with open("README.rst", "wb") as f: f.write(contents) # Make sure it worked. with open("README.rst", "rb") as f: contents = f.read() assert b".. contents" not in contents shutil.rmtree("check_nuitka", ignore_errors=True) shutil.rmtree("dist", ignore_errors=True) print("Creating documentation.") createReleaseDocumentation() print("Creating source distribution.") assert os.system( "umask 0022 && chmod -R a+rX . && python setup.py sdist") == 0 print("Creating a virtualenv for quick test:") with withVirtualenv("check_nuitka") as venv: print("Installing Nuitka into virtualenv:") print("*" * 40) venv.runCommand("python -m pip install ../dist/Nuitka*.tar.gz") print("*" * 40) print("Compiling basic test:") print("*" * 40) venv.runCommand("nuitka-run ../tests/basics/Asserts.py") print("*" * 40) if "check" not in sys.argv: print("Uploading source dist") assert os.system("twine upload dist/*") == 0 print("Uploaded.") else: print("Checked OK, not uploaded.")
def main(): nuitka_version = getNuitkaVersion() branch_name = checkBranchName() check_mode = "--check" in sys.argv # Only real main releases so far. if not check_mode: assert branch_name == "main", branch_name assert "pre" not in nuitka_version and "rc" not in nuitka_version my_print("Working on Nuitka %r." % nuitka_version, style="blue") shutil.rmtree("check_nuitka", ignore_errors=True) shutil.rmtree("dist", ignore_errors=True) my_print("Creating documentation.", style="blue") createReleaseDocumentation() my_print("Creating source distribution.", style="blue") assert os.system("umask 0022 && chmod -R a+rX . && python setup.py sdist") == 0 with withVirtualenv("venv_nuitka", style="blue") as venv: my_print("Installing Nuitka into virtualenv:", style="blue") my_print("*" * 40, style="blue") venv.runCommand("python -m pip install ../dist/Nuitka*.tar.gz") my_print("*" * 40, style="blue") my_print("Compiling basic test with runner:", style="blue") my_print("*" * 40, style="blue") venv.runCommand( "nuitka%d-run ../tests/basics/Asserts.py" % sys.version_info[0], style="blue", ) my_print("*" * 40, style="blue") my_print("Compiling basic test with recommended -m mode:", style="blue") my_print("*" * 40, style="blue") venv.runCommand( "python -m nuitka ../tests/basics/Asserts.py", style="blue", ) my_print("*" * 40, style="blue") assert os.system("twine check dist/*") == 0 if not check_mode: my_print("Uploading source dist") assert os.system("twine upload dist/*") == 0 my_print("Uploaded.") else: my_print("Checked OK, but not uploaded.")
def main(): # pylint: disable=broad-except,too-many-branches,too-many-locals,too-many-statements setup() # cache_dir is where the git clones are cached cache_dir = os.path.join(getCacheDir(), "pypi-git-clones") base_dir = os.getcwd() if not os.path.isdir(cache_dir): os.mkdir(cache_dir) search_mode = createSearchMode() results = [] # load json with open("packages.json", "r") as f: packages = json.load(f) for package_name, details in sorted(packages.items()): active = search_mode.consider(dirname=None, filename=package_name) if not active: continue if str is not bytes: # running on python3 if package_name in ("futures", "future"): reportSkip("Does not run on Python3", ".", package_name) if search_mode.abortIfExecuted(): break continue if os.name == "nt": if package_name in ("cryptography",): reportSkip("Not working on Windows", ".", package_name) if search_mode.abortIfExecuted(): break continue if package_name == "pyyaml": reportSkip("Not yet supported, see Issue #476", ".", package_name) if search_mode.abortIfExecuted(): break continue if package_name in ("pycparser", "numpy"): reportSkip("Not yet supported, see Issue #477", ".", package_name) if search_mode.abortIfExecuted(): break continue if package_name in ( "google-auth", # bdist_nuitka fails AttributeError: single_version_externally_managed "jinja2", # ModuleNotFoundError: No module named 'jinja2.tests' "pandas", # ModuleNotFoundError: No module named 'Cython' "pytz", # need to 'make build' "rsa", # Now uses Poetry (no setup.py) ): if search_mode.abortIfExecuted(): break continue package_dir = os.path.join(cache_dir, package_name) try: gitClone(package_name, details["url"], cache_dir) os.chdir(base_dir) with withVirtualenv( "venv_%s" % package_name, delete=False, style="blue" ) as venv: dist_dir = os.path.join(package_dir, "dist") # delete ignored tests if any if details["ignored_tests"]: for test in details["ignored_tests"]: venv.runCommand("rm -rf %s" % os.path.join(package_dir, test)) # setup for pytest cmds = [ "python -m pip install pytest", "cd %s" % os.path.join(os.path.dirname(nuitka.__file__), ".."), "python setup.py develop", "cd %s" % package_dir, ] if details["requirements_file"]: cmds.append( "python -m pip install -r %s" % details["requirements_file"] ) if details.get("extra_commands"): cmds += details["extra_commands"] # build uncompiled .whl cmds.append("python setup.py bdist_wheel") venv.runCommand(commands=cmds) # install and print out if the active .whl is compiled or not venv.runCommand( commands=[ "python -m pip install -U %s" % os.path.join(dist_dir, os.listdir(dist_dir)[0]), # use triple quotes for linux """python -c "print(getattr(__import__('%s'),'__compiled__','__uncompiled_version__'))" """ % details.get("package_name", package_name), ] ) # get uncompiled pytest results uncompiled_stdout, uncompiled_stderr = venv.runCommandWithOutput( commands=[ "cd %s" % package_dir, "python -m pytest --disable-warnings", ], style="blue", ) # clean up before building compiled .whl cmds = ["cd %s" % package_dir, "git clean -dfx"] if details.get("extra_commands"): cmds += details["extra_commands"] # build nuitka compiled .whl cmds.append("python setup.py bdist_nuitka") venv.runCommand(commands=cmds) # install and print out if the active .whl is compiled or not venv.runCommand( commands=[ "python -m pip install -U %s" % os.path.join(dist_dir, os.listdir(dist_dir)[0]), # use triple quotes for linux """python -c "print(getattr(__import__('%s'),'__compiled__','__uncompiled_version__'))" """ % details.get("package_name", package_name), ] ) # get compiled pytest results compiled_stdout, compiled_stderr = venv.runCommandWithOutput( commands=[ "cd %s" % package_dir, "python -m pytest --disable-warnings", ], style="blue", ) venv.runCommand(commands=["cd %s" % package_dir, "git clean -q -dfx"]) except Exception as e: my_print( "Package", package_name, "ran into an exception during execution, traceback: ", ) my_print(e) results.append((package_name, "ERROR", "ERROR")) if search_mode.abortIfExecuted(): break continue # compare outputs stdout_diff = compareOutput( "stdout", uncompiled_stdout, compiled_stdout, ignore_warnings=True, syntax_errors=True, ) stderr_diff = compareOutput( "stderr", uncompiled_stderr, compiled_stderr, ignore_warnings=True, syntax_errors=True, ) results.append((package_name, stdout_diff, stderr_diff)) exit_code = stdout_diff or stderr_diff my_print( "\n=================================================================================", "\n--- %s ---" % package_name, "exit_stdout:", stdout_diff, "exit_stderr:", stderr_diff, "\nError, outputs differed for package %s." % package_name if exit_code else "\nNo differences found for package %s." % package_name, "\n=================================================================================\n", style="red" if exit_code else "green", ) if exit_code != 0 and search_mode.abortOnFinding( dirname=None, filename=package_name ): break if search_mode.abortIfExecuted(): break search_mode.finish() # give a summary of all packages my_print( "\n\n=====================================SUMMARY=====================================", style="yellow", ) for package_name, stdout_diff, stderr_diff in results: my_print( package_name, "-", end=" ", style="red" if (stdout_diff or stderr_diff) else "green", ) my_print( "stdout:", stdout_diff, end=" ", style="red" if stdout_diff else "green" ) my_print( "stderr:", stderr_diff, end="", style="red" if stderr_diff else "green" ) my_print( "\n---------------------------------------------------------------------------------" ) my_print("TOTAL NUMBER OF PACKAGES TESTED: %s" % len(results), style="yellow") num_failed = 0 num_errors = 0 # tally the number of errors and failed for _, y, z in results: if type(y) is str: # this means the package ran into an exception num_errors += 1 elif y or z: num_failed += 1 my_print( "TOTAL PASSED: %s" % (len(results) - num_failed - num_errors), style="green" ) my_print("TOTAL FAILED (differences): %s" % num_failed, style="red") my_print("TOTAL ERRORS (exceptions): %s" % num_errors, style="red")
def main(): # Complex stuff, pylint: disable=too-many-locals,too-many-statements python_version = setup(needs_io_encoding=True) search_mode = createSearchMode() nuitka_dir = os.path.abspath(os.path.join(os.getcwd(), "..", "..")) for filename in sorted(os.listdir(".")): if (not os.path.isdir(filename) or filename.endswith( (".build", ".dist")) or filename.startswith("venv_")): continue filename = os.path.relpath(filename) if not decideFilenameVersionSkip(filename): continue active = search_mode.consider(dirname=None, filename=filename) if active: my_print("Consider distutils example:", filename) py3_only_examples = ("example_3", "nested_namespaces") if python_version < (3, ) and filename in py3_only_examples: reportSkip("Skipped, only relevant for Python3", ".", filename) continue case_dir = os.path.join(os.getcwd(), filename) removeDirectory(os.path.join(case_dir, "build"), ignore_errors=False) removeDirectory(os.path.join(case_dir, "dist"), ignore_errors=False) with withVirtualenv("venv_cpython") as venv: venv.runCommand(commands=[ 'cd "%s"' % case_dir, "python setup.py bdist_wheel" ]) dist_dir = os.path.join(case_dir, "dist") venv.runCommand('pip install "%s"' % (os.path.join(dist_dir, os.listdir(dist_dir)[0]))) runner_binary = os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "runner", ) if os.path.exists(runner_binary): # Need to call CPython binary for Windows. process = subprocess.Popen( args=[ os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "python", ), os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "runner", ), ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) else: assert os.path.exists(runner_binary + ".exe") process = subprocess.Popen( args=[runner_binary + ".exe"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdout_cpython, stderr_cpython = process.communicate() exit_cpython = process.returncode my_print("STDOUT CPython:") my_print(stdout_cpython) my_print("STDERR CPython:") my_print(stderr_cpython) assert exit_cpython == 0, exit_cpython my_print("EXIT was OK.") removeDirectory(os.path.join(case_dir, "build"), ignore_errors=False) removeDirectory(os.path.join(case_dir, "dist"), ignore_errors=False) with withVirtualenv("venv_nuitka") as venv: # Install nuitka from source. venv.runCommand(commands=[ 'cd "%s"' % nuitka_dir, "python setup.py install" ]) # Remove that left over from the install command. removeDirectory( path=os.path.join(nuitka_dir, "Nuitka.egg-info"), ignore_errors=False, ) # Create the wheel with Nuitka compilation. venv.runCommand(commands=[ 'cd "%s"' % case_dir, "python setup.py bdist_nuitka" ]) dist_dir = os.path.join(case_dir, "dist") venv.runCommand('pip install "%s"' % (os.path.join(dist_dir, os.listdir(dist_dir)[0]))) runner_binary = os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "runner", ) if os.path.exists(runner_binary): process = subprocess.Popen( args=[ os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "python", ), runner_binary, ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) else: assert os.path.exists(runner_binary + ".exe") process = subprocess.Popen( args=[runner_binary + ".exe"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdout_nuitka, stderr_nuitka = process.communicate() exit_nuitka = process.returncode my_print("STDOUT Nuitka:") my_print(stdout_nuitka) my_print("STDERR Nuitka:") my_print(stderr_nuitka) assert exit_nuitka == 0, exit_nuitka my_print("EXIT was OK.") exit_code_stdout = compareOutput( "stdout", stdout_cpython, stdout_nuitka, ignore_warnings=True, syntax_errors=True, ) exit_code_stderr = compareOutput( "stderr", stderr_cpython, stderr_nuitka, ignore_warnings=True, syntax_errors=True, ) exit_code_return = exit_cpython != exit_nuitka if exit_code_return: my_print("""\ Exit codes {exit_cpython:d} (CPython) != {exit_nuitka:d} (Nuitka)""".format( exit_cpython=exit_cpython, exit_nuitka=exit_nuitka)) exit_code = exit_code_stdout or exit_code_stderr or exit_code_return if exit_code: sys.exit("Error, outputs differed.") if search_mode.abortIfExecuted(): break search_mode.finish()
filename = os.path.relpath(filename) if not decideFilenameVersionSkip(filename): continue active = search_mode.consider(dirname=None, filename=filename) if active: my_print("Consider distutils example:", filename) case_dir = os.path.join(os.getcwd(), filename) removeDirectory(os.path.join(case_dir, "build"), ignore_errors=False) removeDirectory(os.path.join(case_dir, "dist"), ignore_errors=False) with withVirtualenv("venv_cpython") as venv: venv.runCommand( commands=['cd "%s"' % case_dir, "python setup.py bdist_wheel"] ) dist_dir = os.path.join(case_dir, "dist") venv.runCommand( 'pip install "%s"' % (os.path.join(dist_dir, os.listdir(dist_dir)[0])) ) runner_binary = os.path.join( venv.getVirtualenvDir(), "bin" if os.name != "nt" else "scripts", "runner", )
active = search_mode.consider( dirname = None, filename = filename ) if active: my_print("Consider distutils example:", filename) case_dir = os.path.join(os.getcwd(), filename) removeDirectory(os.path.join(case_dir, "build"), ignore_errors = False) removeDirectory(os.path.join(case_dir, "dist"), ignore_errors = False) with withVirtualenv("venv_cpython") as venv: venv.runCommand( commands = [ 'cd "%s"' % case_dir, "python setup.py bdist_wheel", ] ) dist_dir = os.path.join(case_dir, "dist") venv.runCommand( 'pip install "%s"' % ( os.path.join( dist_dir, os.listdir(dist_dir)[0] )