This repository has been archived by the owner on Mar 1, 2021. It is now read-only.
forked from hydralabs/pyamf
-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
165 lines (137 loc) · 4.39 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
162
163
164
165
#!/usr/bin/env python
# Copyright (c) The PyAMF Project.
# See LICENSE.txt for details.
import os.path
from setuptools import Feature, setup
import sys
try:
from Cython.Build import cythonize
have_cython = True
except:
have_cython = False
name = "Mini-AMF"
description = "AMF serialization and deserialization support for Python"
url = "https://github.com/zackw/mini-amf"
author = "Zack Weinberg, The PyAMF Project"
author_email = "[email protected]"
license = "MIT License"
classifiers = """
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: C
Programming Language :: Python
Programming Language :: Cython
Programming Language :: Python :: 2.7
Topic :: Internet :: WWW/HTTP :: WSGI :: Application
Topic :: Software Development :: Libraries :: Python Modules
Development Status :: 5 - Production/Stable
"""
keywords = """
amf amf0 amf3 actionscript air flash flashplayer bytearray recordset
decoder encoder sharedobject lso sol
"""
class AccelFeature(Feature):
def __init__(self, have_cython):
self.have_cython = have_cython
self.extensions = []
Feature.__init__(
self,
description="optional C accelerator modules (broken)",
standard=False,
available=have_cython,
ext_modules=self.extensions
)
def include_in(self, dist):
if not self.have_cython:
sys.stderr.write(
"ERROR: Cython is required to compile accelerator modules.\n")
sys.exit(1)
sys.stderr.write(
"WARNING: Accelerator modules are broken.\n"
"WARNING: You should only use --with-accel "
"if you are trying to fix them.\n")
self.extensions.extend(cythonize("miniamf/_accel/*.pyx"))
Feature.include_in(self, dist)
def get_version():
"""
Retrieve the version number from miniamf/_version.py. It is
necessary to do this by hand, because the package may not yet be
importable (critical dependencies, like "six", may be missing).
This duplicates the tuple-to-string logic in miniamf/versions.py,
but without any dependence on "six".
"""
from ast import literal_eval
import re
try:
unicode
except NameError:
unicode = str
try:
int_types = (int, long)
except NameError:
int_types = (int,)
with open(os.path.join(os.path.dirname(__file__),
"miniamf/_version.py"), "rt") as f:
vdat = f.read()
m = re.search(
r"(?ms)^\s*version\s*=\s*Version\(\*(\([^)]+\))\)",
vdat)
if not m:
raise RuntimeError("failed to extract version tuple")
vtuple = literal_eval(m.group(1))
if not vtuple:
raise RuntimeError("version tuple appears to be empty")
v = []
first = True
for x in vtuple:
if not first and isinstance(x, int_types):
v.append(u'.')
if isinstance(x, unicode):
v.append(x)
elif isinstance(x, bytes):
v.append(x.decode("utf-8"))
else:
v.append(unicode(x))
first = False
return u''.join(v)
# Note: this logic is duplicated in doc/conf.py.
# We only want the flair on the Github page.
def get_long_description():
with open(os.path.join(os.path.dirname(__file__),
"README.rst"), "rt") as f:
text = f.read()
cut = text.find("\nAutomatic build statuses\n")
if cut != -1:
return text[:cut]
def setup_package():
setup(
name=name,
version=get_version(),
description=description,
long_description=get_long_description(),
url=url,
author=author,
author_email=author_email,
keywords=keywords.split(),
license=license,
packages=[
"miniamf", "miniamf._accel", "miniamf.adapters", "miniamf.util"
],
install_requires=["six", "defusedxml"],
features={"accel": AccelFeature(have_cython)},
test_suite="tests",
zip_safe=True,
extras_require={
"docs": [
"sphinx >= 1.5",
]
},
classifiers=[
l for l in (ll.strip() for ll in classifiers.splitlines()) if l
],
)
if __name__ == "__main__":
setup_package()