Exemple #1
0
def main():
    import os
    from aksetup_helper import (hack_distutils, get_config, setup,
            NumpyExtension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    EXTRA_OBJECTS, EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested(
                    "pyviennacl", conf,
                    source_path="external/boost-python-ublas-subset/boost_subset",
                    boost_chrono="header_only")

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + [
            "external/boost_numpy/"
            ]
    if conf["USE_SHIPPED_VIENNACL"]:
        INCLUDE_DIRS += ["external/viennacl-dev/"]

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    # {{{ get version number

    ver_dic = {}
    version_file = open("pyviennacl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyviennacl/version.py", 'exec'), ver_dic)

    # }}}

    if conf["USE_OPENCL"]:
        EXTRA_DEFINES["VIENNACL_WITH_OPENCL"] = None
    EXTRA_DEFINES["VIENNACL_WITH_UBLAS"] = None

    platform_cflags["msvc"] = ["/EHsc"]
    platform_cflags["mingw32"] = ["-Wno-unused-function"]
    platform_cflags["unix"] = ["-Wno-unused-function"]

    if not sys.platform.startswith("darwin"):
        platform_libs['unix'] = ['rt']

    if EXTRA_OBJECTS:
        platform_cflags['mingw32'] += ["-Wno-unused-local-typedefs"]
        if not sys.platform.startswith("darwin"):
            platform_cflags['unix'] += ["-Wno-unused-local-typedefs"]

    source_files = [
        "core",
        "vector_float", "vector_double", "vector_int", "vector_long",
        "vector_uint", "vector_ulong",

        "dense_matrix_float", "dense_matrix_double",
        "dense_matrix_int", "dense_matrix_long",
        "dense_matrix_uint", "dense_matrix_ulong",

        "structured_matrices",

        "compressed_matrix", "coordinate_matrix", "ell_matrix", "hyb_matrix",
        "preconditioners","direct_solvers", "iterative_solvers",

        "extra_functions", "eig", #"bandwidth_reduction",

        "scheduler", "opencl_support"]

    from glob import glob

    try:
        long_description = open("README.rst", "rt", encoding='utf8').read()
    except:
        long_description = open("README.rst", "rt").read()

    setup(
        name="pyviennacl",
        version=ver_dic["VERSION_TEXT"],
        description="Sparse/dense linear algebra on GPUs and CPUs using OpenCL",
        long_description=long_description,
        author='Toby St Clere Smithe',
        author_email='*****@*****.**',
        url="http://viennacl.sourceforge.net/pyviennacl.html",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.2',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
        ],
        setup_requires=['numpy>=1.7'],
        install_requires=['numpy>=1.7'],

        packages=["pyviennacl"],
        ext_package="pyviennacl",
        ext_modules=[NumpyExtension(
            "_viennacl",

            [os.path.join("src", "_viennacl", sf + ".cpp")
             for sf in source_files]
            + glob("external/boost_numpy/libs/numpy/src/*.cpp")
            + EXTRA_OBJECTS,
            depends=[os.path.join("src", "_viennacl", "viennacl.h")],

            extra_compile_args=conf["CXXFLAGS"],
            extra_link_args=conf["LDFLAGS"],

            define_macros=list(EXTRA_DEFINES.items()),

            include_dirs=INCLUDE_DIRS,
            library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
            libraries=LIBRARIES + conf["CL_LIBNAME"],
        )],
        cmdclass={'build_ext': build_ext_subclass}
    )
Exemple #2
0
def main():
    import os
    from aksetup_helper import (hack_distutils, get_config, setup,
                                NumpyExtension,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(), warn_about_no_config=False)

    EXTRA_OBJECTS, EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested(
                    "pyviennacl", conf,
                    source_path="external/boost-python-ublas-subset/boost_subset")

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + ["external/boost_numpy/"]
    if conf["USE_SHIPPED_VIENNACL"]:
        INCLUDE_DIRS += ["external/viennacl-dev/"]

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    # {{{ get version number

    ver_dic = {}
    version_file = open("pyviennacl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyviennacl/version.py", 'exec'),
         ver_dic)

    # }}}

    if conf["USE_OPENCL"]:
        EXTRA_DEFINES["VIENNACL_WITH_OPENCL"] = None
    EXTRA_DEFINES["VIENNACL_WITH_UBLAS"] = None

    platform_cflags["msvc"] = ["/EHsc"]
    platform_cflags["mingw32"] = ["-Wno-unused-function"]
    platform_cflags["unix"] = ["-Wno-unused-function"]

    if EXTRA_OBJECTS:
        platform_cflags['mingw32'] += ["-Wno-unused-local-typedefs"]
        if not sys.platform.startswith("darwin"):
            platform_cflags['unix'] += ["-Wno-unused-local-typedefs"]

    source_files = [
        "core", "vector_float", "vector_double", "vector_int", "vector_long",
        "vector_uint", "vector_ulong", "dense_matrix_float",
        "dense_matrix_double", "dense_matrix_int", "dense_matrix_long",
        "dense_matrix_uint", "dense_matrix_ulong", "compressed_matrix",
        "coordinate_matrix", "ell_matrix", "hyb_matrix", "direct_solvers",
        "iterative_solvers", "eig", "extra_functions", "scheduler",
        "opencl_support"
    ]

    from glob import glob

    setup(
        name="pyviennacl",
        version=ver_dic["VERSION_TEXT"],
        description="Sparse/dense linear algebra on GPUs and CPUs using OpenCL",
        long_description=open("README.rst", "rt").read(),
        author='Toby St Clere Smithe',
        author_email='*****@*****.**',
        url="http://viennacl.sourceforge.net/pyviennacl.html",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.2',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
        ],
        packages=["pyviennacl"],
        ext_package="pyviennacl",
        ext_modules=[
            NumpyExtension(
                "_viennacl",
                [
                    os.path.join("src", "_viennacl", sf + ".cpp")
                    for sf in source_files
                ] + glob("external/boost_numpy/libs/numpy/src/*.cpp") +
                EXTRA_OBJECTS,
                depends=[os.path.join("src", "_viennacl", "viennacl.h")],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
                define_macros=list(EXTRA_DEFINES.items()),
                include_dirs=INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
                libraries=LIBRARIES + conf["CL_LIBNAME"],
            )
        ],
        cmdclass={'build_ext': build_ext_subclass})
Exemple #3
0
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
            check_git_submodules)
    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    extra_defines = {}

    extra_defines["PYGPU_PACKAGE"] = "pyopencl"
    extra_defines["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        extra_defines["PYOPENCL_TRACE"] = 1

    if conf["CL_ENABLE_GL"]:
        extra_defines["HAVE_GL"] = 1

    if conf["CL_ENABLE_DEVICE_FISSION"]:
        extra_defines["PYOPENCL_USE_DEVICE_FISSION"] = 1
    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                    "with two integers M and N")
            raise

    conf["EXTRA_DEFINES"] = extra_defines

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic)

    separator = "-"*75

    try:
        import mako  # noqa
    except ImportError:
        print(separator)
        print("Mako is not installed.")
        print(separator)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it.Some higher-level parts of pyopencl (such as ")
        print("pyopencl.reduction) will not function without the templating engine ")
        print("Mako [1] being installed. If you would like this functionality to ")
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(separator)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(separator)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    # {{{ write cffi build script

    with open("cffi_build.py.in", "rt") as f:
        build_script_template = f.read()

    format_args = {}
    for k, v in conf.items():
        format_args[k] = repr(v)

    build_script = build_script_template.format(**format_args)

    with open("cffi_build.py", "wt") as f:
        f.write(build_script)

    # }}}

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description=open("README.rst", "rt").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
                'Environment :: Console',
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'Intended Audience :: Other Audience',
                'Intended Audience :: Science/Research',
                'License :: OSI Approved :: MIT License',
                'Natural Language :: English',
                'Programming Language :: C++',
                'Programming Language :: Python',
                'Programming Language :: Python :: 2',
                'Programming Language :: Python :: 2.6',
                'Programming Language :: Python :: 2.7',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.2',
                'Programming Language :: Python :: 3.3',
                'Topic :: Scientific/Engineering',
                'Topic :: Scientific/Engineering :: Mathematics',
                'Topic :: Scientific/Engineering :: Physics',
                ],

            # build info
            packages=find_packages(),

            setup_requires=[
                "numpy",
                "cffi>=1.1.0",
                ],

            install_requires=[
                "numpy",
                "pytools>=2015.1.2",
                "pytest>=2",
                "decorator>=3.2.0",
                "cffi>=1.1.0",
                "appdirs>=1.4.0",
                "six>=1.9.0",
                # "Mako>=0.3.6",
                ],

            cffi_modules=["cffi_build.py:ffi"],

            include_package_data=True,
            package_data={
                    "pyopencl": ["cl/*.cl", "cl/*.h"]
                    },

            zip_safe=False)
