2021-03-23 22:18:08 +03:00
|
|
|
# -*- mode: python ; coding: utf-8 -*-
|
|
|
|
import importlib
|
2022-09-27 02:35:33 +03:00
|
|
|
import os
|
2021-03-23 22:18:08 +03:00
|
|
|
import pathlib
|
|
|
|
import platform
|
2022-04-22 03:01:17 +03:00
|
|
|
import sysconfig
|
2021-03-23 22:18:08 +03:00
|
|
|
|
|
|
|
from PyInstaller.utils.hooks import collect_submodules, copy_metadata
|
|
|
|
|
|
|
|
THIS_IS_WINDOWS = platform.system().lower().startswith("win")
|
2021-10-29 01:37:46 +03:00
|
|
|
THIS_IS_MAC = platform.system().lower().startswith("darwin")
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
ROOT = pathlib.Path(importlib.import_module("chia").__file__).absolute().parent.parent
|
2021-03-23 22:18:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
keyring_imports = collect_submodules("keyring.backends")
|
|
|
|
|
|
|
|
# keyring uses entrypoints to read keyring.backends from metadata file entry_points.txt.
|
|
|
|
keyring_datas = copy_metadata("keyring")[0]
|
|
|
|
|
2023-09-27 23:01:08 +03:00
|
|
|
version_data = [
|
|
|
|
copy_metadata(name)[0]
|
|
|
|
for name in ["chia-blockchain", "chiapos"]
|
|
|
|
]
|
2021-03-23 22:18:08 +03:00
|
|
|
|
|
|
|
block_cipher = None
|
|
|
|
|
|
|
|
SERVERS = [
|
2022-02-08 05:29:54 +03:00
|
|
|
"data_layer",
|
2021-03-23 22:18:08 +03:00
|
|
|
"wallet",
|
|
|
|
"full_node",
|
|
|
|
"harvester",
|
|
|
|
"farmer",
|
|
|
|
"introducer",
|
|
|
|
"timelord",
|
|
|
|
]
|
|
|
|
|
2023-05-22 19:48:27 +03:00
|
|
|
if THIS_IS_WINDOWS:
|
|
|
|
hidden_imports_for_windows = ["win32timezone", "win32cred", "pywintypes", "win32ctypes.pywin32"]
|
|
|
|
else:
|
|
|
|
hidden_imports_for_windows = []
|
|
|
|
|
|
|
|
hiddenimports = [
|
|
|
|
*collect_submodules("chia"),
|
|
|
|
*keyring_imports,
|
|
|
|
*hidden_imports_for_windows,
|
|
|
|
]
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2022-09-27 02:35:33 +03:00
|
|
|
binaries = []
|
|
|
|
|
|
|
|
if os.path.exists(f"{ROOT}/madmax/chia_plot"):
|
|
|
|
binaries.extend([
|
|
|
|
(
|
|
|
|
f"{ROOT}/madmax/chia_plot",
|
|
|
|
"madmax"
|
|
|
|
)
|
|
|
|
])
|
|
|
|
|
|
|
|
if os.path.exists(f"{ROOT}/madmax/chia_plot_k34",):
|
|
|
|
binaries.extend([
|
|
|
|
(
|
|
|
|
f"{ROOT}/madmax/chia_plot_k34",
|
|
|
|
"madmax"
|
|
|
|
)
|
|
|
|
])
|
2021-04-06 00:43:20 +03:00
|
|
|
|
2022-09-27 02:35:33 +03:00
|
|
|
if os.path.exists(f"{ROOT}/bladebit/bladebit"):
|
2021-10-29 01:37:46 +03:00
|
|
|
binaries.extend([
|
|
|
|
(
|
|
|
|
f"{ROOT}/bladebit/bladebit",
|
|
|
|
"bladebit"
|
|
|
|
)
|
|
|
|
])
|
2021-04-06 00:43:20 +03:00
|
|
|
|
2023-07-25 04:57:49 +03:00
|
|
|
if os.path.exists(f"{ROOT}/bladebit/bladebit_cuda"):
|
|
|
|
binaries.extend([
|
|
|
|
(
|
|
|
|
f"{ROOT}/bladebit/bladebit_cuda",
|
|
|
|
"bladebit"
|
|
|
|
)
|
|
|
|
])
|
|
|
|
|
2021-03-23 22:18:08 +03:00
|
|
|
if THIS_IS_WINDOWS:
|
2021-04-06 00:43:20 +03:00
|
|
|
chia_mod = importlib.import_module("chia")
|
2022-04-22 03:01:17 +03:00
|
|
|
dll_paths = pathlib.Path(sysconfig.get_path("platlib")) / "*.dll"
|
2021-04-06 00:43:20 +03:00
|
|
|
|
2021-03-23 22:18:08 +03:00
|
|
|
binaries = [
|
|
|
|
(
|
2021-04-06 00:43:20 +03:00
|
|
|
dll_paths,
|
2021-03-23 22:18:08 +03:00
|
|
|
".",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"C:\\Windows\\System32\\msvcp140.dll",
|
|
|
|
".",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"C:\\Windows\\System32\\vcruntime140_1.dll",
|
|
|
|
".",
|
|
|
|
),
|
2021-10-29 01:37:46 +03:00
|
|
|
(
|
|
|
|
f"{ROOT}\\madmax\\chia_plot.exe",
|
|
|
|
"madmax"
|
|
|
|
),
|
|
|
|
(
|
|
|
|
f"{ROOT}\\madmax\\chia_plot_k34.exe",
|
|
|
|
"madmax"
|
|
|
|
),
|
|
|
|
(
|
|
|
|
f"{ROOT}\\bladebit\\bladebit.exe",
|
|
|
|
"bladebit"
|
|
|
|
),
|
2023-07-25 04:57:49 +03:00
|
|
|
(
|
|
|
|
f"{ROOT}\\bladebit\\bladebit_cuda.exe",
|
|
|
|
"bladebit"
|
|
|
|
),
|
2021-03-23 22:18:08 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
datas = []
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
datas.append((f"{ROOT}/chia/util/english.txt", "chia/util"))
|
|
|
|
datas.append((f"{ROOT}/chia/util/initial-config.yaml", "chia/util"))
|
2023-05-22 19:48:27 +03:00
|
|
|
for path in sorted({path.parent for path in ROOT.joinpath("chia").rglob("*.hex")}):
|
|
|
|
datas.append((f"{path}/*.hex", path.relative_to(ROOT)))
|
2021-04-06 00:43:20 +03:00
|
|
|
datas.append((f"{ROOT}/chia/ssl/*", "chia/ssl"))
|
|
|
|
datas.append((f"{ROOT}/mozilla-ca/*", "mozilla-ca"))
|
2023-09-27 23:01:08 +03:00
|
|
|
datas.extend(version_data)
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
pathex = []
|
2021-03-23 22:18:08 +03:00
|
|
|
|
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
def add_binary(name, path_to_script, collect_args):
|
2021-03-23 22:18:08 +03:00
|
|
|
analysis = Analysis(
|
2021-04-06 00:43:20 +03:00
|
|
|
[path_to_script],
|
2021-03-23 22:18:08 +03:00
|
|
|
pathex=pathex,
|
|
|
|
binaries=binaries,
|
|
|
|
datas=datas,
|
|
|
|
hiddenimports=hiddenimports,
|
|
|
|
hookspath=[],
|
|
|
|
runtime_hooks=[],
|
|
|
|
excludes=[],
|
|
|
|
win_no_prefer_redirects=False,
|
|
|
|
win_private_assemblies=False,
|
|
|
|
cipher=block_cipher,
|
|
|
|
noarchive=False,
|
|
|
|
)
|
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
binary_pyz = PYZ(analysis.pure, analysis.zipped_data, cipher=block_cipher)
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
binary_exe = EXE(
|
|
|
|
binary_pyz,
|
2021-03-23 22:18:08 +03:00
|
|
|
analysis.scripts,
|
|
|
|
[],
|
|
|
|
exclude_binaries=True,
|
2021-04-06 00:43:20 +03:00
|
|
|
name=name,
|
2021-03-23 22:18:08 +03:00
|
|
|
debug=False,
|
|
|
|
bootloader_ignore_signals=False,
|
|
|
|
strip=False,
|
|
|
|
)
|
|
|
|
|
2021-04-06 00:43:20 +03:00
|
|
|
collect_args.extend(
|
|
|
|
[
|
|
|
|
binary_exe,
|
|
|
|
analysis.binaries,
|
|
|
|
analysis.zipfiles,
|
|
|
|
analysis.datas,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
COLLECT_ARGS = []
|
|
|
|
|
|
|
|
add_binary("chia", f"{ROOT}/chia/cmds/chia.py", COLLECT_ARGS)
|
|
|
|
add_binary("daemon", f"{ROOT}/chia/daemon/server.py", COLLECT_ARGS)
|
|
|
|
|
|
|
|
for server in SERVERS:
|
|
|
|
add_binary(f"start_{server}", f"{ROOT}/chia/server/start_{server}.py", COLLECT_ARGS)
|
2021-03-23 22:18:08 +03:00
|
|
|
|
2022-04-18 23:58:44 +03:00
|
|
|
add_binary("start_crawler", f"{ROOT}/chia/seeder/start_crawler.py", COLLECT_ARGS)
|
|
|
|
add_binary("start_seeder", f"{ROOT}/chia/seeder/dns_server.py", COLLECT_ARGS)
|
2022-09-01 07:19:40 +03:00
|
|
|
add_binary("start_data_layer_http", f"{ROOT}/chia/data_layer/data_layer_server.py", COLLECT_ARGS)
|
2023-04-15 03:07:00 +03:00
|
|
|
add_binary("start_data_layer_s3_plugin", f"{ROOT}/chia/data_layer/s3_plugin_service.py", COLLECT_ARGS)
|
2023-05-30 20:50:31 +03:00
|
|
|
add_binary("timelord_launcher", f"{ROOT}/chia/timelord/timelord_launcher.py", COLLECT_ARGS)
|
2022-04-18 23:58:44 +03:00
|
|
|
|
2021-03-23 22:18:08 +03:00
|
|
|
COLLECT_KWARGS = dict(
|
|
|
|
strip=False,
|
|
|
|
upx_exclude=[],
|
|
|
|
name="daemon",
|
|
|
|
)
|
|
|
|
|
|
|
|
coll = COLLECT(*COLLECT_ARGS, **COLLECT_KWARGS)
|