示例#1
0
def test_distribution_is_pure(distribution_type, tmpdir):

    skbuild_setup_kwargs = {}

    if distribution_type == 'unknown':
        is_pure = False

    elif distribution_type == 'py_modules':
        is_pure = True
        hello_py = tmpdir.join("hello.py")
        hello_py.write("")
        skbuild_setup_kwargs["py_modules"] = ["hello"]

    elif distribution_type == 'packages':
        is_pure = True
        init_py = tmpdir.mkdir("hello").join("__init__.py")
        init_py.write("")
        skbuild_setup_kwargs["packages"] = ["hello"]

    elif distribution_type == 'skbuild':
        is_pure = False
        cmakelists_txt = tmpdir.join("CMakeLists.txt")
        cmakelists_txt.write(
            """
            cmake_minimum_required(VERSION 3.5.0)
            project(test NONE)
            install(CODE "execute_process(
              COMMAND \${CMAKE_COMMAND} -E sleep 0)")
            """
        )
    else:
        raise Exception(
            "Unknown distribution_type: {}".format(distribution_type))

    platform = get_platform()
    original_write_test_cmakelist = platform.write_test_cmakelist

    def write_test_cmakelist_no_languages(_self, _languages):
        original_write_test_cmakelist([])

    with patch.object(type(platform), 'write_test_cmakelist', new=write_test_cmakelist_no_languages):

        with push_dir(str(tmpdir)), push_argv(["setup.py", "build"]):
            distribution = skbuild_setup(
                name="test",
                version="0.0.1",
                description="test object returned by setup function",
                author="The scikit-build team",
                license="MIT",
                **skbuild_setup_kwargs
            )
            assert issubclass(distribution.__class__,
                              (distutils_Distribution, setuptool_Distribution))
            assert is_pure == distribution.is_pure()
示例#2
0
def test_distribution_is_pure(distribution_type, tmpdir):

    skbuild_setup_kwargs = {}

    if distribution_type == 'unknown':
        is_pure = False

    elif distribution_type == 'py_modules':
        is_pure = True
        hello_py = tmpdir.join("hello.py")
        hello_py.write("")
        skbuild_setup_kwargs["py_modules"] = ["hello"]

    elif distribution_type == 'packages':
        is_pure = True
        init_py = tmpdir.mkdir("hello").join("__init__.py")
        init_py.write("")
        skbuild_setup_kwargs["packages"] = ["hello"]

    elif distribution_type == 'skbuild':
        is_pure = False
        cmakelists_txt = tmpdir.join("CMakeLists.txt")
        cmakelists_txt.write(
            """
            cmake_minimum_required(VERSION 3.5.0)
            project(test NONE)
            install(CODE "execute_process(
              COMMAND \${CMAKE_COMMAND} -E sleep 0)")
            """
        )
    else:
        raise Exception(
            "Unknown distribution_type: {}".format(distribution_type))

    platform = get_platform()
    original_write_test_cmakelist = platform.write_test_cmakelist

    def write_test_cmakelist_no_languages(_self, _languages):
        original_write_test_cmakelist([])

    with patch.object(type(platform), 'write_test_cmakelist', new=write_test_cmakelist_no_languages):

        with push_dir(str(tmpdir)), push_argv(["setup.py", "build"]):
            distribution = skbuild_setup(
                name="test",
                version="0.0.1",
                description="test object returned by setup function",
                author="The scikit-build team",
                license="MIT",
                **skbuild_setup_kwargs
            )
            assert issubclass(distribution.__class__,
                              (distutils_Distribution, setuptool_Distribution))
            assert is_pure == distribution.is_pure()
示例#3
0
def setup(*args, **kwargs):
    """This wrapper exists to force the option --build-type=ReleaseWithDocs.

    Neither Release nor RelWithDebInfo will work, due to hard-coded options in
    scikit-build's UseCython.cmake that disable docstrings. The choice of
    ReleaseWithDocs is arbitrary, as a string that won't overlap with any build
    type handled in UseCython.cmake. See this issue for details:
    https://github.com/scikit-build/scikit-build/issues/518
    """
    BUILD_TYPE = '--build-type=ReleaseWithDocs'
    for index, arg in enumerate(sys.argv):
        if arg == '--':
            # Insert at the end of the options that go to scikit-build
            break
        elif arg.startswith('--build-type'):
            # Don't override user-specified build type
            index = False
            break
    else:
        # Insert at the end of the provided arguments
        index = len(sys.argv)
    if index:
        sys.argv.insert(index, BUILD_TYPE)
    skbuild_setup(*args, **kwargs)