-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
112 lines (100 loc) · 3.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
#!/usr/bin/env python
"""
setup.py file for SWIG-ified wndchrm
"""
from setuptools import setup, Extension
import os
pkg_dir = os.path.join (os.path.dirname(os.path.realpath(__file__)),'pychrm')
# this sets the __version__ variable
# the pychrm/_version.py file contains a single line assigning the __version__ variable
# This file gets imported by __init__.py to set __version__ during package import
# Here we do NOT want to import the package we are building to set this variable!
# We DO want to set the version in setup() and have it all synchronized from a single place (pychrm/_version.py)
execfile(os.path.join (pkg_dir,'_version.py'))
# If we're building from svn, get the svn revision using the svnversion command
# The svn revision (if it exists) gets appended to the version string (e.g. 0.3-r123 or 0.2-r141-local)
# This mechanism allows for detection of locally modified (uncommitted) svn versions, and does not
# require any action other than normal svn updates/commits to register new version numbers
# The svn version is written to pychrm/_svn_version.py (which is not under svn control) for inclusion by __init__.py
# If we're not building from svn, then _svn_version.py is not written, and __version__ will be as in pychrm/_version.py
try:
import subprocess
import re
svn_vers = subprocess.Popen(['svnversion', pkg_dir], stdout=subprocess.PIPE).communicate()[0].strip()
rev_re = re.search(r'^(\d+)(.+)?$', svn_vers)
if rev_re:
if rev_re.group(2):
svn_vers = 'r'+rev_re.group(1)+'-local'
else:
svn_vers = 'r'+rev_re.group(1)
print "svn revision "+svn_vers
# this construction matches what is done in __init__.py by importing both _version.py and _svn_version.py
__version__ = __version__+'-'+svn_vers
f = open(os.path.join(pkg_dir,'_svn_version.py'), 'w+')
f.write ("__svn_version__ = '"+svn_vers+"'\n")
f.close()
except:
pass
# Third-party modules - we depend on numpy for everything
import numpy
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
print "numpy_include "+numpy_include
wndchrm_module = Extension('_pychrm',
sources=[
'pychrm/swig/pychrm.i',
'src/colors/FuzzyCalc.cpp',
'src/statistics/CombFirst4Moments.cpp',
'src/statistics/FeatureStatistics.cpp',
'src/textures/gabor.cpp',
'src/textures/haralick/CVIPtexture.cpp',
'src/textures/haralick/haralick.cpp',
'src/textures/tamura.cpp',
'src/textures/zernike/complex.cpp',
'src/textures/zernike/zernike.cpp',
'src/transforms/ChebyshevFourier.cpp',
'src/transforms/chebyshev.cpp',
'src/transforms/radon.cpp',
'src/transforms/wavelet/Common.cpp',
'src/transforms/wavelet/convolution.cpp',
'src/transforms/wavelet/DataGrid2D.cpp',
'src/transforms/wavelet/DataGrid3D.cpp',
'src/transforms/wavelet/Filter.cpp',
'src/transforms/wavelet/FilterSet.cpp',
'src/transforms/wavelet/Symlet5.cpp',
'src/transforms/wavelet/Wavelet.cpp',
'src/transforms/wavelet/WaveletHigh.cpp',
'src/transforms/wavelet/WaveletLow.cpp',
'src/transforms/wavelet/WaveletMedium.cpp',
'src/transforms/wavelet/wt.cpp',
'src/cmatrix.cpp',
'src/wndchrm_error.cpp',
'src/ImageTransforms.cpp',
'src/FeatureAlgorithms.cpp',
'src/Tasks.cpp',
'src/FeatureNames.cpp',
'src/gsl/specfunc.cpp',
],
include_dirs=['./','src/',numpy_include],
# swig_opts=['-modern', '-c++', '-I./', '-I./src', '-outdir', 'pychrm'],
swig_opts=['-c++', '-I./', '-I./src', '-outdir', 'pychrm'],
libraries=['tiff','fftw3'],
)
setup (name = 'pychrm',
version = __version__,
author = "Chris Coletta, Ilya Goldberg",
url = 'http://code.google.com/p/wnd-charm',
description = """Python bindings for wnd-charm""",
ext_modules = [wndchrm_module],
packages = ['pychrm'],
install_requires=[
'numpy',
'stringformat >= 0.4',
'argparse',
],
dependency_links = [
"https://github.com/igg/stringformat/tarball/0.4egg=stringformat-0.4"
],
)