Exemple #4
0
def main():
    import sys

    from aksetup_helper import (hack_distutils, get_config, setup,
                                NumpyExtension,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema())

    EXTRA_SOURCES, EXTRA_DEFINES = set_up_shipped_boost_if_requested(
        "pycuda", conf)

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pycuda"
    EXTRA_DEFINES["PYGPU_PYCUDA"] = "1"

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"] + conf["CUDADRV_LIB_DIR"]
    LIBRARIES = (conf["BOOST_PYTHON_LIBNAME"] + conf["BOOST_THREAD_LIBNAME"] +
                 conf["CUDADRV_LIBNAME"])

    if not conf["CUDA_INC_DIR"] and conf["CUDA_ROOT"]:
        conf["CUDA_INC_DIR"] = [join(conf["CUDA_ROOT"], "include")]

    if conf["CUDA_TRACE"]:
        EXTRA_DEFINES["CUDAPP_TRACE_CUDA"] = 1

    if conf["CUDA_PRETEND_VERSION"]:
        EXTRA_DEFINES["CUDAPP_PRETEND_CUDA_VERSION"] = conf[
            "CUDA_PRETEND_VERSION"]

    INCLUDE_DIRS = ['src/cpp'] + conf["BOOST_INC_DIR"]
    if conf["CUDA_INC_DIR"]:
        INCLUDE_DIRS += conf["CUDA_INC_DIR"]

    conf["USE_CUDA"] = True

    if 'darwin' in sys.platform and sys.maxsize == 2147483647:
        # The Python interpreter is running in 32 bit mode on OS X
        if "-arch" not in conf["CXXFLAGS"]:
            conf["CXXFLAGS"].extend(['-arch', 'i386', '-m32'])
        if "-arch" not in conf["LDFLAGS"]:
            conf["LDFLAGS"].extend(['-arch', 'i386', '-m32'])

    if 'darwin' in sys.platform:
        # set path to Cuda dynamic libraries,
        # as a safe substitute for DYLD_LIBRARY_PATH
        for lib_dir in conf["CUDADRV_LIB_DIR"]:
            conf["LDFLAGS"].extend(["-Xlinker", "-rpath", "-Xlinker", lib_dir])

    if conf["CUDA_ENABLE_GL"]:
        EXTRA_SOURCES.append("src/wrapper/wrap_cudagl.cpp")
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CUDA_ENABLE_CURAND"]:
        EXTRA_DEFINES["HAVE_CURAND"] = 1
        EXTRA_SOURCES.extend(["src/wrapper/wrap_curand.cpp"])
        LIBRARIES.extend(conf["CURAND_LIBNAME"])
        LIBRARY_DIRS.extend(conf["CURAND_LIB_DIR"])

    ver_dic = {}
    exec(
        compile(
            open("pycuda/__init__.py").read(), "pycuda/__init__.py", 'exec'),
        ver_dic)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    import sys
    if sys.version_info >= (3, ):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(
        name="pycuda",
        # metadata
        version=ver_dic["VERSION_TEXT"],
        description="Python wrapper for Nvidia CUDA",
        long_description=open("README.rst", "rt").read(),
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pycuda",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
            'Topic :: Scientific/Engineering :: Visualization',
        ],

        # build info
        packages=["pycuda", "pycuda.gl", "pycuda.sparse", "pycuda.compyte"],
        install_requires=[
            "pytools>=2011.2", "pytest>=2", "decorator>=3.2.0",
            "appdirs>=1.4.0"
        ],
        ext_package="pycuda",
        ext_modules=[
            NumpyExtension(
                "_driver",
                [
                    "src/cpp/cuda.cpp",
                    "src/cpp/bitlog.cpp",
                    "src/wrapper/wrap_cudadrv.cpp",
                    "src/wrapper/mempool.cpp",
                ] + EXTRA_SOURCES,
                include_dirs=INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS,
                libraries=LIBRARIES,
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            NumpyExtension(
                "_pvt_struct",
                [pvt_struct_source],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        include_package_data=True,
        package_data={"pycuda": [
            "cuda/*.hpp",
        ]},
        zip_safe=False,

        # 2to3 invocation
        cmdclass={'build_py': build_py})
Exemple #5
0
def main():
    # pylint: disable=too-many-statements, too-many-branches, too-many-locals

    from aksetup_helper import (hack_distutils,
            get_config, setup, check_git_submodules)

    check_git_submodules()

    hack_distutils(what_opt=None)
    conf = get_config(get_config_schema(), warn_about_no_config=False)

    EXTRA_SOURCES = []  # noqa
    EXTRA_DEFINES = {}  # noqa
    INCLUDE_DIRS = []  # noqa
    LIBRARY_DIRS = []  # noqa
    LIBRARIES = []  # noqa
    CXXFLAGS = conf["CXXFLAGS"]  # noqa: N806

    if conf["USE_SHIPPED_ISL"]:
        from glob import glob
        isl_blacklist = [
                "_templ.c",
                "_templ_yaml.c",
                "mp_get",
                "extract_key.c",
                "isl_multi_templ.c",
                "isl_multi_apply_set.c",
                "isl_multi_gist.c",
                "isl_multi_coalesce.c",
                "isl_multi_intersect.c",
                "isl_multi_floor.c",
                "isl_multi_apply_union_set.c",
                "isl_multi_cmp.c",
                "isl_multi_pw_aff_explicit_domain.c",
                "isl_multi_hash.c",
                "isl_multi_dims.c",
                "isl_multi_explicit_domain.c",
                "isl_multi_no_explicit_domain.c",
                "isl_multi_align_set.c",
                "isl_multi_align_union_set.c",
                "isl_multi_union_pw_aff_explicit_domain.c",
                "isl_union_templ.c",
                "isl_union_multi.c",
                "isl_union_eval.c",
                "isl_union_neg.c",
                "isl_union_single.c",
                "isl_pw_hash.c",
                "isl_pw_eval.c",
                "isl_pw_union_opt.c",
                "isl_pw_union_opt.c",
                ]

        for fn in glob("isl/*.c"):
            blacklisted = False
            for bl in isl_blacklist:
                if bl in fn:
                    blacklisted = True
                    break

            if "no_piplib" in fn:
                pass
            elif "piplib" in fn:
                blacklisted = True

            if "gmp" in fn:
                if conf["USE_SHIPPED_IMATH"]:
                    continue
            if "imath" in fn:
                if not conf["USE_SHIPPED_IMATH"]:
                    continue

                if "sioimath" in fn and not conf["USE_IMATH_SIO"]:
                    continue
                if "isl_val_imath" in fn and conf["USE_IMATH_SIO"]:
                    continue

            if "isl_ast_int.c" in fn and conf["USE_SHIPPED_IMATH"]:
                continue

            inf = open(fn, "r", encoding="utf-8")
            try:
                contents = inf.read()
            finally:
                inf.close()

            if "int main(" not in contents and not blacklisted:
                EXTRA_SOURCES.append(fn)

        conf["ISL_INC_DIR"] = ["isl-supplementary", "isl/include", "isl"]

        if conf["USE_SHIPPED_IMATH"]:
            EXTRA_SOURCES.extend([
                "isl/imath/imath.c",
                "isl/imath/imrat.c",
                "isl/imath/gmp_compat.c",
                #"isl/imath_wrap/imath.c",
                #"isl/imath_wrap/imrat.c",
                #"isl/imath_wrap/gmp_compat.c",
                ])
            EXTRA_DEFINES["USE_IMATH_FOR_MP"] = 1
            if conf["USE_IMATH_SIO"]:
                EXTRA_DEFINES["USE_SMALL_INT_OPT"] = 1

                import sys
                if sys.platform in ['linux', 'linux2', 'darwin']:
                    CXXFLAGS.insert(0, "-std=gnu99")

            conf["ISL_INC_DIR"].append("isl/imath")
        else:
            EXTRA_DEFINES["USE_GMP_FOR_MP"] = 1

    else:
        LIBRARY_DIRS.extend(conf["ISL_LIB_DIR"])
        LIBRARIES.extend(conf["ISL_LIBNAME"])

    wrapper_dirs = conf["ISL_INC_DIR"][:]

    # {{{ configure barvinok

    if conf["USE_BARVINOK"]:
        if conf["USE_SHIPPED_ISL"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                    "shipped isl")
        if conf["USE_SHIPPED_IMATH"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                    "shipped imath")

        INCLUDE_DIRS.extend(conf["BARVINOK_INC_DIR"])
        LIBRARY_DIRS.extend(conf["BARVINOK_LIB_DIR"])
        LIBRARIES.extend(conf["BARVINOK_LIBNAME"])

        wrapper_dirs.extend(conf["BARVINOK_INC_DIR"])

        #EXTRA_DEFINES["ISLPY_ISL_VERSION"] = 15

    # }}}

    INCLUDE_DIRS.extend(conf["ISL_INC_DIR"])

    if not (conf["USE_SHIPPED_ISL"] and conf["USE_SHIPPED_IMATH"]) and \
            conf["USE_GMP"]:
        INCLUDE_DIRS.extend(conf["GMP_INC_DIR"])
        LIBRARY_DIRS.extend(conf["GMP_LIB_DIR"])
        LIBRARIES.extend(conf["GMP_LIBNAME"])

    init_filename = "islpy/version.py"
    with open(init_filename, "r") as version_f:
        version_py = version_f.read()
    exec(compile(version_py, init_filename, "exec"), conf)

    from gen_wrap import gen_wrapper
    headers = gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"],
            isl_version=EXTRA_DEFINES.get("ISLPY_ISL_VERSION"))

    write_cffi_build_script(
            headers,
            EXTRA_DEFINES=EXTRA_DEFINES,
            EXTRA_SOURCES=EXTRA_SOURCES,
            INCLUDE_DIRS=INCLUDE_DIRS,
            LIBRARY_DIRS=LIBRARY_DIRS,
            LIBRARIES=LIBRARIES,
            CFLAGS=CXXFLAGS,
            LDFLAGS=conf["LDFLAGS"]
            )

    with open("README.rst", "rt") as readme_f:
        readme = readme_f.read()

    setup(name="islpy",
          version=conf["VERSION_TEXT"],
          description="Wrapper around isl, an integer set library",
          long_description=readme,
          author="Andreas Kloeckner",
          author_email="*****@*****.**",
          license="MIT",
          url="http://documen.tician.de/islpy",
          classifiers=[
              'Development Status :: 4 - Beta',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
              'Programming Language :: Python :: 2.7',
              'Programming Language :: Python :: 3',
              'Programming Language :: Python :: 3.3',
              'Programming Language :: Python :: 3.4',
              'Programming Language :: Python :: 3.5',
              'Programming Language :: Python :: 3.6',
              'Programming Language :: Python :: Implementation :: CPython',
              'Programming Language :: Python :: Implementation :: PyPy',
              'Topic :: Multimedia :: Graphics :: 3D Modeling',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Visualization',
              'Topic :: Software Development :: Libraries',
              ],

          packages=["islpy"],

          setup_requires=["cffi>=1.1.0"],
          cffi_modules=["islpy_cffi_build.py:ffi"],
          install_requires=[
              "pytest>=2",
              "cffi>=1.1.0",
              # "Mako>=0.3.6",
              "six",
              ],
          )
Exemple #6
0
def main():
    from aksetup_helper import check_git_submodules
    check_git_submodules()

    import os
    build_mode = os.environ.get("PYFMMLIB_BUILD_MODE", "openmp-opt")

    if build_mode == "openmp-ofast":
        FOPT_ARGS = "-Ofast -fopenmp"
        OPT_ARGS = "-Ofast"
        EXTRA_LINK_ARGS = "-fopenmp"

    elif build_mode == "openmp-opt":
        FOPT_ARGS = "-O3 -fopenmp"
        OPT_ARGS = "-O3 -fopenmp"
        EXTRA_LINK_ARGS = "-fopenmp"

    elif build_mode == "debug":
        FOPT_ARGS = "-g"
        OPT_ARGS = "-g"
        EXTRA_LINK_ARGS = "-g"

    elif build_mode == "setuptools":
        FOPT_ARGS = os.environ.get("FOPT", "")
        OPT_ARGS = os.environ.get("OPT", "")
        EXTRA_LINK_ARGS = os.environ.get("EXTRA_LINK_ARGS", "")

    else:
        raise ValueError("invalid value of $PYFMMLIB_BUILD_MODE")

    # NOTE: gfortran 8.1+ errors on incorrect dummy argument shape
    # https://groups.google.com/forum/#!topic/comp.lang.fortran/x3JnAjRX-KA
    os.environ["FOPT"] = "-std=legacy {}".format(FOPT_ARGS)

    os.environ["OPT"] = OPT_ARGS
    os.environ["EXTRA_LINK_ARGS"] = EXTRA_LINK_ARGS

    try:
        import mako  # noqa
    except ImportError:
        print(DASH_SEPARATOR)
        print("Mako is not installed.")
        print(DASH_SEPARATOR)

        all_gen_exist = True
        from os.path import exists
        for s in GENERATED_SOURCES:
            if not exists(s):
                all_gen_exist = False
                break

        if all_gen_exist:
            print("pyfmmlib uses mako [1] to generate its wrappers.")
            print("All the generated files are there, so we'll continue.")
            print(DASH_SEPARATOR)
            print("Hit Ctrl-C now if you'd like to think about the situation.")
            print(DASH_SEPARATOR)

            count_down_delay(delay=5)

        else:
            print("That is a problem because pyfmmlib uses mako [1] "
                  "to generate its wrappers.")
            print("Try typing")
            print("")
            print("  pip install mako")
            print("")
            print("or")
            print("  ez_install mako")
            print("")
            print("That should install it. If that doesn't work, "
                  "go to the mako website,")
            print(
                "download, and install by calling 'python setup.py install'.")
            print("")
            print("[1] http://www.makotemplates.org/")
            print(DASH_SEPARATOR)
            import sys
            sys.exit(1)
    else:
        generate_wrappers()

    # looks pointless, but allows 'python setup.py develop'--do not remove
    import setuptools  # noqa

    from numpy.distutils.core import Extension, setup

    from os.path import basename
    from glob import glob
    source_files = {}

    BLACKLIST = ["d2tstrcr_omp.f", "second-r8.f"]  # noqa

    for f in glob("fmmlib2d/src/*.f") + glob("fmmlib3d/src/*.f"):
        bn = basename(f)
        if bn in BLACKLIST:
            continue

        source_files[bn] = f

    source_files = GENERATED_SOURCES + list(source_files.values())

    import os
    extra_link_args = os.environ.get("EXTRA_LINK_ARGS", "").split()
    if extra_link_args == [""]:
        extra_link_args = []

    ver_dic = {}
    version_file = open("pyfmmlib/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyfmmlib/version.py", 'exec'),
         ver_dic)

    setup(name="pyfmmlib",
          version=ver_dic["VERSION_TEXT"],
          description="Python wrappers for particle FMMs",
          long_description=open("README.rst", "rt").read(),
          author="Leslie Greengard, Zydrunas Gimbutas, Andreas Kloeckner",
          author_email="*****@*****.**",
          license="wrapper: MIT/code: 3-clause BSD",
          url="http://github.com/inducer/pyfmmlib",
          classifiers=[
              'Development Status :: 4 - Beta',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'License :: OSI Approved :: BSD License',
              'Programming Language :: Fortran',
              'Programming Language :: Python',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Software Development :: Libraries',
          ],
          packages=["pyfmmlib"],
          setup_requires=[
              "numpy",
          ],
          ext_modules=[
              Extension(
                  "pyfmmlib._internal",
                  source_files,
                  extra_link_args=extra_link_args,
              ),
          ])
