1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
__copyright__ = """
Copyright (C) 2009-15 Andreas Kloeckner
Copyright (C) 2013 Marko Bencun
Copyright (C) 2013 Marko Bencun
"""
__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import sys
def get_config_schema():
from aksetup_helper import ConfigSchema, Option, \
IncludeDir, LibraryDir, Libraries, \
Switch, StringListOption
default_cxxflags = ['-std=c++0x']
if 'darwin' in sys.platform:
import platform
osx_ver, _, _ = platform.mac_ver()
osx_ver = '.'.join(osx_ver.split('.')[:2])
sysroot_paths = [
"/Applications/Xcode.app/Contents/Developer/Platforms/"
"MacOSX.platform/Developer/SDKs/MacOSX%s.sdk" % osx_ver,
"/Developer/SDKs/MacOSX%s.sdk" % osx_ver
]
default_libs = []
default_cxxflags = default_cxxflags + [
'-stdlib=libc++', '-mmacosx-version-min=10.7',
'-arch', 'i386', '-arch', 'x86_64'
]
from os.path import isdir
for srp in sysroot_paths:
if isdir(srp):
default_cxxflags.extend(['-isysroot', srp])
break
default_ldflags = default_cxxflags[:] + ["-Wl,-framework,OpenCL"]
else:
default_libs = ["OpenCL"]
default_ldflags = []
return ConfigSchema([
Switch("CL_TRACE", False, "Enable OpenCL API tracing"),
Switch("CL_ENABLE_GL", False, "Enable OpenCL<->OpenGL interoperability"),
Switch(
"CL_USE_SHIPPED_EXT", True,
"Use the pyopencl version of CL/cl_ext.h which includes" +
" a broader range of vendor-specific OpenCL extension attributes" +
" than the standard Khronos (or vendor specific) CL/cl_ext.h."),
Option("CL_PRETEND_VERSION", None,
"Dotted CL version (e.g. 1.2) which you'd like to use."),
IncludeDir("CL", []),
LibraryDir("CL", []),
Libraries("CL", default_libs),
StringListOption("CXXFLAGS", default_cxxflags,
help="Any extra C++ compiler options to include"),
StringListOption("LDFLAGS", default_ldflags,
help="Any extra linker options to include"),
])
def main():
from setuptools import find_packages
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_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)
# {{{ 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="inform@tiker.net",
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",
"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)
if __name__ == '__main__':
main()
|