-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
100 lines (84 loc) · 2.77 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
import os
import shutil
from codecs import open as codecs_open
import numpy as np
from setuptools import setup, find_packages
from distutils.core import Distribution, Extension
from distutils.command.build_ext import build_ext
from distutils import errors
from Cython.Build import cythonize
from Cython.Compiler.Errors import CompileError
def check_for_openmp():
"""
There does not seem to be a cross platform and standard way to check for
OpenMP support. Attempt to compile a test script. Proceed with OpenMP
implementation if it works.
"""
distribution = Distribution()
ext_options = {
'extra_compile_args': ['-fopenmp'],
'extra_link_args': ['-fopenmp']
}
extensions = [
Extension('geoblend.openmp_check', ['geoblend/openmp_check.pyx'], **ext_options)
]
build_extension = build_ext(distribution)
build_extension.finalize_options()
build_extension.extensions = cythonize(extensions, force=True)
build_extension.run()
ext_options = {
'include_dirs': [ np.get_include() ]
}
extensions = [
Extension('geoblend.vector', ['geoblend/vector.pyx'], **ext_options),
Extension('geoblend.convolve', ['geoblend/convolve.pyx'], **ext_options)
]
pkg_dir = os.path.dirname(os.path.realpath(__file__))
dst = os.path.join(pkg_dir, 'geoblend', 'coefficients.pyx')
try:
check_for_openmp()
ext_options['extra_compile_args'] = ['-fopenmp']
ext_options['extra_link_args'] = ['-fopenmp']
src = os.path.join(pkg_dir, 'geoblend', '_coefficients_omp.pyx')
except (errors.LinkError, errors.CompileError, CompileError):
src = os.path.join(pkg_dir, 'geoblend', '_coefficients.pyx')
shutil.copy(src, dst)
extensions.append(
Extension('geoblend.coefficients', ['geoblend/coefficients.pyx'], **ext_options),
)
# Get the long description from the relevant file
with codecs_open('README.rst', encoding='utf-8') as f:
long_description = f.read()
setup(name='geoblend',
version='0.2.3',
description=u"Geo-aware poisson blending.",
long_description=long_description,
classifiers=[],
keywords='',
author=u"Amit Kapadia",
author_email='[email protected]',
url='https://github.com/kapadia/geoblend',
license='MIT',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
ext_modules=cythonize(extensions),
zip_safe=False,
install_requires=[
'click',
# 'rasterio',
'pyamg',
'scipy',
'scikit-image'
],
extras_require={
'test': ['pytest'],
'development': [
'cython>=0.23.0',
'benchmark'
]
},
entry_points="""
[console_scripts]
geoblend=geoblend.scripts.cli:geoblend
"""
)