forked from pypa/hatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyoxidizer.bzl
82 lines (63 loc) · 2.27 KB
/
pyoxidizer.bzl
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
VERSION = VARS["version"]
APP_NAME = "hatch"
DISPLAY_NAME = "Hatch"
AUTHOR = "Python Packaging Authority"
def make_msi(target):
if target == "x86_64-pc-windows-msvc":
arch = "x64"
elif target == "i686-pc-windows-msvc":
arch = "x86"
else:
arch = "unknown"
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_wix_msi_builder.html
msi = WiXMSIBuilder(
id_prefix=APP_NAME,
product_name=DISPLAY_NAME,
product_version=VERSION,
product_manufacturer=AUTHOR,
arch=arch,
)
msi.msi_filename = DISPLAY_NAME + "-" + VERSION + "-" + arch + ".msi"
msi.help_url = "https://hatch.pypa.io/latest/"
msi.license_path = CWD + "/LICENSE.txt"
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_file_manifest.html
m = FileManifest()
exe_prefix = "targets/" + target + "/"
m.add_path(
path=exe_prefix + APP_NAME + ".exe",
strip_prefix=exe_prefix,
)
msi.add_program_files_manifest(m)
return msi
def make_exe_installer():
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_wix_bundle_builder.html
bundle = WiXBundleBuilder(
id_prefix=APP_NAME,
name=DISPLAY_NAME,
version=VERSION,
manufacturer=AUTHOR,
)
bundle.add_vc_redistributable("x64")
bundle.add_vc_redistributable("x86")
bundle.add_wix_msi_builder(
builder=make_msi("x86_64-pc-windows-msvc"),
display_internal_ui=True,
install_condition="VersionNT64",
)
bundle.add_wix_msi_builder(
builder=make_msi("i686-pc-windows-msvc"),
display_internal_ui=True,
install_condition="Not VersionNT64",
)
return bundle
def make_macos_universal_binary():
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_apple_universal_binary.html
universal = AppleUniversalBinary(APP_NAME)
for target in ["aarch64-apple-darwin", "x86_64-apple-darwin"]:
universal.add_path("targets/" + target + "/" + APP_NAME)
m = FileManifest()
m.add_file(universal.to_file_content())
return m
register_target("windows_installers", make_exe_installer, default=True)
register_target("macos_universal_binary", make_macos_universal_binary)
resolve_targets()