forked from gieseke/bufferkdtree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
162 lines (135 loc) · 5.76 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#! /usr/bin/env python
#
# Copyright (C) 2013-2016 Fabian Gieseke <[email protected]>
# License: GPL v2
#
# Inspired by https://github.com/scikit-learn/scikit-learn/blob/master/setup.py
# Copyright (C) 2007-2009 Cournapeau David <[email protected]>
# 2010 Fabian Pedregosa <[email protected]>
# License: 3-clause BSD
#
import os
import sys
import shutil
from distutils.command.clean import clean
# set flag to indicate that package
# is installed (similar to scikit-learn
# installation routine)
if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins
builtins.__BUFFERKDTREE_SETUP__ = True
DISTNAME = 'bufferkdtree'
DESCRIPTION = 'A Python library for large-scale exact nearest neighbor search using Buffer k-d Trees (bufferkdtree).'
LONG_DESCRIPTION = open('README.rst').read()
MAINTAINER = 'Fabian Gieseke'
MAINTAINER_EMAIL = '[email protected]'
URL = 'https://github.com/gieseke/bufferkdtree'
LICENSE = 'GNU GENERAL PUBLIC LICENSE Version 2'
DOWNLOAD_URL = 'https://github.com/gieseke/bufferkdtree'
# adapted from scikit-learn
if len(set(('develop', 'release')).intersection(sys.argv)) > 0:
import setuptools
extra_setuptools_args = dict(zip_safe=False)
else:
extra_setuptools_args = dict()
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path)
config.set_options(ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True,
)
config.add_subpackage('bufferkdtree')
return config
class CleanCommand(clean):
description = "Cleaning up code ..."
def run(self):
clean.run(self)
# remove hidden '~' files
for dirpath, dirnames, filenames in os.walk('.'):
for filename in filenames:
if filename.endswith('~'):
os.unlink(os.path.join(dirpath, filename))
# build related files and directories
if os.path.exists('build'):
shutil.rmtree('build')
if os.path.exists('bufferkdtree.egg-info'):
shutil.rmtree('bufferkdtree.egg-info')
if os.path.exists('docs/_build'):
shutil.rmtree('docs/_build')
# remaining files and directories in bufferkdtree dir (recursively)
for dirpath, dirnames, filenames in os.walk('bufferkdtree'):
for filename in filenames:
if (filename.endswith('.so') or \
filename.endswith('.pyd') or \
filename.endswith('.dll') or \
filename.endswith('.pyc') or \
filename.endswith('_wrap.c') or \
filename.startswith('wrapper_') or \
filename.endswith('~')):
os.unlink(os.path.join(dirpath, filename))
for dirname in dirnames:
if dirname == '__pycache__' or dirname == 'build' or dirname == '_build':
shutil.rmtree(os.path.join(dirpath, dirname))
try:
shutil.rmtree("dist")
except:
pass
def setup_package():
import bufferkdtree
VERSION = bufferkdtree.__version__
metadata = dict(name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
download_url=DOWNLOAD_URL,
long_description=LONG_DESCRIPTION,
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
],
cmdclass={'clean': CleanCommand},
setup_requires=["numpy>=1.11.0"],
install_requires=["numpy>=1.11.0"],
include_package_data=True,
package_data={'bufferkdtree': ['src/neighbors/brute/kernels/opencl/*.cl',
'src/neighbors/buffer_kdtree/kernels/*.cl'
]},
**extra_setuptools_args)
if (len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or sys.argv[1] in ('--version', 'clean'))):
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
metadata['version'] = VERSION
setup(**metadata)
else:
# if pip is installed, make sure that numpy
# is installed (pip is not a requirement
# for the bufferkdtree package)
try:
import pip
pip.main(["install", "numpy>=1.11.0"])
except:
pass
try:
from numpy.distutils.core import setup as numpy_setup
metadata['configuration'] = configuration
numpy_setup(**metadata)
except Exception as e:
print("Could not install package: %s" % str(e))
sys.exit(0)
if __name__ == "__main__":
setup_package()