-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyoxidizer.bzl
92 lines (69 loc) · 2.83 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
IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
RELIABLY_VERSION = VARS.get("RELIABLY_VERSION")
def make_exe():
dist = default_python_distribution(python_version="3.10")
policy = dist.make_python_packaging_policy()
policy.allow_in_memory_shared_library_loading = True
policy.bytecode_optimize_level_one = True
policy.include_non_distribution_sources = False
policy.include_test = False
policy.resources_location = "in-memory"
policy.resources_location_fallback = "filesystem-relative:lib"
if IS_WINDOWS:
policy.bytecode_optimize_level_one = True
policy.extension_module_filter = "all"
policy.include_file_resources = True
policy.allow_files = True
policy.file_scanner_emit_files = True
policy.resources_location = "filesystem-relative:lib"
python_config = dist.make_python_interpreter_config()
python_config.module_search_paths = ["$ORIGIN", "$ORIGIN/lib"]
python_config.run_command = "from reliably_cli.__main__ import cli; cli()"
exe = dist.to_python_executable(
name="reliably",
packaging_policy=policy,
config=python_config,
)
if IS_WINDOWS:
exe.windows_runtime_dlls_mode = "always"
exe.windows_subsystem = "console"
exe.add_python_resources(exe.pip_install(["--prefer-binary", "--no-binary", "chaostoolkit-reliably", "-r", "requirements-generated.txt"]))
exe.add_python_resources(exe.pip_install(["--prefer-binary", "--no-deps", "reliably-cli"]))
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
files = FileManifest()
files.add_python_resource(".", exe)
return files
def make_msi(exe):
return exe.to_wix_msi_builder(
"reliably",
"Reliably",
RELIABLY_VERSION,
"ChaosIQ Ltd"
)
def make_macos_app_bundle(exe):
bundle = MacOsApplicationBundleBuilder("Reliably")
bundle.set_info_plist_required_keys(
display_name="Reliably",
identifier="com.reliably.rbly",
version=RELIABLY_VERSION,
signature="rbly",
executable="reliably",
)
universal = AppleUniversalBinary("reliably")
universal.add_path("dist/x86_64-apple-darwin/reliably")
m = FileManifest()
m.add_file(universal.to_file_content())
bundle.add_macos_manifest(m)
return bundle
# Tell PyOxidizer about the build targets defined above.
register_target("exe", make_exe)
register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"], default=True)
register_target("msi", make_msi, depends=["exe"])
register_target("macos", make_macos_app_bundle, depends=["exe"])
# Resolve whatever targets the invoker of this configuration file is requesting
# be resolved.
resolve_targets()