forked from rackerlabs/mimic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
142 lines (126 loc) · 4.44 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
"""
Setup file for mimic
"""
from __future__ import print_function
from setuptools import setup, find_packages
try:
from py2app.build_app import py2app
py2app_available = True
except ImportError:
py2app_available = False
_NAME = "mimic"
_VERSION = "2.1.0"
def setup_options(name, version):
"""
If `py2app` is present in path, then enable to option to build the app.
This also disables the options needed for normal `sdist` installs.
:returns: a dictionary of setup options.
"""
info = dict(
install_requires=[
"klein>=15.3.1",
"twisted>=15.5.0",
"treq>=15.1.0",
"six>=1.6.0",
"xmltodict>=0.9.1",
"attrs>=15.1.0",
"testtools>=1.7.1,<1.8.0",
"iso8601>=0.1.10",
],
package_dir={"mimic": "mimic"},
packages=find_packages(exclude=[]) + ["twisted.plugins"],
)
if not py2app_available:
return info
# py2app available, proceed.
script="bundle/start-app.py"
test_script="bundle/run-tests.py"
plist = dict(
CFBundleName = _NAME,
CFBundleShortVersionString = " ".join([_NAME, _VERSION]),
CFBundleGetInfoString = _NAME,
CFBundleExecutable = _NAME,
CFBundleIdentifier = "com.%s.%s" % (_NAME, _VERSION),
LSUIElement = "1",
LSMultipleInstancesProhibited = "1",
)
app_data = dict(
script=script,
plist=plist,
extra_scripts=[test_script]
)
class BuildWithCache(py2app, object):
"""
Before building the application rebuild the `dropin.cache` files.
"""
def collect_recipedict(self):
"""
Implement a special Twisted plugins recipe so that dropin.cache
files are generated and included in site-packages.zip.
"""
result = super(BuildWithCache, self).collect_recipedict()
def check(cmd, mg):
from twisted.plugin import getPlugins, IPlugin
from twisted import plugins as twisted_plugins
from mimic import plugins as mimic_plugins
for plugin_package in [twisted_plugins, mimic_plugins]:
import time
list(getPlugins(IPlugin, package=plugin_package))
import os
def plugpath(what):
path_in_zip = what + "/plugins"
path_on_fs = (
os.path.abspath(
os.path.join(
os.path.dirname(
__import__(what + ".plugins",
fromlist=["nonempty"])
.__file__),
"dropin.cache")
))
os.utime(path_on_fs, (time.time() + 86400,) * 2)
return (path_in_zip, [path_on_fs])
data_files = [plugpath("mimic"), plugpath("twisted")]
return dict(loader_files=data_files)
result["bonus"] = check
return result
return dict(
info,
app=[app_data],
cmdclass={
"py2app": BuildWithCache
},
options={
"py2app": {
"includes": [
"syslog",
"mimic.test.*",
"mimic.plugins.*",
"twisted.plugins.*",
"twisted.plugin",
],
}
}
)
setup(
classifiers=[
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules'
],
name=_NAME,
version=_VERSION,
description="An API-compatible mock service",
license="Apache License, Version 2.0",
url="https://github.com/rackerlabs/mimic",
include_package_data=True,
**setup_options(_NAME, _VERSION)
)