forked from python-greenlet/greenlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·114 lines (97 loc) · 3.82 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
#! /usr/bin/env python
import sys, os, glob, platform, tempfile, shutil
# workaround segfaults on openbsd and RHEL 3 / CentOS 3 . see
# https://bitbucket.org/ambroff/greenlet/issue/11/segfault-on-openbsd-i386
# https://github.com/python-greenlet/greenlet/issues/4
if ((sys.platform == "openbsd4" and os.uname()[-1] == "i386")
or ("-with-redhat-3." in platform.platform() and platform.machine() == 'i686')
or (sys.platform == "sunos5" and os.uname()[-1] == "sun4v")
or ("SunOS" in platform.platform() and platform.machine() == "sun4v")):
os.environ["CFLAGS"] = ("%s %s" % (os.environ.get("CFLAGS", ""), "-Os")).lstrip()
try:
if not (sys.modules.get("setuptools")
or "develop" in sys.argv
or "upload" in sys.argv
or "bdist_egg" in sys.argv
or "bdist_wheel" in sys.argv
or "test" in sys.argv):
raise ImportError()
from setuptools import setup, Extension
setuptools_args = dict(test_suite='tests.test_collector', zip_safe=False)
except ImportError:
from distutils.core import setup, Extension
setuptools_args = dict()
def readfile(filename):
f = open(filename)
try:
return f.read()
finally:
f.close()
def _find_platform_headers():
return glob.glob("platform/switch_*.h")
if hasattr(sys, "pypy_version_info"):
ext_modules = []
headers = []
else:
headers = ['greenlet.h']
if sys.platform == 'win32' and '64 bit' in sys.version:
# this works when building with msvc, not with 64 bit gcc
# switch_x64_masm.obj can be created with setup_switch_x64_masm.cmd
extra_objects = ['platform/switch_x64_masm.obj']
else:
extra_objects = []
ext_modules = [Extension(
name='greenlet',
sources=['greenlet.c'],
extra_objects=extra_objects,
depends=['greenlet.h', 'slp_platformselect.h'] + _find_platform_headers())]
from my_build_ext import build_ext as _build_ext
from distutils.core import Command
class build_ext(_build_ext):
def configure_compiler(self):
compiler = self.compiler
if compiler.__class__.__name__ != "UnixCCompiler":
return
compiler.compiler_so += ["-fno-tree-dominator-opts"]
tmpdir = tempfile.mkdtemp()
try:
simple_c = os.path.join(tmpdir, "simple.c")
open(simple_c, "w").write("void foo(){}")
compiler.compile([simple_c], output_dir=tmpdir)
except Exception:
del compiler.compiler_so[-1]
shutil.rmtree(tmpdir)
def build_extensions(self):
self.configure_compiler()
_build_ext.build_extensions(self)
setup(
name="greenlet",
version='0.4.2',
description='Lightweight in-process concurrent programming',
long_description=readfile("README.rst"),
maintainer="Ralf Schmitt",
maintainer_email="[email protected]",
url="https://github.com/python-greenlet/greenlet",
license="MIT License",
platforms=['any'],
headers=headers,
ext_modules=ext_modules,
cmdclass=dict(build_ext=build_ext),
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.4',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.0',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Operating System :: OS Independent',
'Topic :: Software Development :: Libraries :: Python Modules'],
**setuptools_args)