-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
135 lines (108 loc) · 4.53 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
#
# Copyright (C) 2015-2018 Fabian Gieseke <fabian.gieseke@di.ku.dk>
# License: GPL v3
#
import os
import sys
import shutil
from distutils.command.clean import clean
DISTNAME = 'woody'
DESCRIPTION = 'A Python library for large-scale random forests.'
LONG_DESCRIPTION = open('README.rst').read()
MAINTAINER = 'Fabian Gieseke'
MAINTAINER_EMAIL = 'fabian.gieseke@di.ku.dk'
URL = 'https://github.com/gieseke/woody'
LICENSE = 'GNU GENERAL PUBLIC LICENSE Version 3'
DOWNLOAD_URL = 'https://github.com/gieseke/woody'
import woody
VERSION = woody.__version__
# 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('woody')
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('~') or filename.endswith('.pyc'):
os.unlink(os.path.join(dirpath, filename))
# build related files and directories
if os.path.exists('build'):
shutil.rmtree('build')
if os.path.exists('woody.egg-info'):
shutil.rmtree('woody.egg-info')
if os.path.exists('docs/_build'):
shutil.rmtree('docs/_build')
# remaining files and directories in woody dir (recursively)
for dirpath, dirnames, filenames in os.walk('woody'):
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():
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},
install_requires=["numpy>=1.6.1"],
include_package_data=True,
package_data={'woody': []},
**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
else:
try:
from numpy.distutils.core import setup
metadata['configuration'] = configuration
except:
print("woody requires numpy>=1.6.1")
sys.exit(0)
setup(**metadata)
if __name__ == "__main__":
setup_package()