File: make-manpages

package info (click to toggle)
pyside6 6.10.2-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 48,184 kB
  • sloc: python: 205,032; cpp: 92,990; xml: 18,587; javascript: 1,182; sh: 163; makefile: 89
file content (101 lines) | stat: -rwxr-xr-x 2,691 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
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
#!/usr/bin/python3

import os
from pathlib import Path
import subprocess
import textwrap


skip_tools = [
    "android-deploy",
    "assistant",
    "balsamui",
    "designer",
    "linguist",
    "qmlimportscanner",
]


def help2man(tool):
    toolname = str(tool.stem).replace("pyside6-", "")
    if toolname in skip_tools:
        print(f"I: skipping {toolname} as configured")
        return

    print(f"I: attempting to make man page for {toolname} ({tool})")
    _run_help2man(tool, toolname, "--help")


def _run_help2man(tool, toolname, help_opt):
    cmd = [
        "xvfb-run",
        "--auto-servernum",
        "help2man",
        "--name",
        toolname,
        "--section",
        "1",
        "--manual",
        "PySide6 tools",
        "--help-option",
        help_opt,
        "--version-string",
        pyside_version,
        "--no-info",  # suppress "see info pages" footer
        "--output",
        str(mandir / (tool.stem + ".1")),
        str(tool),
    ]
    cmd_summary = [
        f"LD_LIBRARY_PATH={env["LD_LIBRARY_PATH"]} ",
        f"PYTHONPATH={env["PYTHONPATH"]} ",
        "'",
        "' '".join(cmd),
        "'",
    ]
    print(f"I: {''.join(cmd_summary)}")

    # Run the tool
    ret = subprocess.run(cmd, capture_output=True, timeout=10, encoding="UTF-8", env=env)
    if ret.returncode != 0:
        print(f"W: returned: {ret.returncode}:\n")
        print(textwrap.indent(ret.stdout, "W: "))
        print(textwrap.indent(ret.stderr, "W: "))


# PATH CONFIG FOR TOOL
wd = Path.cwd()

# In preparation for debhelper, debian/tmp will be used for most operations
# except for the list of tools, which we get from those installed into the
# pyside6-tools package
tmppath = wd / "debian" / "tmp"
modpath = list((tmppath / "usr" / "lib").glob("python*"))[0] / "dist-packages"
bindir = wd / "debian" / "pyside6-tools" / "usr" / "bin"
mandir = tmppath  # dh_installman will sort this out for us

# help2man needs to run the tools but that means that the tools have to be
# able to find libraries / python modules.
libpaths = [
    str(modpath / "shiboken6"),
    str(modpath / "PySide6"),
]
if "LD_LIBRARY_PATH" in os.environ:
    libpaths.append(os.environ["LD_LIBRARY_PATH"])
env = {
    "LD_LIBRARY_PATH": ":".join(libpaths),
    "PYTHONPATH": str(modpath),
}

# Override the version in all pages (lots of tools don't have a --version
# option to extract the version)
pyside_version = os.environ.get("PYSIDE_MAJOR")
if not pyside_version:
    print("W: PySide6 version not available, this should be set in d/rules")
    pyside_version = "6"


mandir.mkdir(exist_ok=True, parents=True)

for tool in sorted(bindir.iterdir()):
    help2man(tool)