Exemple #1
0
def build_wheels(py_envs=DEFAULT_PY_ENVS, single_wheel=False,
                 cleanup=False, wheel_names=None):

    prepare_build_env("35-x64")
    prepare_build_env("36-x64")

    with push_dir(directory=STANDALONE_DIR, make_directory=True):

        cmake_executable = "cmake.exe"
        tools_venv = os.path.join(ROOT_DIR, "venv-35-x64")
        pip_install(tools_venv, "ninja")
        ninja_executable = os.path.join(tools_venv, "Scripts", "ninja.exe")

        # Build standalone project and populate archive cache
        check_call([
            cmake_executable,
            "-DITKPythonPackage_BUILD_PYTHON:PATH=0",
            "-G", "Ninja",
            "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable,
            ROOT_DIR
        ])

        check_call([ninja_executable])

    # Compile wheels re-using standalone project and archive cache
    for py_env in py_envs:
        build_wheel(
            py_env, single_wheel=single_wheel,
            cleanup=cleanup, wheel_names=wheel_names)
Exemple #2
0
def build_wrapped_itk(ninja_executable, build_type, source_path, build_path,
                      python_executable, python_include_dir, python_library):

    try:
        # Because of python issue #14243, we set "delete=False" and
        # delete manually after process execution.
        script_file = tempfile.NamedTemporaryFile(delete=False, suffix=".py")
        script_file.write(
            bytearray(
                textwrap.dedent("""
            import json
            from skbuild.platform_specifics.windows import WindowsPlatform
            # Instantiate
            build_platform = WindowsPlatform()
            generator = build_platform.default_generators[0]
            assert generator.name == "Ninja"
            print(json.dumps(generator.env))
            """

                                # noqa: E501
                                ),
                "utf-8"))
        script_file.file.flush()
        output = check_output([python_executable, script_file.name])
        build_env = json.loads(output.decode("utf-8").strip())
    finally:
        script_file.close()
        os.remove(script_file.name)

    tbb_dir = os.path.join(ROOT_DIR, 'oneTBB-prefix', 'lib', 'cmake', 'TBB')

    # Build ITK python
    with push_dir(directory=build_path, make_directory=True), \
            push_env(**build_env):

        check_call([
            "cmake",
            "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable,
            "-DCMAKE_BUILD_TYPE:STRING=%s" % build_type,
            "-DITK_SOURCE_DIR:PATH=%s" % source_path,
            "-DITK_BINARY_DIR:PATH=%s" % build_path,
            "-DBUILD_TESTING:BOOL=OFF",
            "-DPython3_EXECUTABLE:FILEPATH=%s" % python_executable,
            "-DITK_WRAP_unsigned_short:BOOL=ON", "-DITK_WRAP_double:BOOL=ON",
            "-DITK_WRAP_complex_double:BOOL=ON",
            "-DITK_WRAP_IMAGE_DIMS:STRING=2;3;4",
            "-DPython3_INCLUDE_DIR:PATH=%s" % python_include_dir,
            "-DPython3_INCLUDE_DIRS:PATH=%s" % python_include_dir,
            "-DPython3_LIBRARY:FILEPATH=%s" % python_library,
            "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel",
            "-DWRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=ON",
            "-DPY_SITE_PACKAGES_PATH:PATH=.", "-DITK_LEGACY_SILENT:BOOL=ON",
            "-DITK_WRAP_PYTHON:BOOL=ON", "-DITK_WRAP_DOC:BOOL=ON",
            "-DDOXYGEN_EXECUTABLE:FILEPATH=C:/P/doxygen/doxygen.exe",
            "-DModule_ITKTBB:BOOL=ON",
            "-DTBB_DIR:PATH=%s" % tbb_dir, "-G", "Ninja", source_path
        ])
        check_call([ninja_executable])
def build_wheels(py_envs=DEFAULT_PY_ENVS, cleanup=False):

    for py_env in py_envs:
        prepare_build_env(py_env)

    with push_dir(directory=STANDALONE_DIR, make_directory=True):

        tools_venv = os.path.join(ROOT_DIR, "venv-%s" % DEFAULT_PY_ENVS[0])
        pip_install(tools_venv, "ninja")
        ninja_executable = os.path.join(tools_venv, "bin", "ninja")

        # Build standalone project and populate archive cache
        check_call([
            "cmake", "-DVTKPythonPackage_BUILD_PYTHON:BOOL=OFF", "-G", "Ninja",
            "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable, ROOT_DIR
        ])

    # Compile wheels re-using standalone project and archive cache
    for py_env in py_envs:
        build_wheel(py_env, cleanup=cleanup)
Exemple #4
0
def build_wheels(py_envs=DEFAULT_PY_ENVS,
                 single_wheel=False,
                 cleanup=False,
                 wheel_names=None,
                 cmake_options=[]):

    for py_env in py_envs:
        prepare_build_env(py_env)

    with push_dir(directory=ITK_SOURCE, make_directory=True):

        cmake_executable = "cmake.exe"
        tools_venv = os.path.join(ROOT_DIR, "venv-" + py_envs[0])
        ninja_executable = shutil.which('ninja.exe')
        if ninja_executable is None:
            pip_install(tools_venv, "ninja")
            ninja_executable = os.path.join(tools_venv, "Scripts", "ninja.exe")

        # Build standalone project and populate archive cache
        check_call([
            cmake_executable, "-DITKPythonPackage_BUILD_PYTHON:PATH=0", "-G",
            "Ninja",
            "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable, ROOT_DIR
        ])

        check_call([ninja_executable])

    # Compile wheels re-using standalone project and archive cache
    for py_env in py_envs:
        tools_venv = os.path.join(ROOT_DIR, "venv-" + py_env)
        ninja_executable = shutil.which('ninja.exe')
        if ninja_executable is None:
            pip_install(tools_venv, "ninja")
        build_wheel(py_env,
                    single_wheel=single_wheel,
                    cleanup=cleanup,
                    wheel_names=wheel_names,
                    cmake_options=cmake_options)