forked from dbuscombe-usgs/pysesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·217 lines (195 loc) · 8.74 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## PySESA (Python program for Spatially Explicit Spectral Analysis)
## has been developed at the Grand Canyon Monitorinf & Research Center,
## U.S. Geological Survey
##
## Author: Daniel Buscombe
## Project homepage: <https://github.com/dbuscombe-usgs/pysesa>
##
##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/>.
"""
PySESA - a Python framework for Spatially Explicit Spectral Analysis
PySESA is an open-source project dedicated to provide a generic Python framework
for spatially explicit statistical analyses of point clouds and other geospatial data,
in the spatial and frequency domains, for use in the geosciences
The program is detailed in:
Buscombe, D. (2016) "Computational considerations for spatially explicit spectral analysis of point clouds and geospatial data", 86, 92-108, 10.1016/j.cageo.2015.10.004.
:Author:
Daniel Buscombe
Grand Canyon Monitoring and Research Center
United States Geological Survey
Flagstaff, AZ 86001
For more information visit http://dbuscombe-usgs.github.io/pysesa/
:install:
pip install pysesa
python setup.py install
sudo python setup.py install
:test:
python -c "import pysesa; pysesa.test()"
: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 PySESA.")
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
from Cython.Build import cythonize
except:
msg = ("No module named Cython. "
"Please install Cython first, it is needed before installing pysesa.")
raise ImportError(msg)
# Read version from distmesh/__init__.py
with open(os.path.join('pysesa', '__init__.py')) as f:
line = f.readline()
while not line.startswith('__version__'):
line = f.readline()
exec(line, globals())
ext_modules = [ ]
cmdclass = { }
#ext_modules += cythonize(Extension('_loadtxt',sources=['pysesa/loadtxt.pyx', 'pysesa/loadtxt.cpp'], language="c++"))
if USE_CYTHON:
ext_modules += [
Extension("pysesa.plot", [ "pysesa/plot.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.read", [ "pysesa/read.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.write", [ "pysesa/_write.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.detrend", [ "pysesa/detrend.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.lengthscale", [ "pysesa/lengthscale.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.partition", [ "pysesa/partition.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.spectral", [ "pysesa/spectral.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.spatial", [ "pysesa/_spatial.pyx" ],
include_dirs=[np.get_include()]),
Extension("pysesa.sgolay", [ "pysesa/_sgolay.pyx" ],
include_dirs=[np.get_include()]),
Extension('_RunningStats',sources=['pysesa/RunningStats_wrap.cxx', 'pysesa/RunningStats.cpp']),
]
cmdclass.update({ 'build_ext': build_ext })
else:
ext_modules += [
Extension("pysesa.plot", [ "pysesa/plot.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.read", [ "pysesa/read.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.write", [ "pysesa/_write.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.detrend", [ "pysesa/detrend.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.lengthscale", [ "pysesa/lengthscale.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.partition", [ "pysesa/partition.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.spectral", [ "pysesa/spectral.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.spatial", [ "pysesa/_spatial.c" ],
include_dirs=[np.get_include()]),
Extension("pysesa.sgolay", [ "pysesa/_sgolay.c" ],
include_dirs=[np.get_include()]),
Extension('_RunningStats',sources=['pysesa/RunningStats_wrap.cxx', 'pysesa/RunningStats.cpp']),
]
install_requires = [
'numpy','scipy','matplotlib', 'cython', 'statsmodels', 'ift_nifty', 'joblib','dask', 'toolz', 'dill', 'laspy'
]
def setupPackage():
setup(name='pysesa',
version=__version__,
description='PySESA is an open-source project dedicated to provide a generic Python framework for spatially explicit statistical analyses of point clouds and other geospatial data, in the spatial and frequency domains, for use in the geosciences. The program is detailed in Buscombe, D. (2016) "Computational considerations for spatially explicit spectral analysis of point clouds and geospatial data", 86, 92-108, 10.1016/j.cageo.2015.10.004.',
#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',
],
keywords='point clouds',
author='Daniel Buscombe',
author_email='[email protected]',
url='https://github.com/dbuscombe-usgs/pysesa',
download_url ='https://github.com/dbuscombe-usgs/pysesa/archive/master.zip',
install_requires=install_requires,
license = "GNU GENERAL PUBLIC LICENSE v3",
packages=['pysesa'],
cmdclass = cmdclass,
ext_modules=ext_modules,
platforms='OS Independent',
package_data={'pysesa': ['*.xyz','*.h']}
)
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, 'pysesa')
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()