Esempio n. 1
0
def run_compiled_script(binary_path):
    args = [binary_path]
    exit_code = run_process(args)
    if exit_code:
        raise RuntimeError(
            "Failure while executing compiled script: {}".format(binary_path))
    log.info("")
Esempio n. 2
0
def execute_script(script_path):
    args = [sys.executable, script_path]
    exit_code = run_process(args)
    if exit_code:
        raise RuntimeError(
            "Failure while executing script: {}".format(script_path))
    log.info("")
Esempio n. 3
0
def install_wheel(wheel_path):
    log.info("Installing wheel: {}".format(wheel_path))
    exit_code = run_process(
        [sys.executable, "-m", "pip", "install", wheel_path])
    log.info("")
    if exit_code:
        raise RuntimeError(
            "Error while installing wheel {}".format(wheel_path))
Esempio n. 4
0
def run_make():
    args = []
    if is_unix():
        executable = "make"
    else:
        executable = "nmake"
    args.append(executable)

    exit_code = run_process(args)
    if exit_code:
        raise RuntimeError("Failure while running {}.".format(executable))
    log.info("")
Esempio n. 5
0
def compile_using_pyinstaller():
    src_path = os.path.join("..", "hello.py")
    spec_path = os.path.join("..", "hello_app.spec")
    exit_code = run_process([sys.executable, "-m", "PyInstaller", spec_path])
    # to create the spec file, this setting was used:
    #"--name=hello_app", "--console", "--log-level=DEBUG", src_path])
    # By using a spec file, we avoid all the probing that might disturb certain
    # platforms and also save some analysis time.
    if exit_code:
        # 2019-04-28 Raising on error is again enabled
        raise_error_pyinstaller(
            "Failure while compiling script using PyInstaller.")
    log.info("")
Esempio n. 6
0
def compile_using_pyinstaller():
    src_path = os.path.join("..", "hello.py")
    spec_path = os.path.join("..", "hello_app.spec")
    exit_code = run_process([sys.executable, "-m", "PyInstaller", spec_path])
    # to create the spec file, this setting was used:
    #"--name=hello_app", "--console", "--log-level=DEBUG", src_path])
    # By using a spec file, we avoid all the probing that might disturb certain
    # platforms and also save some analysis time.
    if exit_code:
        # raise RuntimeError("Failure while compiling script using PyInstaller.")
        print("PYINST: Failure while compiling script using PyInstaller.")
        print("PYINST:   sys.version         = {}".format(
            sys.version.splitlines()[0]))
        print("PYINST:   platform.platform() = {}".format(platform.platform()))
        print("PYINST: See the error message above.")
        return False
    log.info("")
    return True
Esempio n. 7
0
def generate_build_cmake():
    args = [CMAKE_PATH]
    if is_unix():
        args.extend(["-G", "Unix Makefiles"])
    else:
        args.extend(["-G", "NMake Makefiles"])
    args.append("-DCMAKE_BUILD_TYPE=Release")
    args.append("-Dpython_interpreter={}".format(sys.executable))

    # Specify prefix path so find_package(Qt5) works.
    qmake_dir = os.path.abspath(os.path.join(os.path.dirname(QMAKE_PATH),
                                             ".."))
    args.append("-DCMAKE_PREFIX_PATH={}".format(qmake_dir))

    args.append("..")

    exit_code = run_process(args)
    if exit_code:
        raise RuntimeError("Failure while running cmake.")
    log.info("")
Esempio n. 8
0
def generate_build_qmake():
    exit_code = run_process(
        [QMAKE_PATH, "..", "python_interpreter={}".format(sys.executable)])
    if exit_code:
        raise RuntimeError("Failure while running qmake.")
    log.info("")
Esempio n. 9
0
    def run_setup(self):
        """
        Decide what kind of build is requested and then execute it.
        In the top-level invocation case, the script
            will spawn setup.py again (possibly multiple times).
        In the internal invocation case, the script
            will run setuptools.setup().
        """

        # Prepare initial config.
        config.init_config(build_type=OPTION_BUILD_TYPE,
                           internal_build_type=OPTION_INTERNAL_BUILD_TYPE,
                           cmd_class_dict=cmd_class_dict,
                           package_version=get_package_version(),
                           ext_modules=get_setuptools_extension_modules(),
                           setup_script_dir=self.setup_script_dir,
                           quiet=OPTION_QUIET)

        # This is an internal invocation of setup.py, so start actual
        # build.
        if config.is_internal_invocation():
            if config.internal_build_type not in config.get_allowed_internal_build_values(
            ):
                raise RuntimeError(
                    "Invalid '{}' option given to --internal-build-type. ".
                    format(config.internal_build_type))
            self.run_setuptools_setup()
            return

        # This is a top-level invocation of setup.py, so figure out what
        # modules we will build and depending on that, call setup.py
        # multiple times with different arguments.
        if config.build_type not in config.get_allowed_top_level_build_values(
        ):
            raise RuntimeError(
                "Invalid '{}' option given to --build-type. ".format(
                    config.build_type))

        # Build everything: shiboken2, shiboken2-generator and PySide2.
        if config.is_top_level_build_all():
            self.add_setup_internal_invocation(
                config.shiboken_module_option_name)

            # Reuse the shiboken build for the generator package instead
            # of rebuilding it again.
            self.add_setup_internal_invocation(
                config.shiboken_generator_option_name, reuse_build=True)

            self.add_setup_internal_invocation(config.pyside_option_name)

        elif config.is_top_level_build_shiboken_module():
            self.add_setup_internal_invocation(
                config.shiboken_module_option_name)

        elif config.is_top_level_build_shiboken_generator():
            self.add_setup_internal_invocation(
                config.shiboken_generator_option_name)

        elif config.is_top_level_build_pyside():
            self.add_setup_internal_invocation(config.pyside_option_name)

        for cmd in self.invocations_list:
            cmd_as_string = " ".join(cmd)
            print("\nRunning process: {}\n".format(cmd_as_string))
            exit_code = run_process(cmd)
            if exit_code != 0:
                msg = textwrap.dedent("""
                    setup.py invocation failed with exit code: {}.\n\n
                    setup.py invocation was: {}
                    """).format(exit_code, cmd_as_string)
                raise RuntimeError(msg)