File: builder.py

package info (click to toggle)
qtile 0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,004 kB
  • sloc: python: 49,959; ansic: 4,371; xml: 324; sh: 260; makefile: 218
file content (44 lines) | stat: -rw-r--r-- 1,599 bytes parent folder | download
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
import sys

from setuptools import build_meta as _orig
from setuptools.build_meta import *  # noqa: F401,F403

WAYLAND_FFI_BUILD = "./libqtile/backend/wayland/cffi/build.py"


def wants_wayland(config_settings):
    if config_settings:
        for key in ["Backend", "backend"]:
            if config_settings.get(key, "").lower() == "wayland":
                return True

    return False


def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
    """If wayland backend is requested, build it!"""
    if config_settings is None:
        config_settings = {}

    wayland_requested = wants_wayland(config_settings)
    try:
        from libqtile.backend.wayland.cffi.build import ffi_compile

        ffi_compile(verbose=wayland_requested)
    except Exception as e:
        if wayland_requested:
            sys.exit(f"Wayland backend requested but backend could not be built: {e}")
        else:
            print("Wayland backend was not built.")

    # Write library paths to file, if they are specified at build time via
    # --config-settings=PANGO_PATH=...
    libs = ["PANGO", "PANGOCAIRO", "GOBJECT", "XCBCURSOR"]
    if set(libs).intersection(config_settings.keys()):
        with open("libqtile/_build_config.py", "w") as f:
            f.write("# This file is generated at build time by builder.py\n")
            for lib in ["PANGO", "PANGOCAIRO", "GOBJECT", "XCBCURSOR"]:
                p = lib + "_PATH"
                f.write(f"{p} = {config_settings.get(lib)!r}\n")

    return _orig.build_wheel(wheel_directory, config_settings, metadata_directory)