File: uwsgiplugin.py

package info (click to toggle)
uwsgi 2.0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,564 kB
  • sloc: ansic: 87,066; python: 7,004; cpp: 1,133; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 148; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (99 lines) | stat: -rw-r--r-- 3,280 bytes parent folder | download | duplicates (2)
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
import os
import sys
try:
    from distutils import sysconfig
    paths = [
        sysconfig.get_python_inc(),
        sysconfig.get_python_inc(plat_specific=True),
    ]
except ImportError:
    import sysconfig
    paths = [
        sysconfig.get_path('include'),
        sysconfig.get_path('platinclude'),
    ]

def get_python_version():
    version = sysconfig.get_config_var('VERSION')
    try:
        version = version + sys.abiflags
    except:
        pass
    return version

NAME = 'python'
GCC_LIST = [
    'python_plugin',
    'pyutils',
    'pyloader',
    'wsgi_handlers',
    'wsgi_headers',
    'wsgi_subhandler',
    'web3_subhandler',
    'pump_subhandler',
    'gil',
    'uwsgi_pymodule',
    'profiler',
    'symimporter',
    'tracebacker',
    'raw'
]

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []

if not 'UWSGI_PYTHON_NOLIB' in os.environ:
    LIBS = sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split()
    # check if it is a non-shared build (but please, add --enable-shared to your python's ./configure script)
    use_static_lib = not sysconfig.get_config_var('Py_ENABLE_SHARED')
    if use_static_lib:
        libdir = sysconfig.get_config_var('LIBPL')
        # libdir does not exists, try to get it from the venv
        version = get_python_version()
        if not os.path.exists(libdir):
            libdir = '%s/lib/python%s/config' % (sys.prefix, version)
        # try skipping abiflag
        if not os.path.exists(libdir) and version.endswith('m'):
            version = version[:-1]
            libdir = '%s/lib/python%s/config' % (sys.prefix, version)
        # try 3.x style config dir
        if not os.path.exists(libdir):
            libdir = '%s/lib/python%s/config-%s' % (sys.prefix, version, get_python_version())
        # try >=3.6 style config dir with arch as suffix
        if not os.path.exists(libdir):
            multiarch = sysconfig.get_config_var('MULTIARCH')
            libdir = '%s/lib/python%s/config-%s-%s' % (sys.prefix, version, get_python_version(), multiarch) 

        # get cpu type
        uname = os.uname()
        if uname[4].startswith('arm'):
            libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LIBRARY'))
            if not os.path.exists(libpath): 
                libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LDLIBRARY'))
        else:
            libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LDLIBRARY'))
            if not os.path.exists(libpath): 
                libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LIBRARY'))
        if not os.path.exists(libpath): 
            libpath = '%s/libpython%s.a' % (libdir, version)

        if os.path.exists(libpath):
            LIBS.append(libpath)
            # hack for messy linkers/compilers
            if '-lutil' in LIBS:
                LIBS.append('-lutil')
            if '-lrt' in LIBS:
                LIBS.append('-lrt')
        else:
            use_static_lib = False
    if not use_static_lib:
        try:
            libdir = sysconfig.get_config_var('LIBDIR')
        except:
            libdir = "%s/lib" % sysconfig.PREFIX

        LDFLAGS.append("-L%s" % libdir)

        LIBS.append('-lpython%s' % get_python_version())
else:
    LIBS = []