-
Notifications
You must be signed in to change notification settings - Fork 16
/
setup.py
170 lines (132 loc) · 4.84 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
163
164
165
166
167
168
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function
import os
import sys
from fnmatch import fnmatchcase
from distutils.core import Command, setup
from distutils.util import convert_path
import glob
import subprocess
import shutil
#------------------------------------------------------------------------
# Top Level Packages
#------------------------------------------------------------------------
def find_packages(where='.', exclude=()):
out = []
stack = [(convert_path(where), '')]
while stack:
where, prefix = stack.pop(0)
for name in os.listdir(where):
fn = os.path.join(where,name)
if ('.' not in name and os.path.isdir(fn) and
os.path.isfile(os.path.join(fn, '__init__.py'))
):
out.append(prefix+name)
stack.append((fn, prefix+name+'.'))
if sys.version_info[0] == 3:
exclude = exclude + ('*py2only*', )
for pat in list(exclude) + ['ez_setup', 'distribute_setup']:
out = [item for item in out if not fnmatchcase(item, pat)]
return out
packages = find_packages()
if sys.platform == 'win32':
dir_sep = '\\'
else:
dir_sep = '/'
def get_data_files():
data_files = []
root = os.path.join("nutchpy","ex_data")
##scan catalog for files with the above extensions and add to pkg_data_dirs
for path, dirs, files in os.walk(root):
for fs in files:
#remove nutchpy from path name
install_path = dir_sep.join(path.split(dir_sep)[1:])
data_files.append(os.path.join(install_path,fs))
return data_files
package_data = dict(nutchpy=get_data_files())
#------------------------------------------------------------------------
# Commands
#------------------------------------------------------------------------
class CleanCommand(Command):
"""Custom distutils command to clean the .so and .pyc files."""
user_options = []
def initialize_options(self):
self._clean_me = []
self._clean_trees = []
for toplevel in packages:
for root, dirs, files in list(os.walk(toplevel)):
for f in files:
if os.path.splitext(f)[-1] in ('.pyc', '.so', '.o', '.pyd', '.jar'):
self._clean_me.append(os.path.join(root, f))
for d in ('build',):
if os.path.exists(d):
self._clean_trees.append(d)
def finalize_options(self):
pass
def run(self):
for clean_me in self._clean_me:
try:
print('flushing', clean_me)
os.unlink(clean_me)
except Exception:
pass
for clean_tree in self._clean_trees:
try:
print('flushing', clean_tree)
shutil.rmtree(clean_tree)
except Exception:
pass
#------------------------------------------------------------------------
# Setup
#------------------------------------------------------------------------
longdesc = open('README.md').read()
#------------------------------------------------------------------------
# Optional building with MAVEN
#------------------------------------------------------------------------
if not 'nojava' in sys.argv:
JAVA_SRC = "seqreader-app"
os.chdir(JAVA_SRC)
build_cmd = "mvn package"
os.system(build_cmd)
# subprocess.check_call(build_cmd, shell=os.name != 'nt',
# stdout=subprocess.PIPE, stderr=subprocess.PIPE)
os.chdir("..")
jar_file = os.path.join(JAVA_SRC,"target",
"seqreader-app-1.0-SNAPSHOT-jar-with-dependencies.jar")
java_lib_dir = os.path.join("nutchpy","java_libs")
if not os.path.exists(java_lib_dir):
os.mkdir(java_lib_dir)
shutil.copy(jar_file,java_lib_dir)
else:
assert 'nojava' == sys.argv.pop(2)
jar_file_list = glob.glob("nutchpy/java_libs/*")
jar_file_list = [os.path.relpath(path,start='nutchpy') for path in jar_file_list]
package_data['nutchpy'] = package_data['nutchpy']+jar_file_list
setup(
name='nutchpy',
version='0.1',
author='Continuum Analytics',
author_email='[email protected]',
description='nutchpy',
long_description=longdesc,
license='BSD',
platforms = ['any'],
install_requires=['py4j>=0.8.2.1'],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Big Data',
'Topic :: Java',
],
packages=packages,
package_data=package_data,
cmdclass = {
'clean': CleanCommand,
}
)