forked from twisted/twisted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·131 lines (108 loc) · 4.07 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
#!/usr/bin/env python
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Distutils installer for Twisted.
"""
try:
# Load setuptools, to build a specific source package
import setuptools
except ImportError:
pass
import sys, os
# remove the generator_failure_tests.py test which fails on Python 2.4
# with a syntax error
from distutils.command.sdist import sdist as _sdist
class twisted_sdist(_sdist):
def run(self):
from distutils.filelist import FileList
self.filelist = FileList()
self.check_metadata()
self.get_file_list()
self.filelist.files.remove('twisted/test/generator_failure_tests.py')
if self.manifest_only: return
self.make_distribution()
# some unpackaged files are being installed, work around that.
# For example, see: https://bugzilla.redhat.com/show_bug.cgi?id=198877#c1
from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm
class twisted_bdist_rpm(_bdist_rpm):
def _make_spec_file(self):
spec_file = _bdist_rpm._make_spec_file(self)
spec_file.insert(0, '%define _unpackaged_files_terminate_build 0')
return(spec_file)
def getExtensions():
"""
Get all extensions from core and all subprojects.
"""
extensions = []
if not sys.platform.startswith('java'):
for dir in os.listdir("twisted") + [""]:
topfiles = os.path.join("twisted", dir, "topfiles")
if os.path.isdir(topfiles):
ns = {}
setup_py = os.path.join(topfiles, "setup.py")
execfile(setup_py, ns, ns)
if "extensions" in ns:
extensions.extend(ns["extensions"])
return extensions
def main(args):
"""
Invoke twisted.python.dist with the appropriate metadata about the
Twisted package.
"""
if os.path.exists('twisted'):
sys.path.insert(0, '.')
from twisted import copyright
from twisted.python.dist import getDataFiles, getScripts, getPackages, setup
# "" is included because core scripts are directly in bin/
projects = [''] + [x for x in os.listdir('bin')
if os.path.isdir(os.path.join("bin", x))
and not x.startswith(".")]
scripts = []
for i in projects:
scripts.extend(getScripts(i))
setup_args = dict(
# metadata
name="Twisted",
version=copyright.version,
description="An asynchronous networking framework written in "
"Python",
author="Twisted Matrix Laboratories",
author_email="twisted-python@twistedmatrix.com",
maintainer="Glyph Lefkowitz",
maintainer_email="glyph@twistedmatrix.com",
url="http://twistedmatrix.com/",
license="MIT",
long_description="""\
An extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
""",
packages = getPackages('twisted'),
conditionalExtensions = getExtensions(),
scripts = scripts,
data_files=getDataFiles('twisted'),
)
if 'setuptools' in sys.modules:
from pkg_resources import parse_requirements
requirements = ["zope.interface"]
try:
list(parse_requirements(requirements))
except:
print """You seem to be running a very old version of setuptools.
This version of setuptools has a bug parsing dependencies, so automatic
dependency resolution is disabled.
"""
else:
setup_args['install_requires'] = requirements
setup_args['include_package_data'] = True
setup_args['zip_safe'] = False
setup_args['cmdclass'] = { 'sdist' : twisted_sdist }
# Python v2.4 and lower...
if sys.version_info[0] <= 2 and sys.version_info[1] <= 4:
setup_args['cmdclass']['sdist'] = twisted_sdist
setup(**setup_args)
if __name__ == "__main__":
try:
main(sys.argv[1:])
except KeyboardInterrupt:
sys.exit(1)