forked from enthought/enable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
161 lines (134 loc) · 5.15 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
# Copyright (c) 2008-2013 by Enthought, Inc.
# All rights reserved.
# These are necessary to get the clib compiled. The following also adds
# an additional option --compiler=STR to develop, which usually does not
# have such an option. The code below is a bad hack, as it changes
# sys.argv to fool setuptools which therefore has to be imported BELOW
# this hack.
import sys
if 'develop' in sys.argv:
idx = sys.argv.index('develop')
compiler = []
for arg in sys.argv[idx+1:]:
if arg.startswith('--compiler='):
compiler = ['-c', arg[11:]]
del sys.argv[idx+1:]
# insert extra options right before 'develop'
sys.argv[idx:idx] = ['build_src', '--inplace', 'build_clib'] + compiler + \
['build_ext', '--inplace'] + compiler
from os.path import join
# Setuptools must be imported BEFORE numpy.distutils for things to work right!
import setuptools
import distutils
import os
import shutil
from numpy.distutils.core import setup
info = {}
execfile(join('enable', '__init__.py'), info)
# Configure python extensions.
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path)
config.set_options(
ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True,
)
config.add_subpackage('kiva')
return config
# Build the full set of packages by appending any found by setuptools'
# find_packages to those discovered by numpy.distutils.
config = configuration().todict()
packages = setuptools.find_packages(exclude=config['packages'] +
['docs', 'examples'])
packages += ['enable.savage.trait_defs.ui.wx.data']
config['packages'] += packages
class MyClean(distutils.command.clean.clean):
'''
Subclass to remove any files created in an inplace build.
This subclasses distutils' clean because neither setuptools nor
numpy.distutils implements a clean command.
'''
def run(self):
distutils.command.clean.clean.run(self)
# Clean any build or dist directory
if os.path.isdir("build"):
shutil.rmtree("build", ignore_errors=True)
if os.path.isdir("dist"):
shutil.rmtree("dist", ignore_errors=True)
# Clean out any files produced by an in-place build. Note that our
# code assumes the files are relative to the 'kiva' dir.
INPLACE_FILES = (
# Common AGG
join("agg", "agg.py"),
join("agg", "plat_support.py"),
join("agg", "agg_wrap.cpp"),
# Mac
join("quartz", "ABCGI.so"),
join("quartz", "ABCGI.c"),
join("quartz", "macport.so"),
join("quartz", "mac_context.so"),
join("quartz", "CTFont.so"),
join("quartz", "CTFont.c"),
# Win32 Agg
join("agg", "_agg.pyd"),
join("agg", "_plat_support.pyd"),
join("agg", "src", "win32", "plat_support.pyd"),
# *nix Agg
join("agg", "_agg.so"),
join("agg", "_plat_support.so"),
join("agg", "src", "x11", "plat_support_wrap.cpp"),
# Misc
join("agg", "src", "gl", "plat_support_wrap.cpp"),
join("agg", "src", "gl", "plat_support.py"),
)
for f in INPLACE_FILES:
f = join("kiva", f)
if os.path.isfile(f):
os.remove(f)
setup(
name = 'enable',
version = info['__version__'],
author = 'Enthought, Inc',
author_email = '[email protected]',
maintainer = 'ETS Developers',
maintainer_email = '[email protected]',
url = 'http://code.enthought.com/projects/enable',
classifiers = [c.strip() for c in """\
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Operating System :: MacOS
Operating System :: Microsoft :: Windows
Operating System :: OS Independent
Operating System :: POSIX
Operating System :: Unix
Programming Language :: C
Programming Language :: Python
Topic :: Scientific/Engineering
Topic :: Software Development
Topic :: Software Development :: Libraries
""".splitlines() if len(c.strip()) > 0],
cmdclass = {
# Work around a numpy distutils bug by forcing the use of the
# setuptools' sdist command.
'sdist': setuptools.command.sdist.sdist,
# Use our customized commands
'clean': MyClean,
},
description = 'low-level drawing and interaction',
long_description = open('README.rst').read(),
download_url = ('http://www.enthought.com/repo/ets/enable-%s.tar.gz' %
info['__version__']),
install_requires = info['__requires__'],
license = 'BSD',
package_data = {'': ['*.zip', '*.svg', 'images/*']},
platforms = ["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"],
setup_requires = [
'cython',
],
zip_safe = False,
**config
)