Newer
Older
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
#!/usr/bin/env python
# -*- coding: latin-1 -*-
def get_config_schema():
from aksetup_helper import ConfigSchema, Option, \
IncludeDir, LibraryDir, Libraries, \
Switch, StringListOption
return ConfigSchema([
IncludeDir("BOOST", []),
LibraryDir("BOOST", []),
Libraries("BOOST_PYTHON", ["boost_python-gcc42-mt"]),
IncludeDir("BOOST_BINDINGS", []),
Option("CUDA_ROOT", help="Path to the CUDA toolkit"),
Option("CUDA_BIN_DIR", help="Path to the CUDA executables"),
IncludeDir("CUDA", None),
LibraryDir("CUDA", None),
Libraries("CUDA", ["cublas", "cudart"]),
StringListOption("CXXFLAGS", [],
help="Any extra C++ compiler options to include"),
StringListOption("LDFLAGS", [],
help="Any extra linker options to include"),
])
def search_on_path(filename):
"""Given a search path, find file
"""
from os.path import exists, join, abspath
from os import pathsep, environ
search_path = environ["PATH"]
file_found = 0
paths = search_path.split(pathsep)
for path in paths:
if exists(join(path, filename)):
file_found = 1
break
if file_found:
return abspath(join(path, filename))
else:
return None
def main():
import glob
from aksetup_helper import hack_distutils, get_config, setup, \
PyUblasExtension
hack_distutils()
conf = get_config(get_config_schema())
LIBRARY_DIRS = conf["BOOST_LIB_DIR"]
LIBRARIES = conf["BOOST_PYTHON_LIBNAME"]
from os.path import dirname, join, normpath
if conf["CUDA_ROOT"] is None:
conf["CUDA_ROOT"] = normpath(join(dirname(search_on_path("nvcc")), ".."))
if conf["CUDA_BIN_DIR"] is None:
conf["CUDA_BIN_DIR"] = join(conf["CUDA_ROOT"], "bin")
if conf["CUDA_INC_DIR"] is None:
conf["CUDA_INC_DIR"] = [join(conf["CUDA_ROOT"], "inc")]
if conf["CUDA_LIB_DIR"] is None:
conf["CUDA_LIB_DIR"] = [join(conf["CUDA_ROOT"], "lib")]
EXTRA_DEFINES = { "PYUBLAS_HAVE_BOOST_BINDINGS":1 }
EXTRA_INCLUDE_DIRS = []
EXTRA_LIBRARY_DIRS = []
EXTRA_LIBRARIES = []
INCLUDE_DIRS = [
"src/cpp",
] \
+ conf["BOOST_BINDINGS_INC_DIR"] \
+ conf["BOOST_INC_DIR"] \
conf["USE_CUDA"] = True
def handle_component(comp):
if conf["USE_"+comp]:
EXTRA_DEFINES["USE_"+comp] = 1
EXTRA_INCLUDE_DIRS.extend(conf[comp+"_INC_DIR"])
EXTRA_LIBRARY_DIRS.extend(conf[comp+"_LIB_DIR"])
EXTRA_LIBRARIES.extend(conf[comp+"_LIBNAME"])
handle_component("CUDA")
setup(name="pycuda",
# metadata
version="0.90",
description="Python wrapper for Nvidia CUDA",
author=u"Andreas Kloeckner",
author_email="inform@tiker.net",
license = "MIT",
url="http://mathema.tician.de/software/hedge",
classifiers=[
'Environment :: Console',
'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',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Visualization',
],
# dependencies
setup_requires=[
"PyUblas>=0.92.5",
],
install_requires=[
"PyUblas>=0.92.5",
],
# build info
packages=["pycuda"],
zip_safe=False,
package_dir={"pycuda": "src/python"},
ext_package="pycuda",
ext_modules=[
PyUblasExtension("_internal",
["src/wrapper/wrap_main.cpp",
],
include_dirs=INCLUDE_DIRS + EXTRA_INCLUDE_DIRS,
library_dirs=LIBRARY_DIRS + EXTRA_LIBRARY_DIRS,
libraries=LIBRARIES + EXTRA_LIBRARIES,
define_macros=list(EXTRA_DEFINES.iteritems()),
extra_compile_args=conf["CXXFLAGS"],
extra_link_args=conf["LDFLAGS"],
),
],
)
if __name__ == '__main__':
main()