예제 #1
0
파일: setup.py 프로젝트: ziiin/pycuda
def main():
    import sys

    from aksetup_helper import (hack_distutils, get_config, setup,
                                ExtensionUsingNumpy,
                                set_up_shipped_boost_if_requested,
                                check_git_submodules, NumpyBuildExtCommand)

    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=[
            ExtensionUsingNumpy(
                "_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"],
            ),
            ExtensionUsingNumpy(
                "_pvt_struct",
                [pvt_struct_source],
                extra_compile_args=conf["CXXFLAGS"],
                extra_link_args=conf["LDFLAGS"],
            ),
        ],
        cmdclass={'build_ext': NumpyBuildExtCommand},
        include_package_data=True,
        package_data={"pycuda": [
            "cuda/*.hpp",
        ]},
        zip_safe=False)
예제 #2
0
파일: setup.py 프로젝트: inducer/pyvisfile
def main():
    from setuptools import find_packages
    from aksetup_helper import (hack_distutils, get_config, setup,
                                ExtensionUsingNumpy, check_pybind11,
                                PybindBuildExtCommand, get_pybind_include)

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

    extra_defines = {}
    extra_include_dirs = []
    extra_library_dirs = []
    extra_libraries = []

    ver_dic = {}
    ver_file_name = "pyvisfile/__init__.py"
    with open(ver_file_name) as inf:
        exec(compile(inf.read(), ver_file_name, "exec"), ver_dic)

    requirements = []
    ext_modules = []

    if conf["USE_SILO"]:
        check_pybind11()

        extra_defines["USE_SILO"] = 1
        extra_include_dirs.extend(conf["SILO_INC_DIR"])
        extra_library_dirs.extend(conf["SILO_LIB_DIR"])
        extra_libraries.extend(conf["SILO_LIBNAME"])

        ext_modules.append(
            ExtensionUsingNumpy(
                "_internal",
                ["src/wrapper/wrap_silo.cpp"],
                include_dirs=[get_pybind_include()] + extra_include_dirs,
                library_dirs=extra_library_dirs,
                libraries=extra_libraries,
                extra_compile_args=conf["CXXFLAGS"],
                define_macros=list(extra_defines.items()),
                language="c++",
            ))
        requirements.append("pybind11>=2.5.0")

    setup(
        name="pyvisfile",
        version=ver_dic["VERSION_TEXT"],
        description="Large-scale Visualization Data Storage",
        long_description=open("README.rst").read(),
        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",
        ],
        author="Andreas Kloeckner",
        author_email="*****@*****.**",
        license="MIT",
        url="http://mathema.tician.de/software/pyvisfile",

        # dependencies
        setup_requires=requirements,
        python_requires="~=3.6",
        install_requires=[
            "pytools>=2013.2",
        ] + requirements,
        packages=find_packages(),
        ext_package="pyvisfile.silo",
        ext_modules=ext_modules,
        cmdclass={"build_ext": PybindBuildExtCommand},
        zip_safe=False)
예제 #3
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",
        ],
        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)
예제 #4
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)