Exemple #7
0
def main():
    from aksetup_helper import (
        hack_distutils,
        get_config,
        setup,
        NumpyExtension,
        set_up_shipped_boost_if_requested,
        check_git_submodules,
    )

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(), warn_about_no_config=False)
    EXTRA_OBJECTS, EXTRA_DEFINES = set_up_shipped_boost_if_requested("pyopencl", conf)

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    EXTRA_INCLUDE_DIRS = []

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pyopencl"
    EXTRA_DEFINES["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        EXTRA_DEFINES["PYOPENCL_TRACE"] = 1

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"]

    if conf["CL_ENABLE_GL"]:
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CL_ENABLE_DEVICE_FISSION"]:
        EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1
    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            EXTRA_DEFINES["PYOPENCL_PRETEND_CL_VERSION"] = 0x1000 * major + 0x10 * minor
        except:
            print("CL_PRETEND_VERSION must be of the form M.N, " "with two integers M and N")
            raise

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", "exec"), ver_dic)

    SEPARATOR = "-" * 75
    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    try:
        import mako  # noqa
    except ImportError:
        print(SEPARATOR)
        print("Mako is not installed.")
        print(SEPARATOR)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it.Some higher-level parts of pyopencl (such as ")
        print("pyopencl.reduction) will not function without the templating engine ")
        print("Mako [1] being installed. If you would like this functionality to ")
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay

        count_down_delay(delay=5)

    might_be_cuda = False
    for inc_dir in conf["CL_INC_DIR"]:
        inc_dir = inc_dir.lower()
        if "nv" in inc_dir or "cuda" in inc_dir:
            might_be_cuda = True

    if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]:
        print(SEPARATOR)
        print("You might be compiling against Nvidia CUDA with device " "fission enabled.")
        print(SEPARATOR)
        print("That is not a problem on CUDA 4.0 and newer. If you are " "using CUDA 3.2,")
        print("your build will break, because Nvidia shipped a broken CL header in")
        print("in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False")
        print("in your PyOpenCL configuration.")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay

        count_down_delay(delay=5)

    import sys

    if sys.version_info >= (3,):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(
        name="pyopencl",
        # metadata
        version=ver_dic["VERSION_TEXT"],
        description="Python wrapper for OpenCL",
        long_description=open("README.rst", "rt").read(),
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pyopencl",
        classifiers=[
            "Environment :: Console",
            "Development Status :: 5 - Production/Stable",
            "Intended Audience :: Developers",
            "Intended Audience :: Other Audience",
            "Intended Audience :: Science/Research",
            "License :: OSI Approved :: MIT License",
            "Natural Language :: English",
            "Programming Language :: C++",
            "Programming Language :: Python",
            "Programming Language :: Python :: 2",
            "Programming Language :: Python :: 2.4",
            "Programming Language :: Python :: 2.5",
            "Programming Language :: Python :: 2.6",
            "Programming Language :: Python :: 2.7",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.2",
            "Programming Language :: Python :: 3.3",
            "Topic :: Scientific/Engineering",
            "Topic :: Scientific/Engineering :: Mathematics",
            "Topic :: Scientific/Engineering :: Physics",
        ],
        # build info
        packages=["pyopencl", "pyopencl.characterize", "pyopencl.compyte"],
        setup_requires=["numpy"],
        install_requires=[
            "pytools>=2014.2",
            "pytest>=2",
            "decorator>=3.2.0",
            # "Mako>=0.3.6",
        ],
        ext_package="pyopencl",
        ext_modules=[
            NumpyExtension(
                "_cl",
                [
                    "src/wrapper/wrap_cl.cpp",
                    "src/wrapper/wrap_cl_part_1.cpp",
                    "src/wrapper/wrap_cl_part_2.cpp",
                    "src/wrapper/wrap_constants.cpp",
                    "src/wrapper/wrap_mempool.cpp",
                    "src/wrapper/bitlog.cpp",
                ]
                + EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS + EXTRA_INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
                libraries=LIBRARIES + conf["CL_LIBNAME"],
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            NumpyExtension(
                "_pvt_struct", [pvt_struct_source], extra_compile_args=conf["CXXFLAGS"], extra_link_args=conf["LDFLAGS"]
            ),
        ],
        include_package_data=True,
        package_data={"pyopencl": ["cl/*.cl", "cl/*.h"]},
        # 2to3 invocation
        cmdclass={"build_py": build_py},
        zip_safe=False,
    )
Exemple #8
0
def main():
    from aksetup_helper import (hack_distutils, get_config, setup, Extension,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils(what_opt=1)
    conf = get_config(get_config_schema())

    TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested("meshpy", conf)
    TET_EXTRA_OBJECTS, TET_EXTRA_DEFINES = TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES

    triangle_macros = [
        ("EXTERNAL_TEST", 1),
        ("ANSI_DECLARATORS", 1),
        ("TRILIBRARY", 1),
    ] + list(TRI_EXTRA_DEFINES.items())

    tetgen_macros = [
        ("TETLIBRARY", 1),
        ("SELF_CHECK", 1),
    ] + list(TET_EXTRA_DEFINES.items())

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + ["src/cpp"]
    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    ######## simple use CMAKE to find get the directories:

    boost_variables = ["VERSION", "INCLUDE_DIRS", "LIB_DIRS", "LIBRARIES"]
    boost_dict = {}
    if sys.version_info.major < 3:
        output = os.popen("cmake . -Dpy_version=2")
    else:
        output = os.popen("cmake .")

    for line in output:
        for var in boost_variables:
            if var in line:
                line = line.replace('-- ' + var,
                                    '').replace(': ', '').replace('\n', '')
                boost_dict[var] = line
    if not "VERSION" in boost_dict:
        print("CMake didn't find any boost library")
        print("default installation will be used instead.")
    else:
        print("use cmake to detect bost")
        lib_name = os.path.basename(boost_dict["LIBRARIES"])
        lib_name = lib_name.replace(".lib", "").replace("lib",
                                                        "").replace(".so", "")
        INCLUDE_DIRS = [boost_dict["INCLUDE_DIRS"]] + ["src/cpp"]
        LIBRARY_DIRS = [boost_dict["LIB_DIRS"]]
        LIBRARIES = [lib_name]
    ########## end of CMAKE configuration

    print("using the following configuration:")
    print("INCLUDE_DIRS: ", INCLUDE_DIRS)
    print("LIBRARY_DIRS: ", LIBRARY_DIRS)
    print("LIBRARIES: ", LIBRARIES)

    init_filename = "meshpy/__init__.py"
    exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf)

    import codecs
    setup(
        name="MeshPy",
        version=conf["version"],
        description="Triangular and Tetrahedral Mesh Generator",
        long_description=codecs.open("README.rst", "r", "utf-8").read(),
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license=
        "MIT for the wrapper/non-commercial for the Triangle/GNU Affero Public License for TetGen",
        url="http://mathema.tician.de/software/meshpy",
        classifiers=[
            'Development Status :: 4 - Beta',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'License :: Free for non-commercial use',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.2',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Topic :: Multimedia :: Graphics :: 3D Modeling',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
            'Topic :: Scientific/Engineering :: Visualization',
            'Topic :: Software Development :: Libraries',
        ],
        packages=["meshpy"],
        install_requires=[
            "pytools>=2011.2",
            "pytest>=2",
            "numpy",
            "six",
        ],
        ext_modules=[
            Extension(
                "meshpy._triangle",
                ["src/cpp/wrap_triangle.cpp", "src/cpp/triangle.c"] +
                TRI_EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS,
                libraries=LIBRARIES,
                define_macros=triangle_macros,
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            Extension(
                "meshpy._tetgen",
                [
                    "src/cpp/tetgen.cpp", "src/cpp/predicates.cpp",
                    "src/cpp/wrap_tetgen.cpp"
                ] + TET_EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS,
                libraries=LIBRARIES,
                define_macros=tetgen_macros,
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ])
Exemple #9
0
def main():
    from aksetup_helper import (hack_distutils,
            get_config, setup, Extension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils(what_opt=1)
    conf = get_config(get_config_schema())

    TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested("meshpy", conf)
    TET_EXTRA_OBJECTS, TET_EXTRA_DEFINES = TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES

    triangle_macros = [
            ("EXTERNAL_TEST", 1),
            ("ANSI_DECLARATORS", 1),
            ("TRILIBRARY", 1),
            ] + list(TRI_EXTRA_DEFINES.items())

    tetgen_macros = [
            ("TETLIBRARY", 1),
            ("SELF_CHECK", 1),
            ] + list(TET_EXTRA_DEFINES.items())

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + ["src/cpp"]
    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    init_filename = "meshpy/__init__.py"
    exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    import codecs
    setup(name="MeshPy",
          version=conf["version"],
          description="Triangular and Tetrahedral Mesh Generator",
          long_description=codecs.open("README.rst", "r", "utf-8").read(),
          author="Andreas Kloeckner",
          author_email="*****@*****.**",
          license="MIT for the wrapper/non-commercial MIT for the meshers",
          url="http://mathema.tician.de/software/meshpy",
          classifiers=[
              'Development Status :: 4 - Beta',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'License :: Free for non-commercial use',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
              'Programming Language :: Python :: 3',
              'Topic :: Multimedia :: Graphics :: 3D Modeling',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Visualization',
              'Topic :: Software Development :: Libraries',
              ],

          packages=["meshpy"],
          install_requires=[
                  "pytools>=2011.2",
                  "pytest>=2",
                  "numpy",
                  ],
          ext_modules=[
              Extension(
                  "meshpy._triangle",
                  ["src/cpp/wrap_triangle.cpp", "src/cpp/triangle.c"]
                  + TRI_EXTRA_OBJECTS,
                  include_dirs=INCLUDE_DIRS,
                  library_dirs=LIBRARY_DIRS,
                  libraries=LIBRARIES,
                  define_macros=triangle_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              Extension(
                  "meshpy._tetgen",
                  [
                      "src/cpp/tetgen.cpp",
                      "src/cpp/predicates.cpp",
                      "src/cpp/wrap_tetgen.cpp"]
                  + TET_EXTRA_OBJECTS,
                  include_dirs=INCLUDE_DIRS,
                  library_dirs=LIBRARY_DIRS,
                  libraries=LIBRARIES,
                  define_macros=tetgen_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              ],

          # 2to3 invocation
          cmdclass={'build_py': build_py},
          )
Exemple #10
0
def main():
    from aksetup_helper import (hack_distutils,
            check_pybind11, get_config, setup, check_git_submodules,
            Extension,
            get_pybind_include, PybindBuildExtCommand)

    check_pybind11()
    check_git_submodules()

    hack_distutils(what_opt=1)
    conf = get_config(
            get_config_schema(),
            warn_about_no_config=False)

    triangle_macros = [
            ("EXTERNAL_TEST", 1),
            ("ANSI_DECLARATORS", 1),
            ("TRILIBRARY", 1),
            ]

    tetgen_macros = [
            ("TETLIBRARY", 1),
            ("SELF_CHECK", 1),
            ]

    # }}}

    include_dirs = [
            get_pybind_include(),
            get_pybind_include(user=True)
            ] + ["src/cpp"]

    init_filename = "meshpy/__init__.py"
    exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf)

    import codecs
    setup(name="MeshPy",
          version=conf["version"],
          description="Triangular and Tetrahedral Mesh Generator",
          long_description=codecs.open("README.rst", "r", "utf-8").read(),
          author="Andreas Kloeckner",
          author_email="*****@*****.**",
          license=("MIT for the wrapper/non-commercial for "
              "the Triangle/GNU Affero Public License for TetGen"),
          url="http://mathema.tician.de/software/meshpy",
          classifiers=[
              'Development Status :: 4 - Beta',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'License :: Free for non-commercial use',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
              'Programming Language :: Python :: 2.7',
              'Programming Language :: Python :: 3',
              'Programming Language :: Python :: 3.2',
              'Programming Language :: Python :: 3.3',
              'Programming Language :: Python :: 3.4',
              'Topic :: Multimedia :: Graphics :: 3D Modeling',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Visualization',
              'Topic :: Software Development :: Libraries',
              ],

          packages=["meshpy"],
          setup_requires=["pybind11"],
          install_requires=[
                  "pytools>=2011.2",
                  "pytest>=2",
                  "numpy",
                  "gmsh_interop",
                  "six",
                  ],
          ext_modules=[
              Extension(
                  "meshpy._internals",
                  [
                      "src/cpp/wrapper.cpp",

                      "src/cpp/wrap_triangle.cpp",
                      "src/cpp/triangle.cpp",

                      "src/cpp/wrap_tetgen.cpp",
                      "src/cpp/tetgen.cpp",
                      "src/cpp/predicates.cpp",
                      ],
                  include_dirs=include_dirs,
                  define_macros=triangle_macros + tetgen_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              ],
          cmdclass={'build_ext': PybindBuildExtCommand},
          zip_safe=False,
          )
Exemple #11
0
def main():
    check_pybind11()
    check_git_submodules()

    conf = get_config(get_config_schema(), warn_about_no_config=False)

    CXXFLAGS = conf["CXXFLAGS"]  # noqa: N806

    EXTRA_OBJECTS = []  # noqa: N806
    EXTRA_DEFINES = {}  # noqa: N806

    INCLUDE_DIRS = ["src/wrapper"]  # noqa: N806
    LIBRARY_DIRS = []  # noqa: N806
    LIBRARIES = []  # noqa: N806

    if conf["USE_SHIPPED_ISL"]:
        from glob import glob
        isl_blacklist = [
            "_templ.c",
            "_templ_yaml.c",
            "mp_get",
            "extract_key.c",
            "isl_multi_templ.c",
            "isl_multi_apply_set.c",
            "isl_multi_gist.c",
            "isl_multi_coalesce.c",
            "isl_multi_intersect.c",
            "isl_multi_floor.c",
            "isl_multi_apply_union_set.c",
            "isl_multi_cmp.c",
            "isl_multi_pw_aff_explicit_domain.c",
            "isl_multi_hash.c",
            "isl_multi_dims.c",
            "isl_multi_explicit_domain.c",
            "isl_multi_no_explicit_domain.c",
            "isl_multi_align_set.c",
            "isl_multi_align_union_set.c",
            "isl_multi_union_pw_aff_explicit_domain.c",
            "isl_union_templ.c",
            "isl_union_multi.c",
            "isl_union_eval.c",
            "isl_union_neg.c",
            "isl_union_single.c",
            "isl_pw_hash.c",
            "isl_pw_eval.c",
            "isl_pw_union_opt.c",
            "isl_pw_union_opt.c",
        ]

        for fn in glob("isl/*.c"):
            blacklisted = False
            for bl in isl_blacklist:
                if bl in fn:
                    blacklisted = True
                    break

            if "no_piplib" in fn:
                pass
            elif "piplib" in fn:
                blacklisted = True

            if "gmp" in fn:
                if conf["USE_SHIPPED_IMATH"]:
                    continue
            if "imath" in fn:
                if not conf["USE_SHIPPED_IMATH"]:
                    continue

                if "sioimath" in fn and not conf["USE_IMATH_SIO"]:
                    continue
                if "isl_val_imath" in fn and conf["USE_IMATH_SIO"]:
                    continue

            if "isl_ast_int.c" in fn and conf["USE_SHIPPED_IMATH"]:
                continue

            inf = open(fn, "r", encoding="utf-8")
            try:
                contents = inf.read()
            finally:
                inf.close()

            if "int main(" not in contents and not blacklisted:
                EXTRA_OBJECTS.append(fn)

        conf["ISL_INC_DIR"] = ["isl-supplementary", "isl/include", "isl"]

        if conf["USE_SHIPPED_IMATH"]:
            EXTRA_OBJECTS.extend([
                "isl/imath/imath.c",
                "isl/imath/imrat.c",
                "isl/imath/gmp_compat.c",
                #"isl/imath_wrap/imath.c",
                #"isl/imath_wrap/imrat.c",
                #"isl/imath_wrap/gmp_compat.c",
            ])
            EXTRA_DEFINES["USE_IMATH_FOR_MP"] = 1
            if conf["USE_IMATH_SIO"]:
                EXTRA_DEFINES["USE_SMALL_INT_OPT"] = 1

            conf["ISL_INC_DIR"].append("isl/imath")
        else:
            EXTRA_DEFINES["USE_GMP_FOR_MP"] = 1

    else:
        LIBRARY_DIRS.extend(conf["ISL_LIB_DIR"])
        LIBRARIES.extend(conf["ISL_LIBNAME"])

    wrapper_dirs = conf["ISL_INC_DIR"][:]

    # {{{ configure barvinok

    if conf["USE_BARVINOK"]:
        if conf["USE_SHIPPED_ISL"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                               "shipped isl")
        if conf["USE_SHIPPED_IMATH"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                               "shipped imath")

        INCLUDE_DIRS.extend(conf["BARVINOK_INC_DIR"])
        LIBRARY_DIRS.extend(conf["BARVINOK_LIB_DIR"])
        LIBRARIES.extend(conf["BARVINOK_LIBNAME"])

        wrapper_dirs.extend(conf["BARVINOK_INC_DIR"])

        EXTRA_DEFINES["ISLPY_INCLUDE_BARVINOK"] = 1

    # }}}

    INCLUDE_DIRS.extend(conf["ISL_INC_DIR"])

    if not (conf["USE_SHIPPED_ISL"] and conf["USE_SHIPPED_IMATH"]) and \
            conf["USE_GMP"]:
        INCLUDE_DIRS.extend(conf["GMP_INC_DIR"])
        LIBRARY_DIRS.extend(conf["GMP_LIB_DIR"])
        LIBRARIES.extend(conf["GMP_LIBNAME"])

    init_filename = "islpy/version.py"
    with open(init_filename, "r") as version_f:
        version_py = version_f.read()
    exec(compile(version_py, init_filename, "exec"), conf)

    from gen_wrap import gen_wrapper
    gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"])

    with open("README.rst", "rt") as readme_f:
        readme = readme_f.read()

    setup(
        name="islpy",
        version=conf["VERSION_TEXT"],
        description="Wrapper around isl, an integer set library",
        long_description=readme,
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://documen.tician.de/islpy",
        classifiers=[
            "Development Status :: 4 - Beta",
            "Intended Audience :: Developers",
            "Intended Audience :: Other Audience",
            "Intended Audience :: Science/Research",
            "License :: OSI Approved :: MIT License",
            "Natural Language :: English",
            "Programming Language :: C++",
            "Programming Language :: Python",
            "Programming Language :: Python :: 3",
            "Topic :: Multimedia :: Graphics :: 3D Modeling",
            "Topic :: Scientific/Engineering",
            "Topic :: Scientific/Engineering :: Mathematics",
            "Topic :: Scientific/Engineering :: Physics",
            "Topic :: Scientific/Engineering :: Visualization",
            "Topic :: Software Development :: Libraries",
        ],
        packages=["islpy"],
        python_requires="~=3.6",
        setup_requires=[
            "pybind11",
        ],
        install_requires=[
            "pytest>=2",
            # "Mako>=0.3.6",
            "six",
        ],
        ext_modules=[
            Extension(
                "islpy._isl",
                [
                    "src/wrapper/wrap_isl.cpp",
                    "src/wrapper/wrap_isl_part1.cpp",
                    "src/wrapper/wrap_isl_part2.cpp",
                    "src/wrapper/wrap_isl_part3.cpp",
                ] + EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS +
                [get_pybind_include(),
                 get_pybind_include(user=True)],
                library_dirs=LIBRARY_DIRS,
                libraries=LIBRARIES,
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=CXXFLAGS,
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        cmdclass={"build_ext": IslPyBuildExtCommand},
    )
Exemple #12
0
def main():
    from aksetup_helper import (hack_distutils, get_config, setup,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils(what_opt=None)
    conf = get_config(get_config_schema(), warn_about_no_config=False)

    EXTRA_SOURCES = []  # noqa
    EXTRA_DEFINES = {}  # noqa
    INCLUDE_DIRS = []  # noqa
    LIBRARY_DIRS = []  # noqa
    LIBRARIES = []  # noqa
    CXXFLAGS = conf["CXXFLAGS"]

    if conf["USE_SHIPPED_ISL"]:
        from glob import glob
        isl_blacklist = [
            "_templ.c",
            "mp_get",
            "isl_multi_templ.c",
            "isl_multi_apply_set.c",
            "isl_multi_gist.c",
            "isl_multi_coalesce.c",
            "isl_multi_intersect.c",
            "isl_multi_floor.c",
            "isl_multi_apply_union_set.c",
            "isl_multi_cmp.c",
            "isl_multi_hash.c",
            "isl_union_templ.c",
            "isl_union_multi.c",
            "isl_union_eval.c",
            "isl_union_neg.c",
            "isl_union_single.c",
            "isl_pw_hash.c",
            "isl_pw_union_opt.c",
        ]

        for fn in glob("isl/*.c"):
            blacklisted = False
            for bl in isl_blacklist:
                if bl in fn:
                    blacklisted = True
                    break

            if "no_piplib" in fn:
                pass
            elif "piplib" in fn:
                blacklisted = True

            if "gmp" in fn:
                if conf["USE_SHIPPED_IMATH"]:
                    continue
            if "imath" in fn:
                if not conf["USE_SHIPPED_IMATH"]:
                    continue

                if "sioimath" in fn and not conf["USE_IMATH_SIO"]:
                    continue
                if "isl_val_imath" in fn and conf["USE_IMATH_SIO"]:
                    continue

            if "isl_ast_int.c" in fn and conf["USE_SHIPPED_IMATH"]:
                continue

            inf = open(fn, "r", encoding="utf-8")
            try:
                contents = inf.read()
            finally:
                inf.close()

            if "int main(" not in contents and not blacklisted:
                EXTRA_SOURCES.append(fn)

        conf["ISL_INC_DIR"] = ["isl-supplementary", "isl/include", "isl"]

        if conf["USE_SHIPPED_IMATH"]:
            EXTRA_SOURCES.extend([
                "isl/imath/imath.c",
                "isl/imath/imrat.c",
                "isl/imath/gmp_compat.c",
                "isl/imath_wrap/imath.c",
                "isl/imath_wrap/imrat.c",
                "isl/imath_wrap/gmp_compat.c",
            ])
            EXTRA_DEFINES["USE_IMATH_FOR_MP"] = 1
            if conf["USE_IMATH_SIO"]:
                EXTRA_DEFINES["USE_SMALL_INT_OPT"] = 1

                import sys
                if sys.platform in ['linux', 'linux2', 'darwin']:
                    CXXFLAGS.insert(0, "-std=gnu99")

            conf["ISL_INC_DIR"].append("isl/imath")
        else:
            EXTRA_DEFINES["USE_GMP_FOR_MP"] = 1

    else:
        LIBRARY_DIRS.extend(conf["ISL_LIB_DIR"])
        LIBRARIES.extend(conf["ISL_LIBNAME"])

    wrapper_dirs = conf["ISL_INC_DIR"][:]

    # {{{ configure barvinok

    if conf["USE_BARVINOK"]:
        if conf["USE_SHIPPED_ISL"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                               "shipped isl")
        if conf["USE_SHIPPED_IMATH"]:
            raise RuntimeError("barvinok wrapper is not compatible with using "
                               "shipped imath")

        INCLUDE_DIRS.extend(conf["BARVINOK_INC_DIR"])
        LIBRARY_DIRS.extend(conf["BARVINOK_LIB_DIR"])
        LIBRARIES.extend(conf["BARVINOK_LIBNAME"])

        wrapper_dirs.extend(conf["BARVINOK_INC_DIR"])

        EXTRA_DEFINES["ISLPY_ISL_VERSION"] = 15

    # }}}

    INCLUDE_DIRS.extend(conf["ISL_INC_DIR"])

    if not (conf["USE_SHIPPED_ISL"] and conf["USE_SHIPPED_IMATH"]):
        INCLUDE_DIRS.extend(conf["GMP_INC_DIR"])
        LIBRARY_DIRS.extend(conf["GMP_LIB_DIR"])
        LIBRARIES.extend(conf["GMP_LIBNAME"])

    init_filename = "islpy/version.py"
    with open(init_filename, "r") as version_f:
        version_py = version_f.read()
    exec(compile(version_py, init_filename, "exec"), conf)

    from gen_wrap import gen_wrapper
    headers = gen_wrapper(wrapper_dirs,
                          include_barvinok=conf["USE_BARVINOK"],
                          isl_version=EXTRA_DEFINES.get("ISLPY_ISL_VERSION"))

    write_cffi_build_script(headers,
                            EXTRA_DEFINES=EXTRA_DEFINES,
                            EXTRA_SOURCES=EXTRA_SOURCES,
                            INCLUDE_DIRS=INCLUDE_DIRS,
                            LIBRARY_DIRS=LIBRARY_DIRS,
                            LIBRARIES=LIBRARIES,
                            CFLAGS=CXXFLAGS,
                            LDFLAGS=conf["LDFLAGS"])

    with open("README.rst", "rt") as readme_f:
        readme = readme_f.read()

    setup(
        name="islpy",
        version=conf["VERSION_TEXT"],
        description="Wrapper around isl, an integer set library",
        long_description=readme,
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://documen.tician.de/islpy",
        classifiers=[
            'Development Status :: 4 - Beta',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: Implementation :: CPython',
            'Programming Language :: Python :: Implementation :: PyPy',
            'Topic :: Multimedia :: Graphics :: 3D Modeling',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
            'Topic :: Scientific/Engineering :: Visualization',
            'Topic :: Software Development :: Libraries',
        ],
        packages=["islpy"],
        setup_requires=["cffi>=1.1.0"],
        cffi_modules=["islpy_cffi_build.py:ffi"],
        install_requires=[
            "pytest>=2",
            "cffi>=1.1.0",
            # "Mako>=0.3.6",
            "six",
        ],
    )
Exemple #13
0
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
            check_pybind11, check_git_submodules, ExtensionUsingNumpy,
            get_pybind_include, PybindBuildExtCommand)
    check_pybind11()
    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    extra_defines = {}

    extra_defines["PYGPU_PACKAGE"] = "pyopencl"
    extra_defines["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        extra_defines["PYOPENCL_TRACE"] = 1

    if conf["CL_ENABLE_GL"]:
        extra_defines["HAVE_GL"] = 1

    if conf["CL_USE_SHIPPED_EXT"]:
        extra_defines["PYOPENCL_USE_SHIPPED_EXT"] = 1

    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except Exception:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                    "with two integers M and N")
            raise

    conf["EXTRA_DEFINES"] = extra_defines

    INCLUDE_DIRS = conf["CL_INC_DIR"] + ["pybind11/include"]  # noqa: N806

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", "exec"), ver_dic)

    if not exists("pyopencl/compyte/dtypes.py"):
        print(75 * "-")
        print("You are missing important files from the pyopencl distribution.")
        print(75 * "-")
        print("You may have downloaded a zip or tar file from Github.")
        print("Those do not work, and I am unable to prevent Github from showing")
        print("them. Delete that file, and get an actual release file from the")
        print("Python package index:")
        print()
        print("https://pypi.python.org/pypi/pyopencl")
        sys.exit(1)

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description=open("README.rst").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
                "Environment :: Console",
                "Development Status :: 5 - Production/Stable",
                "Intended Audience :: Developers",
                "Intended Audience :: Other Audience",
                "Intended Audience :: Science/Research",
                "License :: OSI Approved :: MIT License",
                "Natural Language :: English",
                "Programming Language :: C++",
                "Programming Language :: Python",
                "Programming Language :: Python :: 3",
                "Topic :: Scientific/Engineering",
                "Topic :: Scientific/Engineering :: Mathematics",
                "Topic :: Scientific/Engineering :: Physics",
                ],

            # build info
            packages=find_packages(),

            ext_modules=[
                ExtensionUsingNumpy("pyopencl._cl",
                    [
                        "src/wrap_constants.cpp",
                        "src/wrap_cl.cpp",
                        "src/wrap_cl_part_1.cpp",
                        "src/wrap_cl_part_2.cpp",
                        "src/wrap_mempool.cpp",
                        "src/bitlog.cpp",
                        ],
                    include_dirs=INCLUDE_DIRS + [
                        get_pybind_include(),
                        ],
                    library_dirs=conf["CL_LIB_DIR"],
                    libraries=conf["CL_LIBNAME"],
                    define_macros=list(conf["EXTRA_DEFINES"].items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    language="c++",
                    ),
                ],

            setup_requires=[
                "pybind11>=2.5.0",
                "numpy",
                ],

            python_requires="~=3.6",
            install_requires=[
                "numpy",
                "pytools>=2021.2.7",
                "platformdirs>=2.2.0",
                # "Mako>=0.3.6",

                "dataclasses; python_version<'3.7'",
                ],
            extras_require={
                "pocl":  ["pocl_binary_distribution>=1.2"],
                "oclgrind":  ["oclgrind_binary_distribution>=18.3"],
                "test": ["pytest>=7.0.0", "Mako"],
            },
            include_package_data=True,
            package_data={
                    "pyopencl": [
                        "cl/*.cl",
                        "cl/*.h",
                        "cl/pyopencl-random123/*.cl",
                        "cl/pyopencl-random123/*.h",
                        ]
                    },

            cmdclass={"build_ext": PybindBuildExtCommand},
            zip_safe=False)
Exemple #14
0
def main():
    import glob
    from aksetup_helper import (hack_distutils, get_config, setup,
                                NumpyExtension,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(), warn_about_no_config=False)
    EXTRA_OBJECTS, EXTRA_DEFINES = set_up_shipped_boost_if_requested(
        "pyopencl", conf)

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    EXTRA_INCLUDE_DIRS = []

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pyopencl"
    EXTRA_DEFINES["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        EXTRA_DEFINES["PYOPENCL_TRACE"] = 1

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"]

    if conf["CL_ENABLE_GL"]:
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CL_ENABLE_DEVICE_FISSION"]:
        EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1
    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [
                int(x) for x in conf["CL_PRETEND_VERSION"].split(".")
            ]
            EXTRA_DEFINES[
                "PYOPENCL_PRETEND_CL_VERSION"] = 0x1000 * major + 0x10 * minor
        except:
            print(
                "CL_PRETEND_VERSION must be of the form M.N, with two integers M and N"
            )
            raise

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'),
         ver_dic)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    try:
        import mako
    except ImportError:
        print(
            "-------------------------------------------------------------------------"
        )
        print("Mako is not installed.")
        print(
            "-------------------------------------------------------------------------"
        )
        print(
            "That is not a problem, as most of PyOpenCL will be just fine without it."
        )
        print(
            "Some higher-level parts of pyopencl (such as pyopencl.reduction)")
        print(
            "will not function without the templating engine Mako [1] being installed."
        )
        print(
            "If you would like this functionality to work, you might want to install"
        )
        print("Mako after you finish installing PyOpenCL.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(
            "-------------------------------------------------------------------------"
        )
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(
            "-------------------------------------------------------------------------"
        )

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    might_be_cuda = False
    for inc_dir in conf["CL_INC_DIR"]:
        inc_dir = inc_dir.lower()
        if "nv" in inc_dir or "cuda" in inc_dir:
            might_be_cuda = True

    if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]:
        print(
            "-------------------------------------------------------------------------"
        )
        print(
            "You might be compiling against Nvidia CUDA with device fission enabled."
        )
        print(
            "-------------------------------------------------------------------------"
        )
        print(
            "That is not a problem on CUDA 4.0 and newer. If you are using CUDA 3.2,"
        )
        print(
            "your build will break, because Nvidia shipped a broken CL header in"
        )
        print(
            "in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False"
        )
        print("in your PyOpenCL configuration.")
        print(
            "-------------------------------------------------------------------------"
        )
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(
            "-------------------------------------------------------------------------"
        )

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    import sys
    if sys.version_info >= (3, ):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(
        name="pyopencl",
        # metadata
        version=ver_dic["VERSION_TEXT"],
        description="Python wrapper for OpenCL",
        long_description="""
            PyOpenCL lets you access GPUs and other massively parallel compute
            devices from Python. It tries to offer computing goodness in the
            spirit of its sister project `PyCUDA <http://mathema.tician.de/software/pycuda>`_:

            * Object cleanup tied to lifetime of objects. This idiom, often
              called
              `RAII <http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`_
              in C++, makes it much easier to write correct, leak- and
              crash-free code.

            * Completeness. PyOpenCL puts the full power of OpenCL's API at
              your disposal, if you wish.  Every obscure `get_info()` query and 
              all CL calls are accessible.

            * Automatic Error Checking. All CL errors are automatically
              translated into Python exceptions.

            * Speed. PyOpenCL's base layer is written in C++, so all the niceties
              above are virtually free.

            * Helpful and complete `Documentation <http://documen.tician.de/pyopencl>`_
              as well as a `Wiki <http://wiki.tiker.net/PyOpenCL>`_.

            * Liberal license. PyOpenCL is open-source under the 
              `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_
              and free for commercial, academic, and private use.

            * Broad support. PyOpenCL was tested and works with Apple's, AMD's, and Nvidia's 
              CL implementations.

            Like PyOpenCL? (And perhaps use it for `bitcoin
            <http://bitcoin.org>`_ mining?) Leave a (bitcoin) tip:
            1HGPQitv27CdENBcH1bstu5B3zeqXRDwtY
            """,
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pyopencl",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 3',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
        ],

        # build info
        packages=["pyopencl", "pyopencl.characterize", "pyopencl.compyte"],
        install_requires=[
            "pytools>=2011.2",
            "pytest>=2",
            "decorator>=3.2.0",
            # "Mako>=0.3.6",
        ],
        ext_package="pyopencl",
        ext_modules=[
            NumpyExtension(
                "_cl",
                [
                    "src/wrapper/wrap_cl.cpp",
                    "src/wrapper/wrap_cl_part_1.cpp",
                    "src/wrapper/wrap_cl_part_2.cpp",
                    "src/wrapper/wrap_constants.cpp",
                    "src/wrapper/wrap_mempool.cpp",
                    "src/wrapper/bitlog.cpp",
                ] + EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS + EXTRA_INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
                libraries=LIBRARIES + conf["CL_LIBNAME"],
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            NumpyExtension(
                "_pvt_struct",
                [pvt_struct_source],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        data_files=[("include/pyopencl",
                     glob.glob("src/cl/*.cl") + glob.glob("src/cl/*.h"))],

        # 2to3 invocation
        cmdclass={'build_py': build_py})
Exemple #15
0
def main():
    import glob
    from aksetup_helper import (hack_distutils, get_config, setup,
            NumpyExtension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)
    EXTRA_OBJECTS, EXTRA_DEFINES = set_up_shipped_boost_if_requested("pyopencl", conf)

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    from os.path import dirname, join, normpath

    EXTRA_INCLUDE_DIRS = []
    EXTRA_LIBRARY_DIRS = []
    EXTRA_LIBRARIES = []

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pyopencl"
    EXTRA_DEFINES["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        EXTRA_DEFINES["PYOPENCL_TRACE"] = 1

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"]

    ext_kwargs = dict()

    if conf["CL_ENABLE_GL"]:
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CL_ENABLE_DEVICE_FISSION"]:
        EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    try:
        import mako
    except ImportError:
        print("-------------------------------------------------------------------------")
        print("Mako is not installed.")
        print("-------------------------------------------------------------------------")
        print("That is not a problem, as most of PyOpenCL will be just fine without it.")
        print("Some higher-level parts of pyopencl (pyopencl.reduction, to be precise)")
        print("will not function without the templating engine Mako [1] being installed.")
        print("If you would like this functionality to work, you might want to install")
        print("Mako after you finish installing PyOpenCL.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print("-------------------------------------------------------------------------")
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print("-------------------------------------------------------------------------")

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    might_be_cuda = False
    for inc_dir in conf["CL_INC_DIR"]:
        inc_dir = inc_dir.lower()
        if "nv" in inc_dir or "cuda" in inc_dir:
            might_be_cuda = True

    if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]:
        print("-------------------------------------------------------------------------")
        print("You might be compiling against Nvidia CUDA with device fission enabled.")
        print("-------------------------------------------------------------------------")
        print("That is not a problem on CUDA 4.0 and newer. If you are using CUDA 3.2,")
        print("your build will break, because Nvidia shipped a broken CL header in")
        print("in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False")
        print("in your PyOpenCL configuration.")
        print("-------------------------------------------------------------------------")
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print("-------------------------------------------------------------------------")

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    import sys
    if sys.version_info >= (3,):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description="""
            PyOpenCL lets you access GPUs and other massively parallel compute
            devices from Python. It tries to offer computing goodness in the
            spirit of its sister project `PyCUDA <http://mathema.tician.de/software/pycuda>`_:

            * Object cleanup tied to lifetime of objects. This idiom, often
              called
              `RAII <http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`_
              in C++, makes it much easier to write correct, leak- and
              crash-free code.

            * Completeness. PyOpenCL puts the full power of OpenCL's API at
              your disposal, if you wish.  Every obscure `get_info()` query and 
              all CL calls are accessible.

            * Automatic Error Checking. All CL errors are automatically
              translated into Python exceptions.

            * Speed. PyOpenCL's base layer is written in C++, so all the niceties
              above are virtually free.

            * Helpful and complete `Documentation <http://documen.tician.de/pyopencl>`_
              as well as a `Wiki <http://wiki.tiker.net/PyOpenCL>`_.

            * Liberal license. PyOpenCL is open-source under the 
              `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_
              and free for commercial, academic, and private use.

            * Broad support. PyOpenCL was tested and works with Apple's, AMD's, and Nvidia's 
              CL implementations.

            Like PyOpenCL? (And perhaps use it for `bitcoin
            <http://bitcoin.org>`_ mining?) Leave a (bitcoin) tip:
            1HGPQitv27CdENBcH1bstu5B3zeqXRDwtY
            """,
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license = "MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
              'Environment :: Console',
              'Development Status :: 5 - Production/Stable',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
            'Programming Language :: Python :: 3',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              ],

            # build info
            packages=["pyopencl", "pyopencl.characterize", "pyopencl.compyte"],

            install_requires=[
                "pytools>=2011.2",
                "pytest>=2",
                "decorator>=3.2.0",
                # "Mako>=0.3.6",
                ],

            ext_package="pyopencl",
            ext_modules=[
                NumpyExtension("_cl", 
                    [
                        "src/wrapper/wrap_cl.cpp", 
                        "src/wrapper/wrap_cl_part_1.cpp", 
                        "src/wrapper/wrap_cl_part_2.cpp", 
                        "src/wrapper/wrap_constants.cpp", 
                        "src/wrapper/wrap_mempool.cpp", 
                        "src/wrapper/bitlog.cpp", 
                        ]+EXTRA_OBJECTS, 
                    include_dirs=INCLUDE_DIRS + EXTRA_INCLUDE_DIRS,
                    library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
                    libraries=LIBRARIES + conf["CL_LIBNAME"],
                    define_macros=list(EXTRA_DEFINES.items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                NumpyExtension("_pvt_struct",
                    [pvt_struct_source],
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                ],

            data_files=[
                ("include/pyopencl",
                    glob.glob("src/cl/*.cl") + glob.glob("src/cl/*.h"))
                ],

            # 2to3 invocation
            cmdclass={'build_py': build_py})
Exemple #16
0
def main():
    import glob
    import sys

    from aksetup_helper import (hack_distutils, get_config, setup, \
            NumpyExtension, Extension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils(debug=True)
    conf = get_config(get_config_schema())
    EXTRA_SOURCES, EXTRA_DEFINES = set_up_shipped_boost_if_requested(
        "pycuda", conf)

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pycuda"
    EXTRA_DEFINES["PYGPU_PYCUDA"] = "1"

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"] + conf["CUDADRV_LIB_DIR"]
    LIBRARIES = (conf["BOOST_PYTHON_LIBNAME"] + conf["BOOST_THREAD_LIBNAME"] +
                 conf["CUDADRV_LIBNAME"])

    if not conf["CUDA_INC_DIR"]:
        conf["CUDA_INC_DIR"] = [join(conf["CUDA_ROOT"], "include")]

    if conf["CUDA_TRACE"]:
        EXTRA_DEFINES["CUDAPP_TRACE_CUDA"] = 1

    if conf["CUDA_PRETEND_VERSION"]:
        EXTRA_DEFINES["CUDAPP_PRETEND_CUDA_VERSION"] = conf[
            "CUDA_PRETEND_VERSION"]

    INCLUDE_DIRS = ['src/cpp'] + conf["BOOST_INC_DIR"] + conf["CUDA_INC_DIR"]
    conf["USE_CUDA"] = True

    if 'darwin' in sys.platform and sys.maxsize == 2147483647:
        # The Python interpreter is running in 32 bit mode on OS X
        if "-arch" not in conf["CXXFLAGS"]:
            conf["CXXFLAGS"].extend(['-arch', 'i386', '-m32'])
        if "-arch" not in conf["LDFLAGS"]:
            conf["LDFLAGS"].extend(['-arch', 'i386', '-m32'])

    if 'darwin' in sys.platform:
        # set path to Cuda dynamic libraries,
        # as a safe substitute for DYLD_LIBRARY_PATH
        for lib_dir in conf["CUDADRV_LIB_DIR"]:
            conf["LDFLAGS"].extend(["-Xlinker", "-rpath", "-Xlinker", lib_dir])

    if conf["CUDA_ENABLE_GL"]:
        EXTRA_SOURCES.append("src/wrapper/wrap_cudagl.cpp")
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CUDA_ENABLE_CURAND"]:
        EXTRA_DEFINES["HAVE_CURAND"] = 1
        EXTRA_SOURCES.extend(["src/wrapper/wrap_curand.cpp"])
        LIBRARIES.extend(conf["CURAND_LIBNAME"])
        LIBRARY_DIRS.extend(conf["CURAND_LIB_DIR"])

    ver_dic = {}
    exec(
        compile(
            open("pycuda/__init__.py").read(), "pycuda/__init__.py", 'exec'),
        ver_dic)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    setup(
        name="pycuda",
        # metadata
        version=ver_dic["VERSION_TEXT"],
        description="Python wrapper for Nvidia CUDA",
        long_description="""
            PyCUDA lets you access `Nvidia <http://nvidia.com>`_'s `CUDA
            <http://nvidia.com/cuda/>`_ parallel computation API from Python.
            Several wrappers of the CUDA API already exist-so what's so special
            about PyCUDA?

            * Object cleanup tied to lifetime of objects. This idiom, often
              called
              `RAII <http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`_
              in C++, makes it much easier to write correct, leak- and
              crash-free code. PyCUDA knows about dependencies, too, so (for
              example) it won't detach from a context before all memory
              allocated in it is also freed.

            * Convenience. Abstractions like pycuda.driver.SourceModule and
              pycuda.gpuarray.GPUArray make CUDA programming even more
              convenient than with Nvidia's C-based runtime.

            * Completeness. PyCUDA puts the full power of CUDA's driver API at
              your disposal, if you wish. It also includes code for
              interoperability with OpenGL.

            * Automatic Error Checking. All CUDA errors are automatically
              translated into Python exceptions.

            * Speed. PyCUDA's base layer is written in C++, so all the niceties
              above are virtually free.

            * Helpful `Documentation <http://documen.tician.de/pycuda>`_ and a
              `Wiki <http://wiki.tiker.net/PyCuda>`_.

            Relatedly, like-minded computing goodness for `OpenCL <http://khronos.org>`_
            is provided by PyCUDA's sister project `PyOpenCL <http://pypi.python.org/pypi/pyopencl>`_.
            """,
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pycuda",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
            'Topic :: Scientific/Engineering :: Visualization',
        ],

        # build info
        packages=["pycuda", "pycuda.gl", "pycuda.sparse", "pycuda.compyte"],
        install_requires=["pytools>=2011.2", "pytest>=2", "decorator>=3.2.0"],
        ext_package="pycuda",
        ext_modules=[
            NumpyExtension(
                "_driver",
                [
                    "src/cpp/cuda.cpp",
                    "src/cpp/bitlog.cpp",
                    "src/wrapper/wrap_cudadrv.cpp",
                    "src/wrapper/mempool.cpp",
                ] + EXTRA_SOURCES,
                include_dirs=INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS,
                libraries=LIBRARIES,
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            NumpyExtension(
                "_pvt_struct",
                ["src/wrapper/_pycuda_struct.cpp"],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        data_files=[("include/pycuda", glob.glob("src/cuda/*.hpp"))],

        # 2to3 invocation
        cmdclass={'build_py': build_py})
Exemple #17
0
def main():
    from aksetup_helper import (hack_distutils, get_config, setup,
                                NumpyExtension,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(), warn_about_no_config=False)
    EXTRA_OBJECTS, EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested("pyopencl", conf)

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
    LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]

    EXTRA_INCLUDE_DIRS = []

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pyopencl"
    EXTRA_DEFINES["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        EXTRA_DEFINES["PYOPENCL_TRACE"] = 1

    INCLUDE_DIRS = conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"]

    if conf["CL_ENABLE_GL"]:
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CL_ENABLE_DEVICE_FISSION"]:
        EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1
    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [
                int(x) for x in conf["CL_PRETEND_VERSION"].split(".")
            ]
            EXTRA_DEFINES["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                  "with two integers M and N")
            raise

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'),
         ver_dic)

    SEPARATOR = "-" * 75
    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    try:
        import mako  # noqa
    except ImportError:
        print(SEPARATOR)
        print("Mako is not installed.")
        print(SEPARATOR)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it.Some higher-level parts of pyopencl (such as ")
        print(
            "pyopencl.reduction) will not function without the templating engine "
        )
        print(
            "Mako [1] being installed. If you would like this functionality to "
        )
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    might_be_cuda = False
    for inc_dir in conf["CL_INC_DIR"]:
        inc_dir = inc_dir.lower()
        if "nv" in inc_dir or "cuda" in inc_dir:
            might_be_cuda = True

    if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]:
        print(SEPARATOR)
        print("You might be compiling against Nvidia CUDA with device "
              "fission enabled.")
        print(SEPARATOR)
        print("That is not a problem on CUDA 4.0 and newer. If you are "
              "using CUDA 3.2,")
        print(
            "your build will break, because Nvidia shipped a broken CL header in"
        )
        print(
            "in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False"
        )
        print("in your PyOpenCL configuration.")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    import sys
    if sys.version_info >= (3, ):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(
        name="pyopencl",
        # metadata
        version=ver_dic["VERSION_TEXT"],
        description="Python wrapper for OpenCL",
        long_description=open("README.rst", "rt").read(),
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pyopencl",
        classifiers=[
            'Environment :: Console',
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: Other Audience',
            'Intended Audience :: Science/Research',
            'License :: OSI Approved :: MIT License',
            'Natural Language :: English',
            'Programming Language :: C++',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.4',
            'Programming Language :: Python :: 2.5',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.2',
            'Programming Language :: Python :: 3.3',
            'Topic :: Scientific/Engineering',
            'Topic :: Scientific/Engineering :: Mathematics',
            'Topic :: Scientific/Engineering :: Physics',
        ],

        # build info
        packages=["pyopencl", "pyopencl.characterize", "pyopencl.compyte"],
        install_requires=[
            "pytools>=2013.5.2",
            "pytest>=2",
            "decorator>=3.2.0",
            # "Mako>=0.3.6",
        ],
        ext_package="pyopencl",
        ext_modules=[
            NumpyExtension(
                "_cl",
                [
                    "src/wrapper/wrap_cl.cpp",
                    "src/wrapper/wrap_cl_part_1.cpp",
                    "src/wrapper/wrap_cl_part_2.cpp",
                    "src/wrapper/wrap_constants.cpp",
                    "src/wrapper/wrap_mempool.cpp",
                    "src/wrapper/bitlog.cpp",
                ] + EXTRA_OBJECTS,
                include_dirs=INCLUDE_DIRS + EXTRA_INCLUDE_DIRS,
                library_dirs=LIBRARY_DIRS + conf["CL_LIB_DIR"],
                libraries=LIBRARIES + conf["CL_LIBNAME"],
                define_macros=list(EXTRA_DEFINES.items()),
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
            NumpyExtension(
                "_pvt_struct",
                [pvt_struct_source],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        include_package_data=True,
        package_data={"pyopencl": [
            "cl/*.cl",
            "cl/*.h",
        ]},

        # 2to3 invocation
        cmdclass={'build_py': build_py},
        zip_safe=False)
Exemple #18
0
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
            check_pybind11, check_git_submodules, NumpyExtension)
    check_pybind11()
    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    extra_defines = {}

    extra_defines["PYGPU_PACKAGE"] = "pyopencl"
    extra_defines["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        extra_defines["PYOPENCL_TRACE"] = 1

    if conf["CL_ENABLE_GL"]:
        extra_defines["HAVE_GL"] = 1

    if conf["CL_USE_SHIPPED_EXT"]:
        extra_defines["PYOPENCL_USE_SHIPPED_EXT"] = 1

    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except Exception:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                    "with two integers M and N")
            raise

    conf["EXTRA_DEFINES"] = extra_defines

    INCLUDE_DIRS = conf["CL_INC_DIR"] + ["pybind11/include"]  # noqa: N806

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic)

    try:
        import mako  # noqa
    except ImportError:
        print(SEPARATOR)
        print("Mako is not installed.")
        print(SEPARATOR)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it. Some higher-level parts of pyopencl (such as ")
        print("pyopencl.reduction) will not function without the templating engine ")
        print("Mako [1] being installed. If you would like this functionality to ")
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("Simply type")
        print("python -m pip install mako")
        print("either now or after the installation completes to fix this.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    if not exists("pyopencl/compyte/dtypes.py"):
        print(75 * "-")
        print("You are missing important files from the pyopencl distribution.")
        print(75 * "-")
        print("You may have downloaded a zip or tar file from Github.")
        print("Those do not work, and I am unable to prevent Github from showing")
        print("them. Delete that file, and get an actual release file from the")
        print("Python package index:")
        print()
        print("https://pypi.python.org/pypi/pyopencl")
        sys.exit(1)

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description=open("README.rst", "rt").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
                'Environment :: Console',
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'Intended Audience :: Other Audience',
                'Intended Audience :: Science/Research',
                'License :: OSI Approved :: MIT License',
                'Natural Language :: English',
                'Programming Language :: C++',
                'Programming Language :: Python',
                'Programming Language :: Python :: 2',
                'Programming Language :: Python :: 2.7',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.2',
                'Programming Language :: Python :: 3.3',
                'Topic :: Scientific/Engineering',
                'Topic :: Scientific/Engineering :: Mathematics',
                'Topic :: Scientific/Engineering :: Physics',
                ],

            # build info
            packages=find_packages(),

            ext_modules=[
                NumpyExtension("pyopencl._cl",
                    [
                        "src/wrap_constants.cpp",
                        "src/wrap_cl.cpp",
                        "src/wrap_cl_part_1.cpp",
                        "src/wrap_cl_part_2.cpp",
                        "src/wrap_mempool.cpp",
                        "src/bitlog.cpp",
                        ],
                    include_dirs=INCLUDE_DIRS + [
                        get_pybind_include(),
                        get_pybind_include(user=True)
                        ],
                    library_dirs=conf["CL_LIB_DIR"],
                    libraries=conf["CL_LIBNAME"],
                    define_macros=list(conf["EXTRA_DEFINES"].items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    language='c++',
                    ),
                ],

            setup_requires=[
                "pybind11",
                "numpy",
                ],

            install_requires=[
                "numpy",
                "pytools>=2017.6",
                "decorator>=3.2.0",
                "appdirs>=1.4.0",
                "six>=1.9.0",
                # "Mako>=0.3.6",
                ],

            include_package_data=True,
            package_data={
                    "pyopencl": [
                        "cl/*.cl",
                        "cl/*.h",
                        "cl/pyopencl-random123/*.cl",
                        "cl/pyopencl-random123/*.h",
                        ]
                    },

            cmdclass={'build_ext': BuildExt},
            zip_safe=False)
Exemple #19
0
def main():
    import sys

    from aksetup_helper import (hack_distutils, get_config, setup,
            NumpyExtension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema())

    EXTRA_SOURCES, EXTRA_DEFINES = set_up_shipped_boost_if_requested("pycuda", conf)

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pycuda"
    EXTRA_DEFINES["PYGPU_PYCUDA"] = "1"

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"] + conf["CUDADRV_LIB_DIR"]
    LIBRARIES = (conf["BOOST_PYTHON_LIBNAME"] + conf["BOOST_THREAD_LIBNAME"]
            + conf["CUDADRV_LIBNAME"])

    if not conf["CUDA_INC_DIR"] and conf["CUDA_ROOT"]:
        conf["CUDA_INC_DIR"] = [join(conf["CUDA_ROOT"], "include")]

    if conf["CUDA_TRACE"]:
        EXTRA_DEFINES["CUDAPP_TRACE_CUDA"] = 1

    if conf["CUDA_PRETEND_VERSION"]:
        EXTRA_DEFINES["CUDAPP_PRETEND_CUDA_VERSION"] = conf["CUDA_PRETEND_VERSION"]

    INCLUDE_DIRS = ['src/cpp'] + conf["BOOST_INC_DIR"]
    if conf["CUDA_INC_DIR"]:
        INCLUDE_DIRS += conf["CUDA_INC_DIR"]

    conf["USE_CUDA"] = True

    if 'darwin' in sys.platform and sys.maxsize == 2147483647:
        # The Python interpreter is running in 32 bit mode on OS X
        if "-arch" not in conf["CXXFLAGS"]:
            conf["CXXFLAGS"].extend(['-arch', 'i386', '-m32'])
        if "-arch" not in conf["LDFLAGS"]:
            conf["LDFLAGS"].extend(['-arch', 'i386', '-m32'])

    if 'darwin' in sys.platform:
        # set path to Cuda dynamic libraries,
        # as a safe substitute for DYLD_LIBRARY_PATH
        for lib_dir in conf["CUDADRV_LIB_DIR"]:
            conf["LDFLAGS"].extend(["-Xlinker", "-rpath", "-Xlinker", lib_dir])

    if conf["CUDA_ENABLE_GL"]:
        EXTRA_SOURCES.append("src/wrapper/wrap_cudagl.cpp")
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CUDA_ENABLE_CURAND"]:
        EXTRA_DEFINES["HAVE_CURAND"] = 1
        EXTRA_SOURCES.extend([
            "src/wrapper/wrap_curand.cpp"
            ])
        LIBRARIES.extend(conf["CURAND_LIBNAME"])
        LIBRARY_DIRS.extend(conf["CURAND_LIB_DIR"])

    ver_dic = {}
    exec(compile(open("pycuda/__init__.py").read(), "pycuda/__init__.py", 'exec'),
            ver_dic)

    import sys
    if sys.version_info >= (3,):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(name="pycuda",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for Nvidia CUDA",
            long_description=open("README.rst", "rt").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pycuda",
            classifiers=[
                'Environment :: Console',
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'Intended Audience :: Other Audience',
                'Intended Audience :: Science/Research',
                'License :: OSI Approved :: MIT License',
                'Natural Language :: English',
                'Programming Language :: C++',
                'Programming Language :: Python',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 2.6',
                'Programming Language :: Python :: 2.7',
                'Programming Language :: Python :: 3.3',
                'Programming Language :: Python :: 3.4',
                'Topic :: Scientific/Engineering',
                'Topic :: Scientific/Engineering :: Mathematics',
                'Topic :: Scientific/Engineering :: Physics',
                'Topic :: Scientific/Engineering :: Visualization',
                ],

            # build info
            packages=["pycuda", "pycuda.gl", "pycuda.sparse", "pycuda.compyte"],

            setup_requires=[
                "numpy>=1.6",
                ],

            install_requires=[
                "pytools>=2011.2",
                "pytest>=2",
                "decorator>=3.2.0",
                "appdirs>=1.4.0",
                "mako",
                ],

            ext_package="pycuda",
            ext_modules=[
                NumpyExtension("_driver",
                    [
                        "src/cpp/cuda.cpp",
                        "src/cpp/bitlog.cpp",
                        "src/wrapper/wrap_cudadrv.cpp",
                        "src/wrapper/mempool.cpp",
                        ]+EXTRA_SOURCES,
                    include_dirs=INCLUDE_DIRS,
                    library_dirs=LIBRARY_DIRS,
                    libraries=LIBRARIES,
                    define_macros=list(EXTRA_DEFINES.items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                NumpyExtension("_pvt_struct",
                    [pvt_struct_source],
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                ],

            include_package_data=True,
            package_data={
                    "pycuda": [
                        "cuda/*.hpp",
                        ]
                    },

            zip_safe=False)
Exemple #20
0
def main():
    import glob
    import sys

    from aksetup_helper import (hack_distutils, get_config, setup, \
            NumpyExtension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema())

    EXTRA_SOURCES, EXTRA_DEFINES = set_up_shipped_boost_if_requested("pycuda", conf)

    EXTRA_DEFINES["PYGPU_PACKAGE"] = "pycuda"
    EXTRA_DEFINES["PYGPU_PYCUDA"] = "1"

    LIBRARY_DIRS = conf["BOOST_LIB_DIR"] + conf["CUDADRV_LIB_DIR"]
    LIBRARIES = (conf["BOOST_PYTHON_LIBNAME"] + conf["BOOST_THREAD_LIBNAME"]
            + conf["CUDADRV_LIBNAME"])

    if not conf["CUDA_INC_DIR"]:
        conf["CUDA_INC_DIR"] = [join(conf["CUDA_ROOT"], "include")]

    if conf["CUDA_TRACE"]:
        EXTRA_DEFINES["CUDAPP_TRACE_CUDA"] = 1

    if conf["CUDA_PRETEND_VERSION"]:
        EXTRA_DEFINES["CUDAPP_PRETEND_CUDA_VERSION"] = conf["CUDA_PRETEND_VERSION"]

    INCLUDE_DIRS = ['src/cpp'] + conf["BOOST_INC_DIR"] + conf["CUDA_INC_DIR"]
    conf["USE_CUDA"] = True

    if 'darwin' in sys.platform and sys.maxsize == 2147483647:
        # The Python interpreter is running in 32 bit mode on OS X
        if "-arch" not in conf["CXXFLAGS"]:
            conf["CXXFLAGS"].extend(['-arch', 'i386', '-m32'])
        if "-arch" not in conf["LDFLAGS"]:
            conf["LDFLAGS"].extend(['-arch', 'i386', '-m32'])

    if 'darwin' in sys.platform:
        # set path to Cuda dynamic libraries,
        # as a safe substitute for DYLD_LIBRARY_PATH
        for lib_dir in conf["CUDADRV_LIB_DIR"]:
            conf["LDFLAGS"].extend(["-Xlinker", "-rpath", "-Xlinker", lib_dir])

    if conf["CUDA_ENABLE_GL"]:
        EXTRA_SOURCES.append("src/wrapper/wrap_cudagl.cpp")
        EXTRA_DEFINES["HAVE_GL"] = 1

    if conf["CUDA_ENABLE_CURAND"]:
        EXTRA_DEFINES["HAVE_CURAND"] = 1
        EXTRA_SOURCES.extend([
            "src/wrapper/wrap_curand.cpp"
            ])
        LIBRARIES.extend(conf["CURAND_LIBNAME"])
        LIBRARY_DIRS.extend(conf["CURAND_LIB_DIR"])

    ver_dic = {}
    exec(compile(open("pycuda/__init__.py").read(), "pycuda/__init__.py", 'exec'), ver_dic)

    try:
        from distutils.command.build_py import build_py_2to3 as build_py
    except ImportError:
        # 2.x
        from distutils.command.build_py import build_py

    import sys
    if sys.version_info >= (3,):
        pvt_struct_source = "src/wrapper/_pvt_struct_v3.cpp"
    else:
        pvt_struct_source = "src/wrapper/_pvt_struct_v2.cpp"

    setup(name="pycuda",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for Nvidia CUDA",
            long_description="""
            PyCUDA lets you access `Nvidia <http://nvidia.com>`_'s `CUDA
            <http://nvidia.com/cuda/>`_ parallel computation API from Python.
            Several wrappers of the CUDA API already exist-so what's so special
            about PyCUDA?

            * Object cleanup tied to lifetime of objects. This idiom, often
              called
              `RAII <http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`_
              in C++, makes it much easier to write correct, leak- and
              crash-free code. PyCUDA knows about dependencies, too, so (for
              example) it won't detach from a context before all memory
              allocated in it is also freed.

            * Convenience. Abstractions like pycuda.driver.SourceModule and
              pycuda.gpuarray.GPUArray make CUDA programming even more
              convenient than with Nvidia's C-based runtime.

            * Completeness. PyCUDA puts the full power of CUDA's driver API at
              your disposal, if you wish. It also includes code for
              interoperability with OpenGL.

            * Automatic Error Checking. All CUDA errors are automatically
              translated into Python exceptions.

            * Speed. PyCUDA's base layer is written in C++, so all the niceties
              above are virtually free.

            * Helpful `Documentation <http://documen.tician.de/pycuda>`_ and a
              `Wiki <http://wiki.tiker.net/PyCuda>`_.

            Relatedly, like-minded computing goodness for `OpenCL <http://khronos.org>`_
            is provided by PyCUDA's sister project `PyOpenCL <http://pypi.python.org/pypi/pyopencl>`_.
            """,
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license = "MIT",
            url="http://mathema.tician.de/software/pycuda",
            classifiers=[
              'Environment :: Console',
              'Development Status :: 5 - Production/Stable',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Visualization',
              ],

            # build info
            packages=["pycuda", "pycuda.gl", "pycuda.sparse", "pycuda.compyte"],

            install_requires=[
                "pytools>=2011.2",
                "pytest>=2",
                "decorator>=3.2.0"
                ],

            ext_package="pycuda",
            ext_modules=[
                NumpyExtension("_driver",
                    [
                        "src/cpp/cuda.cpp",
                        "src/cpp/bitlog.cpp",
                        "src/wrapper/wrap_cudadrv.cpp",
                        "src/wrapper/mempool.cpp",
                        ]+EXTRA_SOURCES,
                    include_dirs=INCLUDE_DIRS,
                    library_dirs=LIBRARY_DIRS,
                    libraries=LIBRARIES,
                    define_macros=list(EXTRA_DEFINES.items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                NumpyExtension("_pvt_struct",
                    [pvt_struct_source],
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    ),
                ],

            data_files=[
                ("include/pycuda", glob.glob("src/cuda/*.hpp"))
                ],

            # 2to3 invocation
            cmdclass={'build_py': build_py})
Exemple #21
0
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
            check_git_submodules)
    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    extra_defines = {}

    extra_defines["PYGPU_PACKAGE"] = "pyopencl"
    extra_defines["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        extra_defines["PYOPENCL_TRACE"] = 1

    if conf["CL_ENABLE_GL"]:
        extra_defines["HAVE_GL"] = 1

    if conf["CL_USE_SHIPPED_EXT"]:
        extra_defines["PYOPENCL_USE_SHIPPED_EXT"] = 1

    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                    "with two integers M and N")
            raise

    conf["EXTRA_DEFINES"] = extra_defines

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic)

    separator = "-"*75

    try:
        import mako  # noqa
    except ImportError:
        print(separator)
        print("Mako is not installed.")
        print(separator)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it. Some higher-level parts of pyopencl (such as ")
        print("pyopencl.reduction) will not function without the templating engine ")
        print("Mako [1] being installed. If you would like this functionality to ")
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("Simply type")
        print("python -m pip install mako")
        print("either now or after the installation completes to fix this.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(separator)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(separator)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    # {{{ write cffi build script

    with open("cffi_build.py.in", "rt") as f:
        build_script_template = f.read()

    format_args = {}
    for k, v in conf.items():
        format_args[k] = repr(v)

    build_script = build_script_template.format(**format_args)

    with open("cffi_build.py", "wt") as f:
        f.write(build_script)

    # }}}

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description=open("README.rst", "rt").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
                'Environment :: Console',
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'Intended Audience :: Other Audience',
                'Intended Audience :: Science/Research',
                'License :: OSI Approved :: MIT License',
                'Natural Language :: English',
                'Programming Language :: C++',
                'Programming Language :: Python',
                'Programming Language :: Python :: 2',
                'Programming Language :: Python :: 2.6',
                'Programming Language :: Python :: 2.7',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.2',
                'Programming Language :: Python :: 3.3',
                'Topic :: Scientific/Engineering',
                'Topic :: Scientific/Engineering :: Mathematics',
                'Topic :: Scientific/Engineering :: Physics',
                ],

            # build info
            packages=find_packages(),

            setup_requires=[
                "numpy",
                "cffi>=1.1.0",
                ],

            install_requires=[
                "numpy",
                "pytools>=2017.2",
                "pytest>=2",
                "decorator>=3.2.0",
                "cffi>=1.1.0",
                "appdirs>=1.4.0",
                "six>=1.9.0",
                # "Mako>=0.3.6",
                ],

            cffi_modules=["cffi_build.py:ffi"],

            include_package_data=True,
            package_data={
                    "pyopencl": [
                        "cl/*.cl",
                        "cl/*.h",
                        "cl/pyopencl-random123/*.cl",
                        "cl/pyopencl-random123/*.h",
                        ]
                    },

            zip_safe=False)
Exemple #22
0
def main():
    from aksetup_helper import (hack_distutils,
            get_config, setup, Extension, set_up_shipped_boost_if_requested,
            check_git_submodules)

    check_git_submodules()

    hack_distutils(what_opt=1)
    conf = get_config(get_config_schema())

    TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES = \
            set_up_shipped_boost_if_requested("meshpy", conf)
    TET_EXTRA_OBJECTS, TET_EXTRA_DEFINES = TRI_EXTRA_OBJECTS, TRI_EXTRA_DEFINES

    triangle_macros = [
            ("EXTERNAL_TEST", 1),
            ("ANSI_DECLARATORS", 1),
            ("TRILIBRARY", 1),
            ] + list(TRI_EXTRA_DEFINES.items())

    tetgen_macros = [
            ("TETLIBRARY", 1),
            ("SELF_CHECK", 1),
            ] + list(TET_EXTRA_DEFINES.items())

    # }}}

    include_dirs = conf["BOOST_INC_DIR"] + ["src/cpp"]
    library_dirs = conf["BOOST_LIB_DIR"]
    libraries = conf["BOOST_PYTHON_LIBNAME"]

    init_filename = "meshpy/__init__.py"
    exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf)

    import codecs
    setup(name="MeshPy",
          version=conf["version"],
          description="Triangular and Tetrahedral Mesh Generator",
          long_description=codecs.open("README.rst", "r", "utf-8").read(),
          author="Andreas Kloeckner",
          author_email="*****@*****.**",
          license=("MIT for the wrapper/non-commercial for "
              "the Triangle/GNU Affero Public License for TetGen"),
          url="http://mathema.tician.de/software/meshpy",
          classifiers=[
              'Development Status :: 4 - Beta',
              'Intended Audience :: Developers',
              'Intended Audience :: Other Audience',
              'Intended Audience :: Science/Research',
              'License :: OSI Approved :: MIT License',
              'License :: Free for non-commercial use',
              'Natural Language :: English',
              'Programming Language :: C++',
              'Programming Language :: Python',
              'Programming Language :: Python :: 2.6',
              'Programming Language :: Python :: 2.7',
              'Programming Language :: Python :: 3',
              'Programming Language :: Python :: 3.2',
              'Programming Language :: Python :: 3.3',
              'Programming Language :: Python :: 3.4',
              'Topic :: Multimedia :: Graphics :: 3D Modeling',
              'Topic :: Scientific/Engineering',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Visualization',
              'Topic :: Software Development :: Libraries',
              ],

          packages=["meshpy"],
          install_requires=[
                  "pytools>=2011.2",
                  "pytest>=2",
                  "numpy",
                  "six",
                  ],
          ext_modules=[
              Extension(
                  "meshpy._triangle",
                  ["src/cpp/wrap_triangle.cpp", "src/cpp/triangle.c"]
                  + TRI_EXTRA_OBJECTS,
                  include_dirs=include_dirs,
                  library_dirs=library_dirs,
                  libraries=libraries,
                  define_macros=triangle_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              Extension(
                  "meshpy._tetgen",
                  [
                      "src/cpp/tetgen.cpp",
                      "src/cpp/predicates.cpp",
                      "src/cpp/wrap_tetgen.cpp"]
                  + TET_EXTRA_OBJECTS,
                  include_dirs=include_dirs,
                  library_dirs=library_dirs,
                  libraries=libraries,
                  define_macros=tetgen_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              ])
Exemple #23
0
def main():
    from aksetup_helper import (hack_distutils,
            check_pybind11, get_config, setup, check_git_submodules,
            Extension,
            get_pybind_include, PybindBuildExtCommand)

    check_pybind11()
    check_git_submodules()

    hack_distutils(what_opt=1)
    conf = get_config(
            get_config_schema(),
            warn_about_no_config=False)

    triangle_macros = [
            ("EXTERNAL_TEST", 1),
            ("ANSI_DECLARATORS", 1),
            ("TRILIBRARY", 1),
            ]

    tetgen_macros = [
            ("TETLIBRARY", 1),
            ("SELF_CHECK", 1),
            ]

    # }}}

    include_dirs = [
            get_pybind_include(),
            get_pybind_include(user=True)
            ] + ["src/cpp"]

    init_filename = "meshpy/__init__.py"
    exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf)

    import codecs
    setup(name="MeshPy",
          version=conf["version"],
          description="Triangular and Tetrahedral Mesh Generator",
          long_description=codecs.open("README.rst", "r", "utf-8").read(),
          author="Andreas Kloeckner",
          author_email="*****@*****.**",
          license=("MIT for the wrapper/non-commercial for "
              "the Triangle/GNU Affero Public License for TetGen"),
          url="https://documen.tician.de/meshpy",
          classifiers=[
              "Development Status :: 4 - Beta",
              "Intended Audience :: Developers",
              "Intended Audience :: Other Audience",
              "Intended Audience :: Science/Research",
              "License :: OSI Approved :: MIT License",
              "License :: Free for non-commercial use",
              "Natural Language :: English",
              "Programming Language :: C++",
              "Programming Language :: Python",
              "Programming Language :: Python :: 3",
              "Topic :: Multimedia :: Graphics :: 3D Modeling",
              "Topic :: Scientific/Engineering",
              "Topic :: Scientific/Engineering :: Mathematics",
              "Topic :: Scientific/Engineering :: Physics",
              "Topic :: Scientific/Engineering :: Visualization",
              "Topic :: Software Development :: Libraries",
              ],

          packages=["meshpy"],
          setup_requires=["pybind11"],
          python_requires="~=3.6",
          install_requires=[
                  "pytools>=2011.2",
                  "pytest>=2",
                  "numpy",
                  "gmsh_interop",
                  ],
          ext_modules=[
              Extension(
                  "meshpy._internals",
                  [
                      "src/cpp/wrapper.cpp",

                      "src/cpp/wrap_triangle.cpp",
                      "src/cpp/triangle.cpp",

                      "src/cpp/wrap_tetgen.cpp",
                      "src/cpp/tetgen.cpp",
                      "src/cpp/predicates.cpp",
                      ],
                  include_dirs=include_dirs,
                  define_macros=triangle_macros + tetgen_macros,
                  extra_compile_args=conf["CXXFLAGS"],
                  extra_link_args=conf["LDFLAGS"],
                  ),
              ],
          cmdclass={"build_ext": PybindBuildExtCommand},
          zip_safe=False,
          )
Exemple #24
0
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
            check_pybind11, check_git_submodules, ExtensionUsingNumpy,
            get_pybind_include, PybindBuildExtCommand)
    check_pybind11()
    check_git_submodules()

    hack_distutils()
    conf = get_config(get_config_schema(),
            warn_about_no_config=False)

    extra_defines = {}

    extra_defines["PYGPU_PACKAGE"] = "pyopencl"
    extra_defines["PYGPU_PYOPENCL"] = "1"

    if conf["CL_TRACE"]:
        extra_defines["PYOPENCL_TRACE"] = 1

    if conf["CL_ENABLE_GL"]:
        extra_defines["HAVE_GL"] = 1

    if conf["CL_USE_SHIPPED_EXT"]:
        extra_defines["PYOPENCL_USE_SHIPPED_EXT"] = 1

    if conf["CL_PRETEND_VERSION"]:
        try:
            major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
            extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \
                    0x1000*major + 0x10 * minor
        except Exception:
            print("CL_PRETEND_VERSION must be of the form M.N, "
                    "with two integers M and N")
            raise

    conf["EXTRA_DEFINES"] = extra_defines

    INCLUDE_DIRS = conf["CL_INC_DIR"] + ["pybind11/include"]  # noqa: N806

    ver_dic = {}
    version_file = open("pyopencl/version.py")
    try:
        version_file_contents = version_file.read()
    finally:
        version_file.close()

    exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic)

    try:
        import mako  # noqa
    except ImportError:
        print(SEPARATOR)
        print("Mako is not installed.")
        print(SEPARATOR)
        print("That is not a problem, as most of PyOpenCL will be just fine ")
        print("without it. Some higher-level parts of pyopencl (such as ")
        print("pyopencl.reduction) will not function without the templating engine ")
        print("Mako [1] being installed. If you would like this functionality to ")
        print("work, you might want to install Mako after you finish ")
        print("installing PyOpenCL.")
        print("")
        print("Simply type")
        print("python -m pip install mako")
        print("either now or after the installation completes to fix this.")
        print("")
        print("[1] http://www.makotemplates.org/")
        print(SEPARATOR)
        print("Hit Ctrl-C now if you'd like to think about the situation.")
        print(SEPARATOR)

        from aksetup_helper import count_down_delay
        count_down_delay(delay=5)

    if not exists("pyopencl/compyte/dtypes.py"):
        print(75 * "-")
        print("You are missing important files from the pyopencl distribution.")
        print(75 * "-")
        print("You may have downloaded a zip or tar file from Github.")
        print("Those do not work, and I am unable to prevent Github from showing")
        print("them. Delete that file, and get an actual release file from the")
        print("Python package index:")
        print()
        print("https://pypi.python.org/pypi/pyopencl")
        sys.exit(1)

    setup(name="pyopencl",
            # metadata
            version=ver_dic["VERSION_TEXT"],
            description="Python wrapper for OpenCL",
            long_description=open("README.rst", "rt").read(),
            author="Andreas Kloeckner",
            author_email="*****@*****.**",
            license="MIT",
            url="http://mathema.tician.de/software/pyopencl",
            classifiers=[
                'Environment :: Console',
                'Development Status :: 5 - Production/Stable',
                'Intended Audience :: Developers',
                'Intended Audience :: Other Audience',
                'Intended Audience :: Science/Research',
                'License :: OSI Approved :: MIT License',
                'Natural Language :: English',
                'Programming Language :: C++',
                'Programming Language :: Python',
                'Programming Language :: Python :: 2',
                'Programming Language :: Python :: 2.7',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.2',
                'Programming Language :: Python :: 3.3',
                'Topic :: Scientific/Engineering',
                'Topic :: Scientific/Engineering :: Mathematics',
                'Topic :: Scientific/Engineering :: Physics',
                ],

            # build info
            packages=find_packages(),

            ext_modules=[
                ExtensionUsingNumpy("pyopencl._cl",
                    [
                        "src/wrap_constants.cpp",
                        "src/wrap_cl.cpp",
                        "src/wrap_cl_part_1.cpp",
                        "src/wrap_cl_part_2.cpp",
                        "src/wrap_mempool.cpp",
                        "src/bitlog.cpp",
                        ],
                    include_dirs=INCLUDE_DIRS + [
                        get_pybind_include(),
                        get_pybind_include(user=True)
                        ],
                    library_dirs=conf["CL_LIB_DIR"],
                    libraries=conf["CL_LIBNAME"],
                    define_macros=list(conf["EXTRA_DEFINES"].items()),
                    extra_compile_args=conf["CXXFLAGS"],
                    extra_link_args=conf["LDFLAGS"],
                    language='c++',
                    ),
                ],

            setup_requires=[
                "pybind11",
                "numpy",
                ],

            install_requires=[
                "numpy",
                "pytools>=2017.6",
                "decorator>=3.2.0",
                "appdirs>=1.4.0",
                "six>=1.9.0",
                # "Mako>=0.3.6",
                ],
            extras_require={
                'pocl':  ["pocl_binary_distribution>=1.2"],
                'oclgrind':  ["oclgrind_binary_distribution>=18.3"],
            },
            include_package_data=True,
            package_data={
                    "pyopencl": [
                        "cl/*.cl",
                        "cl/*.h",
                        "cl/pyopencl-random123/*.cl",
                        "cl/pyopencl-random123/*.h",
                        ]
                    },

            cmdclass={'build_ext': PybindBuildExtCommand},
            zip_safe=False)