forked from unbit/uwsgi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
110 lines (85 loc) · 2.76 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
import os
import sys
import uwsgiconfig as uc
import shutil
from setuptools import setup
from setuptools.dist import Distribution
from setuptools.command.install import install
from setuptools.command.install_lib import install_lib
from setuptools.command.build_ext import build_ext
"""
This is a hack allowing you installing
uWSGI and uwsgidecorators via pip and easy_install
since 1.9.11 it automatically detects pypy
"""
uwsgi_compiled = False
def get_profile():
is_pypy = False
try:
import __pypy__
is_pypy = True
except ImportError:
pass
if is_pypy:
profile = os.environ.get('UWSGI_PROFILE', 'buildconf/pypy.ini')
else:
profile = os.environ.get('UWSGI_PROFILE', 'buildconf/default.ini')
if not profile.endswith('.ini'):
profile = "%s.ini" % profile
if not '/' in profile:
profile = "buildconf/%s" % profile
return profile
def patch_bin_path(cmd, conf):
bin_name = conf.get('bin_name')
if not os.path.isabs(bin_name):
print('Patching "bin_name" to properly install_scripts dir')
try:
if not os.path.exists(cmd.install_scripts):
os.makedirs(cmd.install_scripts)
conf.set('bin_name',
os.path.join(cmd.install_scripts, conf.get('bin_name')))
except:
conf.set('bin_name', sys.prefix + '/bin/' + bin_name)
class uWSGIBuilder(build_ext):
def run(self):
global uwsgi_compiled
if not uwsgi_compiled:
conf = uc.uConf(get_profile())
patch_bin_path(self, conf)
uc.build_uwsgi(conf)
uwsgi_compiled = True
class uWSGIInstall(install):
def run(self):
global uwsgi_compiled
if not uwsgi_compiled:
conf = uc.uConf(get_profile())
patch_bin_path(self, conf)
uc.build_uwsgi(conf)
uwsgi_compiled = True
install.run(self)
class uWSGIInstallLib(install_lib):
def run(self):
global uwsgi_compiled
if not uwsgi_compiled:
conf = uc.uConf(get_profile())
patch_bin_path(self, conf)
uc.build_uwsgi(conf)
uwsgi_compiled = True
install_lib.run(self)
class uWSGIDistribution(Distribution):
def __init__(self, *attrs):
Distribution.__init__(self, *attrs)
self.cmdclass['install'] = uWSGIInstall
self.cmdclass['install_lib'] = uWSGIInstallLib
self.cmdclass['build_ext'] = uWSGIBuilder
def is_pure(self):
return False
setup(name='uWSGI',
version=uc.uwsgi_version,
description='The uWSGI server',
author='Unbit',
author_email='info@unbit.it',
license='GPL2',
py_modules=['uwsgidecorators'],
distclass=uWSGIDistribution,
)