forked from couchapp/couchapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·145 lines (122 loc) · 4.38 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2009 Benoit Chesneau <benoitc@e-engura.org>
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.
import os
import sys
from ez_setup import use_setuptools
if 'cygwin' in sys.platform.lower():
min_version='0.6c6'
else:
min_version='0.6a9'
try:
use_setuptools(min_version=min_version)
except TypeError:
# If a non-local ez_setup is already imported, it won't be able to
# use the min_version kwarg and will bail with TypeError
use_setuptools()
from setuptools import setup, find_packages, Extension, Feature
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
data_files = []
for dir, dirs, files in os.walk('app-template'):
data_files.append((os.path.join('couchapp', dir),
[os.path.join(dir, file_) for file_ in files]))
for dir, dirs, files in os.walk('vendor'):
data_files.append((os.path.join('couchapp', dir),
[os.path.join(dir, file_) for file_ in files]))
for dir, dirs, files in os.walk('src/couchapp'):
for i, dirname in enumerate(dirs):
if dirname.startswith('.'): del dirs[i]
data_files.append((dir, [os.path.join(dir, file_) for file_ in files]))
speedups = Feature(
"options C speed-enhancement modules",
standard=True,
ext_modules = [
Extension("couchapp/contrib/simplejson._speedups", ["src/couchapp/contrib/simplejson/_speedups.c"]),
],
)
if sys.platform == 'win32' and sys.version_info > (2, 6):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
IOError)
else:
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
class BuildFailed(Exception):
pass
class ve_build_ext(build_ext):
# This class allows C extension building to fail.
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError, x:
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors, x:
raise BuildFailed()
def run_setup(with_binary):
if with_binary:
features = {'speedups': speedups}
else:
features = {}
setup(
name = 'Couchapp',
version = '0.3.2',
url = 'http://github.com/couchapp/couchapp/tree/master',
license = 'Apache License 2',
author = 'Benoit Chesneau',
author_email = 'benoitc@e-engura.org',
description = 'Standalone CouchDB Application Development Made Simple.',
long_description = """CouchApp is a set of helpers and a jQuery plugin
that conspire to get you up and running on CouchDB quickly and
correctly. It brings clarity and order to the freedom of CouchDB's
document-based approach.""",
keywords = 'couchdb couchapp',
platforms = ['any'],
zip_safe = False,
packages=find_packages('src'),
package_dir={
'': 'src'
},
data_files = data_files,
include_package_data = True,
entry_points = {
'console_scripts': [
'couchapp = couchapp.bin.couchapp_cli:main',
]
},
classifiers = [
'License :: OSI Approved :: Apache Software License',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Operating System :: OS Independent',
'Topic :: Database',
'Topic :: Utilities',
],
features=features,
cmdclass={'build_ext': ve_build_ext},
test_suite='tests',
)
try:
run_setup(True)
except BuildFailed:
BUILD_EXT_WARNING = "WARNING: The C extension could not be compiled, speedups are not enabled."
print '*' * 75
print BUILD_EXT_WARNING
print "Failure information, if any, is above."
print "I'm retrying the build without the C extension now."
print '*' * 75
run_setup(False)
print '*' * 75
print BUILD_EXT_WARNING
print "Plain-Python installation succeeded."
print '*' * 75