forked from BenthicSubstrateMapping/PyHum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·234 lines (211 loc) · 8.91 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## PyHum (Python program for Humminbird(R) data processing)
## has been developed at the Grand Canyon Monitoring & Research Center,
## U.S. Geological Survey
##
## Author: Daniel Buscombe
## Project homepage: <https://github.com/dbuscombe-usgs/PyHum>
##
##This software is in the public domain because it contains materials that originally came from
##the United States Geological Survey, an agency of the United States Department of Interior.
##For more information, see the official USGS copyright policy at
##http://www.usgs.gov/visual-id/credit_usgs.html#copyright
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
#"""
# ____ _ _
#| _ \ _ _| | | |_ _ _ __ ___ _ _
#| |_) | | | | |_| | | | | '_ ` _ \ (_) (_)
#| __/| |_| | _ | |_| | | | | | | _ _
#|_| \__, |_| |_|\__,_|_| |_| |_| (_) (_)
# |___/
#
##+-+-+ +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
#|b|y| |D|a|n|i|e|l| |B|u|s|c|o|m|b|e|
#+-+-+ +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#|d|a|n|i|e|l|.|b|u|s|c|o|m|b|e|@|n|a|u|.|e|d|u|
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#"""
"""
PyHum - a Python framework for sidescan data texture classification.
PyHum is an open-source project dedicated to provide a Python framework for
processing low-cost sidescan data. It provides parsers for Humminbird file formats,
and signal processing routines which allow the manipulation of sidescan data and automated texture classification
For more information visit http://dbuscombe-usgs.github.io/PyHum/
:install:
python setup.py install
sudo python setup.py install
:test:
python -c "import PyHum; PyHum.test.dotest()"
:license:
GNU Lesser General Public License, Version 3
(http://www.gnu.org/copyleft/lesser.html)
This software is in the public domain because it contains materials that
originally came from the United States Geological Survey, an agency of the
United States Department of Interior. For more information,
see the official USGS copyright policy at
http://www.usgs.gov/visual-id/credit_usgs.html#copyright
Any use of trade, product, or firm names is for descriptive purposes only
and does not imply endorsement by the U.S. government.
"""
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os, sys, glob
import inspect
try:
import numpy as np
except:
msg = ("No module named numpy. "
"Please install numpy first, it is needed before installing PyHum.")
raise ImportError(msg)
from distutils.core import setup
from distutils.extension import Extension
#from setuptools import setup, Extension
# Directory of the current file
SETUP_DIRECTORY = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe())))
# Set this to True to enable building extensions using Cython.
# Set it to False to build extensions from the C file (that
# was previously created using Cython).
# Set it to 'auto' to build with Cython if available, otherwise
# from the C file.
USE_CYTHON = True
if USE_CYTHON:
try:
from Cython.Distutils import build_ext
except:
msg = ("No module named Cython. "
"Please install Cython first, it is needed before installing PyHum.")
raise ImportError(msg)
#if USE_CYTHON:
# try:
# from Cython.Distutils import build_ext
# except ImportError:
# if USE_CYTHON=='auto':
# USE_CYTHON=False
# else:
# raise
# Read version from distmesh/__init__.py
with open(os.path.join('PyHum', '__init__.py')) as f:
line = f.readline()
while not line.startswith('__version__'):
line = f.readline()
exec(line, globals())
ext_modules = [ ]
cmdclass = { }
if USE_CYTHON:
ext_modules += [
Extension("PyHum.cwt", [ "PyHum/cwt.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.pyread", [ "PyHum/pyread.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.pyread_single", [ "PyHum/pyread_single.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.ppdrc", [ "PyHum/ppdrc.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.replace_nans", [ "PyHum/replace_nans.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.spec_noise", [ "PyHum/spec_noise.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.stdev", [ "PyHum/stdev.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.write", [ "PyHum/write.pyx" ],
include_dirs=[np.get_include()]),
Extension("PyHum.getxy", [ "PyHum/getxy.pyx" ],
include_dirs=[np.get_include()]),
Extension('_RunningStats',sources=['PyHum/RunningStats_wrap.cxx', 'PyHum/RunningStats.cpp']),
]
cmdclass.update({ 'build_ext': build_ext })
else:
ext_modules += [
Extension("PyHum.cwt", [ "PyHum/cwt.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.pyread", [ "PyHum/pyread.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.pyread_single", [ "PyHum/pyread_single.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.ppdrc", [ "PyHum/ppdrc.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.replace_nans", [ "PyHum/replace_nans.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.spec_noise", [ "PyHum/spec_noise.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.stdev", [ "PyHum/stdev.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.write", [ "PyHum/write.c" ],
include_dirs=[np.get_include()]),
Extension("PyHum.getxy", [ "PyHum/getxy.c" ],
include_dirs=[np.get_include()]),
Extension('_RunningStats',sources=['PyHum/RunningStats_wrap.cxx', 'PyHum/RunningStats.cpp']),
]
install_requires = [
'numpy','scipy','Pillow','matplotlib', 'cython', 'pyproj', 'scikit-image', 'simplekml', 'joblib', 'basemap', 'scikit-learn', 'pyresample==1.1.4', 'dask', 'toolz', 'pandas'
]
#==0.16.0
#==0.7.1
#long_description = open('README.md').read()
def setupPackage():
setup(name='PyHum',
version=__version__,
description='Buscombe, D., 2017, Shallow water benthic imaging and substrate characterization using recreational-grade sidescan-sonar. ENVIRONMENTAL MODELLING & SOFTWARE 89, 1-18.',
#long_description=long_description,
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics',
],
keywords='sidescan sonar humminbird sediment substrate classification',
author='Daniel Buscombe',
author_email='daniel.buscombe@nau.edu',
url='https://github.com/dbuscombe-usgs/PyHum',
download_url ='https://github.com/dbuscombe-usgs/PyHum/archive/master.zip',
install_requires=install_requires,
license = "GNU GENERAL PUBLIC LICENSE v3",
packages=['PyHum'],
cmdclass = cmdclass,
ext_modules=ext_modules,
platforms='OS Independent',
package_data={'PyHum': ['*.SON', '*.DAT','*.h', '*.IDX', '*.txt', '*.png']}
)
if __name__ == '__main__':
# clean --all does not remove extensions automatically
if 'clean' in sys.argv and '--all' in sys.argv:
import shutil
# delete complete build directory
path = os.path.join(SETUP_DIRECTORY, 'build')
try:
shutil.rmtree(path)
except:
pass
# delete all shared libs from lib directory
path = os.path.join(SETUP_DIRECTORY, 'PyHum')
for filename in glob.glob(path + os.sep + '*.pyd'):
try:
os.remove(filename)
except:
pass
for filename in glob.glob(path + os.sep + '*.so'):
try:
os.remove(filename)
except:
pass
setupPackage()