forked from bentoml/OpenLLM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyoxidizer.bzl
106 lines (87 loc) · 3.4 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright 2023 BentoML Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Entrypoint for using pyoxidizer to package openllm into standalone binary distribution."""
VERSION = VARS["version"]
APP_NAME = "openllm"
DISPLAY_NAME = "OpenLLM"
AUTHOR = "BentoML"
def make_msi(target_triple):
if target_triple == "x86_64-pc-windows-msvc":
arch = "x64"
elif target_triple == "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://github.com/bentoml/OpenLLM/"
msi.license_path = CWD + "/LICENSE.md"
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_file_manifest.html
m = FileManifest()
exe_prefix = "targets/" + target_triple + "/"
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_app_bundle():
# https://gregoryszorc.com/docs/pyoxidizer/main/tugger_starlark_type_macos_application_bundle_builder.html
bundle = MacOsApplicationBundleBuilder(DISPLAY_NAME)
bundle.set_info_plist_required_keys(
display_name = DISPLAY_NAME,
identifier = "com.github.bentoml." + APP_NAME,
version = VERSION,
signature = "oplm",
executable = APP_NAME,
)
# 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())
bundle.add_macos_manifest(m)
return bundle
register_target("windows_installers", make_exe_installer, default = True)
register_target("macos_app_bundle", make_macos_app_bundle)
resolve_targets()