Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FindPython.py « Modules « config « scons « build_files - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 03c9d5487d055e3f70dc587f733e24126fdb4874 (plain)
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
import os

def FindPython():
    all_abi_flags = ['m', 'mu', '']

    python = "/usr"
    abi_flags = "m"  # Most common for linux distros
    version = "3.3"

    _arch = "x86_64-linux-gnu"

    # Determine ABI flags used on this system
    include = os.path.join(python, "include")
    for cur_flags in all_abi_flags:
        inc = os.path.join(include, "python" + version + cur_flags, "Python.h")
        if os.path.exists(inc):
            abi_flags = cur_flags
            break

    # Find config.h. In some distros, such as ubuntu 12.10 they are not in standard include dir.
    incconf = os.path.join(include, _arch, "python" + version + cur_flags)
    if not os.path.exists(os.path.join(incconf, "pyconfig.h")):
        incconf = ''

    # Determine whether python is in /usr/lib or /usr/lib64
    lib32 = os.path.join(python, "lib", "python" + version, "sysconfig.py")
    lib64 = os.path.join(python, "lib64", "python" + version, "sysconfig.py")
    if os.path.exists(lib32):
        libpath = "${BF_PYTHON}/lib"
    elif os.path.exists(lib64):
        libpath = "${BF_PYTHON}/lib64"
    else:
        # roll back to default value
        libpath = "${BF_PYTHON}/lib"

    libpath_arch = libpath
    _libpath_arch = os.path.join(python, "lib", _arch)  # No lib64 stuff with recent deb-like distro afaik...
    _libs = ["libpython" + version + abi_flags + ext for ext in (".so", ".a")]
    for l in _libs:
        if not os.path.exists(os.path.join(libpath, l)) and os.path.exists(os.path.join(_libpath_arch, l)):
            libpath_arch = os.path.join(libpath, _arch)
            break

    return {"PYTHON": python,
            "VERSION": version,
            "LIBPATH": libpath,
            "LIBPATH_ARCH": libpath_arch,
            "ABI_FLAGS": abi_flags,
            "CONFIG": incconf}