forked from jjguy/heatmap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
83 lines (75 loc) · 2.94 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
import os
import glob
#here use a flag so don't automatically use setuptools if available, hard to test otherwise
with_setuptools = False
if 'USE_SETUPTOOLS' in os.environ or 'pip' in __file__ or 'easy_install' in __file__:
try:
from setuptools.command.install import install
from setuptools import setup
from setuptools import Extension
from setuptools.command.build_ext import build_ext
with_setuptools = True
except ImportError:
pass
if not with_setuptools:
from distutils.command.install import install
from distutils.core import setup
from distutils.core import Extension
from distutils.command.build_ext import build_ext
# sorry for this, welcome feedback on the "right" way.
# shipping pre-compiled bainries on windows, have
# to hack things up here.
class mybuild(build_ext):
def run(self):
if "nt" in os.name:
print("On Windows, skipping build_ext.")
return
build_ext.run(self)
class post_install(install):
def run(self):
install.run(self)
# on windows boxes, manually copy pre-compiled DLLs to
# site-packages (or wherever the module is being installed)
if "nt" in os.name:
basedir = os.path.dirname(__file__)
for f in glob.glob(os.path.join(basedir, "*.dll")):
src = os.path.join(basedir, f)
dst = os.path.join(self.install_lib, f)
open(dst, "wb").write(open(src, "rb").read())
cHeatmap = Extension('cHeatmap', sources=['heatmap/heatmap.c', ])
#separate calls to remove errors
basekw = {
'name' : 'heatmap',
'version' : "2.2.1",
'description' : 'Module to create heatmaps',
'author' : 'Jeffrey J. Guy',
'author_email' : '[email protected]',
'url' : 'http://jjguy.com/heatmap/',
'packages' : ['heatmap', ],
'py_modules' : ['heatmap.colorschemes', ],
'ext_modules' : [cHeatmap, ],
'cmdclass' : {'install': post_install,
'build_ext': mybuild},
'classifiers' : [
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
'License :: OSI Approved :: MIT License',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Scientific/Engineering :: GIS'
]
}
setuptoolskw = {
'install_requires' : ['Pillow'],
'extras_require' : {'proj' : 'pyproj'},
'test_suite' : "test",
'tests_require' : ['pyproj']
}
distutilskw = {
'requires' : ["Pillow"]
}
basekw.update(setuptoolskw) if with_setuptools else basekw.update(distutilskw)
setup(**basekw)