Debian Codegraph @

pyqtbuild/bundle/qt_wheel_main.py

raw
1 # SPDX-License-Identifier: BSD-2-Clause
2
3 # Copyright (c) 2024 Phil Thompson <[email protected]>
4
5
6 from argparse import ArgumentParser
7 import sys
8
9 from sipbuild import handle_exception
10
11 from ..version import PYQTBUILD_VERSION_STR
12
13 from .qt_wheel import qt_wheel
14 from .verbose import set_verbose
15
16
17 def main():
18 """ Create a Qt wheel to support a particular PyQt package. """
19
20 # Parse the command line.
21 parser = ArgumentParser(
22 description="Create a wheel containing the Qt installation for a PyQt package.")
23
24 parser.add_argument('-V', '--version', action='version',
25 version=PYQTBUILD_VERSION_STR)
26
27 parser.add_argument('--verbose', default=False, action='store_true',
28 help="enable verbose progress messages")
29
30 if sys.platform == 'darwin':
31 parser.add_argument('--arch', choices=('x86_64', 'arm64'),
32 help="the architecture to create the wheel for")
33
34 parser.add_argument('--build-tag', metavar='TAG',
35 help="use TAG as the build tag in the wheel name")
36
37 parser.add_argument('--exclude', metavar="NAME", default=[],
38 action='append', help="exclude the NAME library from the wheel")
39
40 parser.add_argument('--no-msvc-runtime', dest='msvc_runtime', default=True,
41 action='store_false',
42 help="don't include msvcp140.dll, concrt140.dll and "
43 "vcruntime140.dll in the wheel")
44
45 parser.add_argument('--no-openssl', dest='openssl', default=True,
46 action='store_false',
47 help="don't include the OpenSSL DLLs in the wheel")
48
49 parser.add_argument('--openssl-dir', metavar='DIR',
50 help="replace the OpenSSL DLLs with the versions in DIR")
51
52 parser.add_argument('--qt-dir', metavar='DIR', required=True,
53 help="the Qt installation in DIR to be copied to the wheel")
54
55 parser.add_argument('--suffix', metavar='SUFFIX',
56 help="append SUFFIX to the Qt version number")
57
58 parser.add_argument(dest='packages', nargs=1, help="the PyQt package",
59 metavar="PACKAGE")
60
61 parser.add_argument('--subwheel', choices=('generate', 'exclude'),
62 default=None,
63 help="generate the package's sub-wheel or exclude the sub-wheel "
64 "contents from the main wheel [default: generate a full "
65 "wheel]")
66
67 args = parser.parse_args()
68
69 try:
70 set_verbose(args.verbose)
71
72 try:
73 arch = args.arch
74 except AttributeError:
75 arch = None
76
77 subwheel = args.subwheel
78
79 if subwheel == 'generate':
80 subwheel = True
81 elif subwheel == 'exclude':
82 subwheel = False
83
84 qt_wheel(package=args.packages[0], qt_dir=args.qt_dir,
85 build_tag=args.build_tag, suffix=args.suffix,
86 msvc_runtime=args.msvc_runtime, openssl=args.openssl,
87 openssl_dir=args.openssl_dir, exclude=args.exclude, arch=arch,
88 subwheel=subwheel)
89 except Exception as e:
90 handle_exception(e)
91
92 return 0