forked from stefanv/scikits.cuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
146 lines (123 loc) · 5.02 KB
/
setup.py
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
#!/usr/bin/env python
import sys
import os
from glob import glob
from setuptools.command.build_py import build_py
from distutils.command.install_headers import install_headers
from setuptools import find_packages
from numpy.distutils.core import setup
NAME = 'scikits.cuda'
VERSION = '0.02'
IS_RELEASED = True
AUTHOR = 'Lev Givon'
AUTHOR_EMAIL = 'lev@columbia.edu'
URL = 'http://bionet.ee.columbia.edu/code/'
DESCRIPTION = 'Python utilities for CUDA'
LONG_DESCRIPTION = DESCRIPTION
DOWNLOAD_URL = URL
LICENSE = 'BSD'
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Software Development']
NAMESPACE_PACKAGES = ['scikits']
PACKAGES = find_packages()
def get_version(version, is_released=True):
"""
Return package version. If `is_released` is True, append the
package Mercurial revision.
"""
full_version = version
if not is_released and os.path.exists('.hg'):
# Do not read any config file when running mercurial:
os.environ['HGRCPATH'] = ''
cmd = '%s /usr/bin/hg id -it' % sys.executable
try:
l = os.popen(cmd).read().split()
except OSError, e:
print "warning: could not determine version: %s" % e
# Toss non-numbered tags:
while len(l) > 1 and l[-1][0].isalpha():
l.pop()
if l:
# Get the latest tag or revision number:
version = l[-1]
# Append the current time if the source code has been
# modified but not checked in:
if version.endswith('+'):
version += time.strftime('%Y%m%d')
# Append the global Mercurial revision:
full_version += '.dev.'+version
return full_version
def write_version_py(version, filename='scikits/cuda/version.py'):
"""
Write the indicated package version to the specified Python file.
"""
f = file(filename, "w")
f.write("# THIS FILE IS GENERATED BY THE CUDA SCIKITS SETUP.PY FILE\n")
f.write("__version__ = '" + version + "'\n")
f.close()
# Overwrite the copy of scikits/cuda/__info__.py that will be
# installed with the actual header installation path. This is
# necessary so that PyCUDA can find the headers when executing the
# kernels in this package that use it:
class custom_build_py(build_py):
def run(self):
build_py.run(self)
package_dir = self.get_package_dir('scikits.cuda')
inst_obj = self.distribution.command_obj['install']
install_headers_pdir, _ = os.path.split(inst_obj.install_headers)
self.install_dir = install_headers_pdir + '/scikits/cuda'
filename = os.path.join(self.build_lib, package_dir, '__info__.py')
f = open(filename, 'w')
f.write('# Installation location of C headers:\n')
f.write('install_headers = \"%s\"\n' % self.install_dir)
f.close()
# Install the C headers in scikits/cuda rather than scikits.cuda:
class custom_install_headers(install_headers):
def run(self):
inst_obj = self.distribution.command_obj['install']
install_headers_pdir, _ = os.path.split(inst_obj.install_headers)
self.install_dir = install_headers_pdir + '/scikits/cuda'
install_headers.run(self)
def configuration(parent_package='', top_path=None,
package_name=NAME):
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path,
version = VERSION,
author = AUTHOR,
author_email = AUTHOR_EMAIL,
license = LICENSE,
url = URL,
download_url = DOWNLOAD_URL,
description = DESCRIPTION,
long_description = LONG_DESCRIPTION,
classifiers = CLASSIFIERS)
config.set_options(
ignore_setup_xxx_py = True,
assume_default_configuration = True,
delegate_options_to_subpackages = True,
quiet = True,
)
config.add_subpackage('scikits')
config.add_data_files('scikits/__init__.py')
config.add_subpackage(NAME)
return config
if __name__ == "__main__":
write_version_py(get_version(VERSION, IS_RELEASED))
setup(configuration = configuration,
name = NAME,
namespace_packages = NAMESPACE_PACKAGES,
packages = PACKAGES,
headers = glob('scikits/cuda/*.h'),
install_requires = ["numpy",
"pycuda >= 0.94rc"],
cmdclass={"build_py": custom_build_py,
"install_headers": custom_install_headers})